#django

/

      • maryokhin joined the channel
      • maryokhin has quit
      • Debnet has quit
      • surfnturf_ has quit
      • skay has quit
      • hutch34 joined the channel
      • p4trix has quit
      • ellmetha joined the channel
      • govg joined the channel
      • maks25 has quit
      • Volund
        SO
      • FunkyBob
        no SO!
      • Volund
        FunkyBob, got a really weird question for thee.
      • maks25 joined the channel
      • hutch34 has quit
      • let's say you have Model A and Model B, and Model Y and Model Z. B is a proxy model for A, and Z for Y. Model Y/Z also has a foreign key to A/B
      • if you start from Model Z and poke its related manager for Model A/B, will you get an instance of A, or B?
      • jtri joined the channel
      • I'd imagine A.
      • jtri
        Is there a good way to specifiy a db constraint where exactly one of 4 columns shoudl be non-null?
      • using postgres
      • Ariel_Calzada joined the channel
      • detseg joined the channel
      • FunkyBob
        jtri: I'm sure you could using xor...
      • moldy
        jtri: not through thte orm, but with raw sql, i think so, yes
      • not_a_web_devbot has quit
      • Koterpillar
        FunkyBob: how would xor work for more than 2 columns?
      • not_a_web_devbot joined the channel
      • not_a_web_devbot has quit
      • not_a_web_devbot joined the channel
      • not_a_web_devbot has quit
      • FunkyBob
        just pondering how you'd implement a 4-way xor in sql...
      • Koterpillar
        what is a 4-way xor anyway?
      • FunkyBob
        one and only one input is true
      • Koterpillar
        ah, right, ignore
      • djapo has quit
      • linusthebear has quit
      • Tomatosoup- has quit
      • fission6 has quit
      • phinxy has quit
      • maks25 has quit
      • beardedeagle has quit
      • beardedeagle joined the channel
      • hipertracker has quit
      • johnnypyve has quit
      • beardedeagle has quit
      • hipertracker joined the channel
      • beastDivision joined the channel
      • beastDivision has quit
      • kus_ joined the channel
      • amcorreia has quit
      • subleq has quit
      • subleq joined the channel
      • Leeds joined the channel
      • c17r joined the channel
      • not_a_web_devbot joined the channel
      • netheranthem has quit
      • kus_ has quit
      • kus_ joined the channel
      • v0lksman joined the channel
      • not_a_web_devbot has quit
      • v0lksman
        is there a way to probe pytz to give me info like utc offset, the timezone name (IE "Eastern daylight time") and whether the location observes DST from the timezone America/Chicago for example?
      • asadjb joined the channel
      • FunkyBob
        v0lksman: erk... what are you looking up by?
      • csotelo joined the channel
      • v0lksman
        the location
      • so America/Toronto or America/Chicago etc
      • asadjb has quit
      • maks25 joined the channel
      • FunkyBob
        so, it's trivial to find a timezone by name... but you want to extract "common misleading name" and "do they engage in DST"?
      • k_sze[work] has quit
      • k_sze[work] joined the channel
      • v0lksman
        not sure what you mean by common misleading name
      • but yes would like to know if that zone observes dst
      • FunkyBob
        "Eastern Daylight Time" ... how many countries have an eastern daylight time?
      • Koterpillar
        v0lksman: currently or..?
      • FunkyBob
        (I can think of two I'm sure of, possibly 3 or 4)
      • v0lksman
        could be many but based on the location I'm passing the info comes into context
      • AtomicSpark joined the channel
      • dlam has quit
      • Koterpillar: in general, though on a specific date is fine too. I could just do the look up twice...once mid summer and once mid winter
      • Koterpillar
        v0lksman: "in general" makes no sense, as regions introduce and remove DST sometimes
      • v0lksman
        Koterpillar: wouldn't pytz or any lib try to keep that info up to date? it doesn't change that often
      • Koterpillar
        v0lksman: it is up to date, generally, but I'm saying that "has DST in general" is meaningless
      • surfnturf_ joined the channel
      • schinckel
        Yeah, it's only possible to know if a given date will be in DST or not in a given timezone.
      • surfnturf_
        when I delete my LectureFile, the actual file in /media is not being deleted. How do I fix it? https://dpaste.de/jUYv
      • v0lksman
        that's fine...like I said I can do the look up twice and extract that info that way but I still can't figure out how to get the info out of pytz to begin with
      • FunkyBob
        it changes far more often than it ever ought.... and, truely, DST should be abolished.
      • surfnturf_: from memory the docs recomment a post-delete or pre-delete signal handler
      • as well as a cleanup task
      • just in case
      • schinckel
        surfnturf_: You'll have to do that some other way: but it's also worth pointing out that you'll need to be careful to ensure a rolled-back transaction doesn't delete a file that is still required.
      • Koterpillar
        schinckel: transaction.on_success!
      • MarkusH
        FunkyBob: surfnturf_: use an on_commit signal
      • Koterpillar
        on_commit
      • schinckel
        Yeah.
      • MarkusH
        that's the only way to ensure the change is actually committed to the database
      • surfnturf_
        well these are deleting user uploads so i dont think theres a db issue
      • i just want to give them option to delete their files
      • schinckel
        Yeah, there is.
      • If a user deletes a file (field), but the transaction rolls back in some way, then the file should not be deleted.
      • surfnturf_
        ok
      • so basically i listen for an on_commit signal and then manually delete the file myself
      • Koterpillar
        on_commit isn't a signal
      • surfnturf_
        what i was doing before was just letting a bunch of files accumulate and trying to clean up alter
      • Koterpillar
        you register your callback to delete the file with on_commit in a pre-delete signal handler
      • FunkyBob
        MarkusH: morning!
      • redShadow joined the channel
      • sol1x has quit
      • AtomicSpark
        Slightly offtopic but affects us all. Why doesn't this webpage mention a specific python version? Is tle supported TLS version a choice during building? Is building your own python really that popular? https://pyfound.blogspot.com/2017/01/time-to-up...
      • Debian Testing not affected. Don't have access to Stable ATM.
      • FunkyBob
        isn't it more to do with the version of openssl it's linked to?
      • AtomicSpark: it mentions python2... isn't that enough?
      • Koterpillar
        well, Python disabled SSLv2 before
      • FunkyBob: no
      • as you say, Python 3 can still be linked to a brain-dead OpenSSL
      • FunkyBob
      • AtomicSpark
        FunkyBob: It mentions "upgrade your python" a few times.
      • palinf has quit
      • Koterpillar
        FunkyBob: that's not what I meant by "brain-dead"
      • FunkyBob
        Koterpillar: no, just a related query...
      • "Avoid brain-dead SSL, use LibreSSL" :P
      • Phanes
        how do you get a boolean from re.match()
      • Koterpillar
        Phanes: bool(), if you must
      • palinf joined the channel
      • FunkyBob
        Phanes: why do you want this?
      • Phanes
        bah. is not None:
      • maks25 has quit
      • FunkyBob
        it either returns None (which is falsey) or a MatchObject, which is not
      • so "if re.match(...):" will work
      • Phanes
        i always want to if pattern.match(stringy): blah
      • but it's
      • if pattern.match(stringy) is not None: blah
      • FunkyBob
        it's?
      • I've never needed that
      • Phanes
        does not return a bool type
      • FunkyBob
        can you show an example where "if pattern.match():" is insufficient?
      • no, it doesn't
      • shangxiao has quit
      • so what?
      • Phanes
        do type( pattern.match(testString) )
      • FunkyBob
        None is falsey, MatchObject is not... problem solved
      • Koterpillar
        Phanes: are you coming from a language with a strict type system?
      • Phanes
        i am
      • Koterpillar
        Phanes: in Python, every object implements __bool__ (or something like this), which is checked in if
      • FunkyBob
        it doesn't have to be a bool ... just "falsey"
      • Koterpillar
        Phanes: so MatchObject will be considered trueish
      • Phanes
        well that's handy. i've always wanted to be really confused about the types im working with and what their conditional value actually represents
      • FunkyBob
        so None, False, 0, [], {}, set(), .... all falsey