¯\_(ツ)_/¯ seems equivalent to me but, sure, whatever
if it works, it works
Koterpillar
pjs: that would be my preferred approach
cnk joined the channel
mandeep
Koterpillar: if i take out abspath i get an error saying Resume has no len()
pjs
__love__ My method just saves a query or two. I can't shake habits from the 90's apparently
Koterpillar
mandeep: looks like you're passing wrong objects to everything
rns2 joined the channel
mandeep
hmm
Koterpillar
mandeep: what do you *want* to do at that line?
__love__
pjs: it does? doesn't the article view and the category view both perform queries?
mandeep
Koterpillar: pass the uploaded file into another uplod box
Koterpillar
mandeep: well, 'cv' is not an uploaded file
pjs
__love__ Yes, but now you're talking about adding additional queries to the router view
lejedi76 has quit
mandeep
Koterpillar: what can i change to have cv become an uploaded file?
kkuj joined the channel
__love__
pjs: hmm, yeah, i guess. or just pass the actual collected object into the final view
pjs: seems like that final view would never need to actually perform a query itself
Koterpillar
mandeep: I can't see the code around that
pjs
__love__ That's true.
mandeep
Koterpillar: i dont think anything in the script needs to be changed since it's django independent, right?
__love__
pjs: you just gotta know what kind of object you have. easy enough
Koterpillar
mandeep: how would I know if it is if I can't see it?
__love__: what advantage would making a query first give?
mandeep
Koterpillar: the script works if i use request.POST.get('cv')
__love__
Koterpillar: it's more about controlling where the queries are done. do them early and don't do them again
pjs
__love__ Right, that's no issue. Just don't see advantage to change the logic of 2 working views for no real performance gain, or code logic gain.. But who knows, maybe once I write this stupid router view it'll make more sense. I'll keep you posted
__love__: looks like in pjs' case, the queries in the views are early enough
newjersey joined the channel
newjersey has quit
__love__
pjs: ¯\_(ツ)_/¯ this is what 2 minutes of contemplation gets you
pjs
hah!
fair enough
newjersey joined the channel
newjersey has quit
newjersey joined the channel
newjersey has quit
Koterpillar
mandeep: where is django_view() called? I can't deduce what 'cv' and 'resume' are here
newjersey joined the channel
__love__
Koterpillar: sure but there's a query in each view and you have to check for the 404s. w/ my method, there's one "query" (yes, it's two queries but a single queryset in the end) and you don't have to catch 404s. all of the logic is encapsulated in the router view
kkuj has quit
mandeep
Koterpillar: in the views.py. cv is the argument name in line 58 of the script. resume is from the views.py
Koterpillar
__love__: disagree, the logic leaks from the article/category views: what if get_object_or_404 has more parameters that control how the object is found?
__love__
Koterpillar: ¯\_(ツ)_/¯ i don't know that as it hasn't been shared and that should probably be addressed in a model manager, not a view
Koterpillar
mandeep: ok, so instead of the uploaded file you are creating a Resume object from it
killvenom has quit
cyphase joined the channel
__love__: issue still stands, the article view should know how to find the article, not the router view
eluus joined the channel
cyphase joined the channel
eluus has quit
eluus joined the channel
__love__
Koterpillar: not really. the view should be thin and dumb. the model should know how to find an article, the view should just handle the logic of getting the instance to the template. which it would still do.
mandeep
Koterpillar: isn't filefield what i need to use?
Koterpillar
mandeep: you are not using a filefield
__love__
(model, model manager, querysets, etc)
DevilTiger_ has quit
Koterpillar
__love__: the article view will at least call the right manager method
__love__: that part of logic should stay there
__love__
sure. but _any_ view can call that
mandeep
Koterpillar: i have a filefield in my models.py
__love__
if the router depends on a valid record being found, that logic belongs in the router
s/router/router view/
mandeep
and it's being called in the views.py
Koterpillar
__love__: in fact, the router view can be made generic, it should just call several views until one succeeds
__love__: why should _router_ know about the right Article methods to call?
__love__
yeah, that won't get out of hand any time soon
Koterpillar
well, we're just fixing a limitation of the stock router
mandeep: what does this line do? resume = Resume(request.FILES['resume_upload'].read())
dlam` has quit
mandeep
Koterpillar: reads the uploaded file
Koterpillar
mandeep: and then?
mandeep: here's the part that "reads the uploaded file": request.FILES['resume_upload'].read()
mandeep
Koterpillar: and then passes it to the model?
johnmilton joined the channel
Koterpillar
mandeep: OK, so why do you pass the model to django_view() and ultimately to abspath() then?
__love__
Koterpillar: really, i think it's a wash. both approaches are fine and it just depends on how you want the logic fractured.
for now, though, it's time to go have a beer and play a game
Koterpillar
__love__: ++
Nemus has left the channel
mandeep
Koterpillar: im not sure how to pass the file from the model to django_view() and abspath is a carryover from a prior implementation of request.POST.get('resume')
Genitrust joined the channel
Koterpillar
mandeep: why do you pass the file to the model?
mandeep
Koterpillar: i was having memory issues
Koterpillar
in what sense?
kingarmadillo joined the channel
mandeep
Koterpillar: i cant remember the error, but it was something about file not able to be saved in to memory
delgiudices joined the channel
zos_ joined the channel
Koterpillar: InMemoryUploadedfile does not support indexing
Koterpillar
so you decided putting it into Resume() will solve it. However, django_view() expects a file name, not a Resume object, so you have to figure out how to get your file back
mandeep
Koterpillar: any suggestions in what to learn to accomplish this?