as I said.. it's stashed in the session... I don't see why it would be restored then...
AIUI user.backend is only used when logging in a user
Mask777 joined the channel
thrawny joined the channel
RobM_71
then the question becomes: how do I check from a template which backend authenticated the user? :-) (yes, user is already available in templates)
Xiti joined the channel
FunkyBob
again, why do you care?
z1r0_ joined the channel
what is the reason you want to check?
RobM_71
I'm having legacy users (numeric), Active Directory users and django users: some options are valid only for legacy users, and for some {% url %} I get reverse errors (I check digits)
aldnavleech
how do you do internal page links on django templates?
RobM_71
(yeah, it's a mess, but I can't fix the business...)
aldnavleech
i mean focus on that page section
jiang42 joined the channel
jeadre joined the channel
brat197 joined the channel
lietu joined the channel
FunkyBob
aldnavleech: you mean what?
foxmask
bonjello
FunkyBob
dodo?
RobM_71: ok... and tyou're not using separate user models for these? even proxy models could then provide a user.type property
lietu
when running tests in Django it automatically cleans the test database between tests, right? .. I also have memcached, mongo, etc. other code that could require similar clean up steps in between tests. Now it's pretty easy for me to check configuration and based on it return a mockcache/mongomock/similar instance, but is there a way to hook into what django does between all tests other than creating my own test baseclass which would in
setUp/tearDown do these steps?
FunkyBob
setUpClass/setUp/tearDown/tearDownClass
lietu
I'm not saying my own test baseclass is out of the question, just wondering if there's a more "core" hook in django
FunkyBob
you could mock those services out
xterm
Eh? no it doesnt automatically clean test database between tests.
lietu
xterm, it doesn't? is it just between test runs then? as in when you start the tests?
aldnavleech
i'll just ask another one
lietu
at the very end it says "Destroying test database for alias 'default'..."
xterm
lietu: the default behavior is that it destroys the test database after each 'test suite run'
a behavior that the most recent django version has completed with a `--keepdb` switch to allow you to keep the database.
FunkyBob
xterm: it does roll back changes between tests, though
jiang42 has quit
xterm
what!
xterm checks
lietu
fair enough, either way I'd like similar behavior to other services that django isn't as much aware of, and I was wondering if there's a better place to put them in than a common base test class of my own?
subleq has quit
RobM_71
FunkyBob: the only requirement I have to create proxies would be to get the type and if it's available in .backend I'd be fine with that.
FunkyBob
RobM_71: yeah, but yhou seem to be missing my point
RobM_71
I am :-)
lietu
not sure if django's behavior relies on me using anything special but extending unittest.TestCase, so I'd imagine there was another way to hook into that process
FunkyBob
RobM_71: user.backend is, IIRC, only set when authenticatE() is called... and then consumed by login() where it's stashed in the session along with the user id
so that when the middlewqare goes to load the user again, it knows which backend to ask for that user id
however, when doing that it DOES NOT set user.backend again
RobM_71
I see
FunkyBob
I just grepped the source... that is the case
anyway... gotta go
Debnet
o/
RobM_71
but I don't get what am I supposed to proxy, since 2 kind of users are in 2 different tables, AD users aren't in any
thomas is now known as evilthomas
Thank you FunkyBob :-)
grafa joined the channel
grafa has quit
Morroque joined the channel
jessamynsmith joined the channel
primozk has quit
liefer joined the channel
liefer has quit
jessamynsmith has quit
xterm
lietu: I retract my statement, I don't know how i missed this i could've sworn there's no auto rollback whatsoever on the test database.
thanks FunkyBob
lietu
hehe, fair enough
but my interest is mainly in how does the logic work, because it seems like this stuff works if I just use unittest.TestCase (I could be wrong here), so Django probably hooks into unittest somehow, and I was wondering if I could extend this behavior myself
could you maybe point me towards the right module to look into for the code?
djapo
you can extend, its just classes
jarshwah_ joined the channel
lietu
so you're suggesting subclassing TestCase?
djapo
if it suits you
subleq joined the channel
lietu
well that was my original thought but then I realized that it *seems* like Django doesn't need to do that to hook the DB cleanup into it, and I'd like to see if there is a way to extend that behavior further, without subclassing
annefly joined the channel
it could be that for this to work properly django actually expects me to subclass something else than unittest.TestCase and I'm just not doing that and thus my tests don't work the way I expect them to hehe
anyway I need to head off, I might be back later if I can't find a solution
xterm
lietu: it's all about the discovery, don't be shy from subclassing
jarshwah has quit
slav0nic joined the channel
lietu
I'm not
I've done it plenty, I'm just wondering how does django achieve this
xterm
i meant test discovery btw, not you discovering how to do this :-)
lietu
I know
xterm
i'm not aware of any mean to 'plug' functionality like this apart from the setUpClass/setUp/... which bob mentioned
ASonOfGod has quit
jarshwah_ has quit
the majority of the projects i've seen tune their base test classes as such.
david5aa has quit
jeadre joined the channel
djapo
thats the way it should be done. any other way, seems like a unnecessary hack that would introduce unneeded complexity
lietu has quit
nimomo joined the channel
freakboy_ joined the channel
Morroque has quit
BeerLover joined the channel
scarabx has quit
Nizumzen joined the channel
julienp has quit
dodobas
yutro
subleq has quit
jas02 joined the channel
zanderle joined the channel
rdorgueil has quit
rtpg joined the channel
jwhitmore has quit
drag0nius joined the channel
TeeTime joined the channel
tobias47n9e joined the channel
shangxiao joined the channel
akaariai_ joined the channel
Audioburn has quit
slav0nic joined the channel
akaariai has quit
subleq joined the channel
pedrorivera has quit
mascot66991 joined the channel
DarkSector
EncodeError: can't serialize <WSGIRequest>
brat197 has quit
mattmcc
It's not lying.
mascot66991
Hie I just have to store a single variable somewhere in a table. Do I have to create a whole new model just to store this variable or iss there a place where I can store common variables in django's default table? to make it clear I want to use a global variable like SITE and change a functionality based on the value however I dont want it to be in my settings file as that means I have to edit settings file to change the value which i dont want
idioterna
mattmcc: but it is being lazy
mascot66991
any idea how to achieve it without making own table?
tyris has quit
v0r0nwe joined the channel
BlindHunter joined the channel
idioterna
mascot66991: adding a model isn't really expensive
tyris joined the channel
something like Settings(models.Model): name = TextField, value = TextField
mascot66991
idioterna: but just for one variable? I wanted to know if that is possible without it or not? If not I can do that
idioterna
and it's following all the common patterns
1 is ideologically equal to any other integer :)
jeadre joined the channel
mascot66991: i don't think you should make an exception because it's just 1
shangxiao joined the channel
mascot66991
idioterna: okay thanks mate
Quitta joined the channel
TrioTorus joined the channel
mattmcc
mascot66991: Check out django-solo or django-constance.
mascot66991
mattmcc: thanks
panta34 has quit
Quitta has quit
kuter joined the channel
BruteShot has quit
vdboor joined the channel
quetzakubica joined the channel
shashank_ joined the channel
Unifox joined the channel
mattmcc: I think I will go with making my own one as functionalities like template tags and admin interfaces are really not important for me