Re: ORM Question

2014-04-02 Thread Justin Holmes
I think you misunderstand: I am not actually tracking llama herds. :-)

This is just example code; I haven't actually tested it in the way that you
suggest.  The problem isn't with this code in particular, it's with this
concept in general.  This is a question I have had again and again in the
past few years - this code is just a way to articulate it.

So, in short - no, the code won't work as now written, and it's obvious
why: annotate doesn't assign instances, it assigns results.

I don't think I need an annotation expert per se; it may well be that
annotate is the wrong way to do this.

My SQL isn't particularly strong, but if I were writing this in SQL, I
suspect that GROUP_BY is necessary or at least plausible.  I know that
Django doesn't directly expose GROUP_BY, but it looks likes
QuerySet.values() uses it; so I wonder if that fits into the picture
somehow?


On Wed, Apr 2, 2014 at 12:35 PM, Bill Freeman <ke1g...@gmail.com> wrote:

> My point was that annotate might work after the other problems were
> fixed.  Have you re-tested since?  If your annotate still doesn't work then
> perhaps someone with more annotate experience than I will comment.
>
>
>
> On Wed, Apr 2, 2014 at 12:04 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>
>> No no, the annotate doesn't work - that's the whole reason for my
>> question.  See, the annotate doesn't associate instances with the annotated
>> attribute, it associated results.
>>
>> (BTW, good looking out - I have once again fixed the SO question :-))
>>
>>
>> On Wed, Apr 2, 2014 at 10:17 AM, Bill Freeman <ke1g...@gmail.com> wrote:
>>
>>> 1.  You now have a foreign key to Herd, but you don't have a model by
>>> that name.  It's called LlamaHerd.
>>>
>>> 2.  I was misinterpreting what you wanted (couldn't get past the lack of
>>> a relationship while reading0.  Once the relationship is fixed, your
>>> original annotate might work.
>>>
>>>
>>> On Tue, Apr 1, 2014 at 6:20 PM, Justin Holmes 
>>> <jus...@justinholmes.com>wrote:
>>>
>>>> You say "use the reverse relation manager in LlamaHerd to build up your
>>>> annotation," but that answer the question.
>>>>
>>>> How can I sort LlamaHerd objects by the DOB of their largest llama?
>>>>
>>>>
>>>> On Tue, Apr 1, 2014 at 6:13 PM, Justin Holmes 
>>>> <jus...@justinholmes.com>wrote:
>>>>
>>>>> Yes, absolutely - my bad.  I have updated to SO question.  I meant the
>>>>> models to look like:
>>>>>
>>>>> class LlamaHerd(models.Model):
>>>>> shepherd = ForeignKey(User)
>>>>>
>>>>> class Llama(models.Model):
>>>>> size = FloatField()
>>>>> dob =
>>>>>  FloatField
>>>>> herd = ForeignKey(Herd, related_name="llamas")
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Tue, Apr 1, 2014 at 6:09 PM, Bill Freeman <ke1g...@gmail.com>wrote:
>>>>>
>>>>>> Aren't you missing a ForeignKey relationship to tell which LlamaHerd
>>>>>> a Llama belongs to?
>>>>>>
>>>>>> Then you would use the reverse relation manager in LlamaHerd to build
>>>>>> up your annotation.
>>>>>>
>>>>>>
>>>>>> On Tue, Apr 1, 2014 at 5:52 PM, Justin Holmes <
>>>>>> jus...@justinholmes.com> wrote:
>>>>>>
>>>>>>> I have come across this problem in several Django projects, but only
>>>>>>> just now worked it out in my head enough to make it a cognizable 
>>>>>>> question.
>>>>>>>
>>>>>>> I have also posted it on StackOverflow, here:
>>>>>>> http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item
>>>>>>>
>>>>>>>
>>>>>>> Consider this example:
>>>>>>>
>>>>>>> class LlamaHerd(models.Model):
>>>>>>> shepherd = ForeignKey(User)
>>>>>>>
>>>>>>> class Llama(models.Model):
>>>>>>> size = FloatField()
>>>>>>> dob = FloatField
>>>>>>>
>>>>>>> How can I now make a query to get LlamaHerd objects, sorted by the
>>>>>>> date of birth of their largest

Re: ORM Question

2014-04-02 Thread Justin Holmes
No no, the annotate doesn't work - that's the whole reason for my
question.  See, the annotate doesn't associate instances with the annotated
attribute, it associated results.

(BTW, good looking out - I have once again fixed the SO question :-))


On Wed, Apr 2, 2014 at 10:17 AM, Bill Freeman <ke1g...@gmail.com> wrote:

> 1.  You now have a foreign key to Herd, but you don't have a model by that
> name.  It's called LlamaHerd.
>
> 2.  I was misinterpreting what you wanted (couldn't get past the lack of a
> relationship while reading0.  Once the relationship is fixed, your original
> annotate might work.
>
>
> On Tue, Apr 1, 2014 at 6:20 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>
>> You say "use the reverse relation manager in LlamaHerd to build up your
>> annotation," but that answer the question.
>>
>> How can I sort LlamaHerd objects by the DOB of their largest llama?
>>
>>
>> On Tue, Apr 1, 2014 at 6:13 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>>
>>> Yes, absolutely - my bad.  I have updated to SO question.  I meant the
>>> models to look like:
>>>
>>> class LlamaHerd(models.Model):
>>> shepherd = ForeignKey(User)
>>>
>>> class Llama(models.Model):
>>> size = FloatField()
>>> dob =
>>>  FloatField
>>> herd = ForeignKey(Herd, related_name="llamas")
>>>
>>>
>>>
>>>
>>> On Tue, Apr 1, 2014 at 6:09 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>>>
>>>> Aren't you missing a ForeignKey relationship to tell which LlamaHerd a
>>>> Llama belongs to?
>>>>
>>>> Then you would use the reverse relation manager in LlamaHerd to build
>>>> up your annotation.
>>>>
>>>>
>>>> On Tue, Apr 1, 2014 at 5:52 PM, Justin Holmes 
>>>> <jus...@justinholmes.com>wrote:
>>>>
>>>>> I have come across this problem in several Django projects, but only
>>>>> just now worked it out in my head enough to make it a cognizable question.
>>>>>
>>>>> I have also posted it on StackOverflow, here:
>>>>> http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item
>>>>>
>>>>>
>>>>> Consider this example:
>>>>>
>>>>> class LlamaHerd(models.Model):
>>>>> shepherd = ForeignKey(User)
>>>>>
>>>>> class Llama(models.Model):
>>>>> size = FloatField()
>>>>> dob = FloatField
>>>>>
>>>>> How can I now make a query to get LlamaHerd objects, sorted by the
>>>>> date of birth of their largest llama?
>>>>>
>>>>> It almost feels like I might be able to use annotate:
>>>>>
>>>>> LlamaHerd.annotate(largest_llama=Max('llama__size')).order_by('largest_llama__dob')
>>>>>
>>>>> ...but the annotate here creates fields with float values, not with
>>>>> the model instances.
>>>>>
>>>>>
>>>>> --
>>>>> Justin Holmes
>>>>> Chief Chocobo Breeder, slashRoot
>>>>>
>>>>> slashRoot: Coffee House and Tech Dojo
>>>>> New Paltz, NY 12561
>>>>> 845.633.8330
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django users" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to django-users+unsubscr...@googlegroups.com.
>>>>> To post to this group, send email to django-users@googlegroups.com.
>>>>> Visit this group at http://groups.google.com/group/django-users.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com?utm_medium=email_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To unsubscribe from this group and stop rec

Re: ORM Question

2014-04-01 Thread Justin Holmes
You say "use the reverse relation manager in LlamaHerd to build up your
annotation," but that answer the question.

How can I sort LlamaHerd objects by the DOB of their largest llama?


On Tue, Apr 1, 2014 at 6:13 PM, Justin Holmes <jus...@justinholmes.com>wrote:

> Yes, absolutely - my bad.  I have updated to SO question.  I meant the
> models to look like:
>
> class LlamaHerd(models.Model):
> shepherd = ForeignKey(User)
>
> class Llama(models.Model):
> size = FloatField()
> dob =
>  FloatField
> herd = ForeignKey(Herd, related_name="llamas")
>
>
>
>
> On Tue, Apr 1, 2014 at 6:09 PM, Bill Freeman <ke1g...@gmail.com> wrote:
>
>> Aren't you missing a ForeignKey relationship to tell which LlamaHerd a
>> Llama belongs to?
>>
>> Then you would use the reverse relation manager in LlamaHerd to build up
>> your annotation.
>>
>>
>> On Tue, Apr 1, 2014 at 5:52 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>>
>>> I have come across this problem in several Django projects, but only
>>> just now worked it out in my head enough to make it a cognizable question.
>>>
>>> I have also posted it on StackOverflow, here:
>>> http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item
>>>
>>>
>>> Consider this example:
>>>
>>> class LlamaHerd(models.Model):
>>> shepherd = ForeignKey(User)
>>>
>>> class Llama(models.Model):
>>> size = FloatField()
>>> dob = FloatField
>>>
>>> How can I now make a query to get LlamaHerd objects, sorted by the date
>>> of birth of their largest llama?
>>>
>>> It almost feels like I might be able to use annotate:
>>>
>>> LlamaHerd.annotate(largest_llama=Max('llama__size')).order_by('largest_llama__dob')
>>>
>>> ...but the annotate here creates fields with float values, not with the
>>> model instances.
>>>
>>>
>>> --
>>> Justin Holmes
>>> Chief Chocobo Breeder, slashRoot
>>>
>>> slashRoot: Coffee House and Tech Dojo
>>> New Paltz, NY 12561
>>> 845.633.8330
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAB%2BAj0srKNzRs%3DzbsPm%2BobxLNFCcjRccGSVeYykF1PSnJc-ydQ%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAB%2BAj0srKNzRs%3DzbsPm%2BobxLNFCcjRccGSVeYykF1PSnJc-ydQ%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Justin Holmes
> Chief Chocobo Breeder, slashRoot
>
> slashRoot: Coffee House and Tech Dojo
> New Paltz, NY 12561
> 845.633.8330
>



-- 
Justin Holmes
Chief Chocobo Breeder, slashRoot

slashRoot: Coffee House and Tech Dojo
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGywB4V3zpbqr7v1kcvOi8%2BoqLPm0nr18dGStaedys494%2BOag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ORM Question

2014-04-01 Thread Justin Holmes
Yes, absolutely - my bad.  I have updated to SO question.  I meant the
models to look like:

class LlamaHerd(models.Model):
shepherd = ForeignKey(User)

class Llama(models.Model):
size = FloatField()
dob = FloatField
herd = ForeignKey(Herd, related_name="llamas")




On Tue, Apr 1, 2014 at 6:09 PM, Bill Freeman <ke1g...@gmail.com> wrote:

> Aren't you missing a ForeignKey relationship to tell which LlamaHerd a
> Llama belongs to?
>
> Then you would use the reverse relation manager in LlamaHerd to build up
> your annotation.
>
>
> On Tue, Apr 1, 2014 at 5:52 PM, Justin Holmes <jus...@justinholmes.com>wrote:
>
>> I have come across this problem in several Django projects, but only just
>> now worked it out in my head enough to make it a cognizable question.
>>
>> I have also posted it on StackOverflow, here:
>> http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item
>>
>>
>> Consider this example:
>>
>> class LlamaHerd(models.Model):
>> shepherd = ForeignKey(User)
>>
>> class Llama(models.Model):
>> size = FloatField()
>> dob = FloatField
>>
>> How can I now make a query to get LlamaHerd objects, sorted by the date
>> of birth of their largest llama?
>>
>> It almost feels like I might be able to use annotate:
>>
>> LlamaHerd.annotate(largest_llama=Max('llama__size')).order_by('largest_llama__dob')
>>
>> ...but the annotate here creates fields with float values, not with the
>> model instances.
>>
>>
>> --
>> Justin Holmes
>> Chief Chocobo Breeder, slashRoot
>>
>> slashRoot: Coffee House and Tech Dojo
>> New Paltz, NY 12561
>> 845.633.8330
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAB%2BAj0srKNzRs%3DzbsPm%2BobxLNFCcjRccGSVeYykF1PSnJc-ydQ%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAB%2BAj0srKNzRs%3DzbsPm%2BobxLNFCcjRccGSVeYykF1PSnJc-ydQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Justin Holmes
Chief Chocobo Breeder, slashRoot

slashRoot: Coffee House and Tech Dojo
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGywB6r1wu0hsTVH8JdpBMSWDLBWsH87%2B1H_vZ%2BDqr0Eu%2BSXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


ORM Question

2014-04-01 Thread Justin Holmes
I have come across this problem in several Django projects, but only just
now worked it out in my head enough to make it a cognizable question.

I have also posted it on StackOverflow, here:
http://stackoverflow.com/questions/22797497/using-the-django-orm-to-order-by-a-value-in-a-distinct-related-item


Consider this example:

class LlamaHerd(models.Model):
shepherd = ForeignKey(User)

class Llama(models.Model):
size = FloatField()
dob = FloatField

How can I now make a query to get LlamaHerd objects, sorted by the date of
birth of their largest llama?

It almost feels like I might be able to use annotate:

LlamaHerd.annotate(largest_llama=Max('llama__size')).order_by('largest_llama__dob')

...but the annotate here creates fields with float values, not with the
model instances.


-- 
Justin Holmes
Chief Chocobo Breeder, slashRoot

slashRoot: Coffee House and Tech Dojo
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGywB6gkBvhFs%2BP2PrtDah24VDCko8QK-1UCnSGugz_ts1v8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Http404 and process_exception

2012-03-30 Thread Justin Holmes
Russell,

Yeah, I see the inconsistency there, and my first thought was that
this is a bit backward.  However, the underlying distinction here is
that it's not the 404 (ie, the resource gone missin') that is the
exception but the Http404 object.

It remains straightforward enough for a developer to simply return
HttpResponseNotFound if they don't want their business logic treated
as an exception.

(Maybe this belongs on -dev) I do, however, think that the
get_object_or_404 documentation can be clearer that, as with .get(),
either failing case raises an exception.  Perhaps change the note to:

"As with .get(), an exception is raised unless exactly one object is
found for the given parameters.  A MultipleObjectsReturned exception
will be raised if more than one object is found.  However, unlike
.get(), Http404 is raised if no object is found."

This may not be necessary at all, as the Http404 page makes it clear
that it's an exception.



On Wed, Mar 28, 2012 at 7:22 PM, Russell Keith-Magee
<russ...@keith-magee.com> wrote:
>
>
> On 29/03/2012, at 12:10 AM, Justin Holmes wrote:
>
> > Russell,
> >
> > Thanks for the reply.
> >
> > Two reasons:
> >
> > 1) Up until now, I hadn't encountered a 404 that had triggered this 
> > particular process_exception.  It hadn't occurred to me that since 
> > get_object_or_404 actually raises the Http404 exception that the behavior 
> > was going to be different than, say, a try block whose exception clause 
> > returned HttpResponseNotFound.
> >
> > 2) Once I had encountered this phenomenon, a quick google search led me to 
> > this page from the book:
> >
> > http://www.djangobook.com/en/beta/chapter16/
> >
> > which seemed, at least for a moment, to verify my previous experience.
>
> Yes - that does seem to suggest 404's don't trigger exception middleware. 
> However, I've checked the code back to the magic-removal merge (in 2005) [1], 
> and I can't see any evidence that 404's have ever been a special case.
>
> [1] 
> https://code.djangoproject.com/browser/django/trunk/django/core/handlers/base.py?rev=2809#L73
>
> The only change to this area that I can see is to make sure that the response 
> raised by the exception middleware is in recent times has been a modification 
> that means that if the exception middleware returns a response, that response 
> goes through the response middleware; back in the days of magic-removal, it 
> would be returned verbatim.
>
> > I think though that I simply hadn't raised Http404 since implementing this 
> > middleware.  It makes perfect sense that it behaves the way it does.
>
> Yes and no; yes, in that it's an exception; no, in that it's an interesting 
> inconsistency that 404s are (or can be) handled as exceptions, but no other 
> status code is handled as an exception.
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>



--
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Http404 and process_exception

2012-03-28 Thread Justin Holmes
Russell,

Thanks for the reply.

Two reasons:

1) Up until now, I hadn't encountered a 404 that had triggered this
particular process_exception.  It hadn't occurred to me that since
get_object_or_404 actually raises the Http404 exception that the behavior
was going to be different than, say, a try block whose exception clause
returned HttpResponseNotFound.

2) Once I had encountered this phenomenon, a quick google search led me to
this page from the book:

http://www.djangobook.com/en/beta/chapter16/

which seemed, at least for a moment, to verify my previous experience.

I think though that I simply hadn't raised Http404 since implementing this
middleware.  It makes perfect sense that it behaves the way it does.



On Tue, Mar 27, 2012 at 11:29 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

>
> On 28/03/2012, at 6:31 AM, Justin Holmes wrote:
>
> > Heretofore, I had always believed that Http404 did not cause Middleware
> process_exception() to be run.  Am I right in this thinking?
> >
> > I have a get_object_or_404 that, when the object in question isn't
> found, is running process_exception.
>
> Http404 is an exception, so yes, it should cause process_exception() to be
> run.
>
> The test suite for middleware processing might be (slightly) illuminating
> here; it's a bit long winded and gnarly, but it enumerates and validates
> the full path for every possible combination of middleware and response
> type.
>
> Look at regression_tests/middleware_exceptions;
> test_process_exception_middleware_not_found is the test for your specific
> case.
>
> Out of interest -- can you put your finger on why you heretofore thought
> Http404 didn't hit exception middleware? I've done a quick poke through the
> history of the middleware handling code, and I can't see any obvious reason
> why this would have changed (even inadvertently).
>
> Yours,
> Russ Magee %-)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Http404 and process_exception

2012-03-27 Thread Justin Holmes
Heretofore, I had always believed that Http404 did not cause Middleware
process_exception() to be run.  Am I right in this thinking?

I have a get_object_or_404 that, when the object in question isn't found,
is running process_exception.


-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New way to run your Django projects

2012-03-18 Thread Justin Holmes
I feel the need to inject, once again, that the Twisted WSGI container
rocks.

On Sun, Mar 18, 2012 at 12:40 PM, Bolang <boo.l...@gmail.com> wrote:

> Hi Alexander,
> What is the advantage of using gevent-fastcgi instead of simply using
> nginx and maybe with gunicorn?
>
>
>
> On 03/18/2012 12:59 PM, Alexander wrote:
>
>> Hello everybody,
>>
>> I'm working on gevent coroutine based  library FastCGI server
>> implementation and I's ready for testing. It most likely contains lots
>> of bugs and it would be great if you help to catch some of them.
>>
>> Just install gevent-fastcgi package:
>>
>> $ easy_install gevent-fastcgi
>>
>> Then include gevent_fastcgi.adapters.django into INSTALLED_APPS list
>> of your settings.py. Then run:
>>
>> $ python manage.py run_gevent_fastcgi host:port
>>
>> Run "python manage.py run_gevent_fastcgi --help" to find out more
>> about run_gevent_fastcgi command.
>>
>> Alex
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@**
> googlegroups.com <django-users%2bunsubscr...@googlegroups.com>.
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
>
>


-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-deeper

2011-12-28 Thread Justin Holmes
In response to the recent discussion of SOPA on the django-dev list
(and to the recurring phenomenon of having no clearly defined space to
congregate to discuss "deeper" issues), I have started a new google
group, django-deeper.

As a relative newcomer to the django community, I have been
overwhelmed by the awesome vibes.  Djangocon 2011 was one of the best
conferences (probably top 5 even) that I've ever been to.

>From the very first peek at the project, it's clear that django has a
much sharper focus on community building than is typical for a
software project.  The emphasis and effort on documentation, for
example, sends a strong signal that "this is not just a piece of
software, it's a group of passionate people."  The mature and
open-minded atmosphere of the django IRC presence also suggests this.

As the django community expands in breadth and in depth, we need a way
to ensure that our underlying aspirations - expressed sometimes in the
form of python code but sometimes as political, philosophical, or
psychological prose, are likewise cultivated.  My hope is that
django-deeper will provide a forum for those of us who welcome growth
in this direction.

http://groups.google.com/group/django-deeper

-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



contrib.auth tests - not respecting TEMPLATE_DIRS?

2011-10-10 Thread Justin Holmes
I'm running the contrib.auth tests in a situation where I have a
signal hook on login which uses a template.

Strangely, when I run the full test suite, I find that in state, the
global template dirs contains only
"/django/contrib/auth/tests/templates" and not the directory (or -ies)
specified in the TEMPLATE_DIRS setting.

The same code is executed just fine in production.

-- 
Justin Holmes

Head Instructor, SlashRoot Collective
SlashRoot: Coffee House and Tech Dojo
60 Main Street
New Paltz, NY 12561
845.633.8330

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



test_invalid_key failing

2011-10-04 Thread Justin Holmes
I am having a problem with contrib.sessions.tests.test_valid_key (line
159).  It's a mixin which in the failure case is mixed with
CacheDBSessionTests.

The test raises:

"AttributeError: 'bool' object has no attribute 'get'"

The error is actually raised by session.save() on 164.

Stepping inward reveals that sessions.backends.cached_db (line 18)
sets data thusly:

data = cache.get(self.session_key, None)

QUESTION #1 (maybe more suited for django-dev?): If I step in, I find
that debugging core.cache.backends.locmem.LocMemCache.get(), which is
odd since the TestCase is CacheDBSessionTests.  Why is it testing
LocMemCache and not core.cache.backends.db.DatabaseCache?

In this case, self.session_key is 1, and indeed the cache has a
pickled "True" for the key 1.  In fact, during the course of debugging
core.cache.backends.locmem.LocMemCache.get(), we have found that in
every case during which the testrunner hits this method, 1 is a key
for pickled True.

QUESTION #2: Why is the key 1 set to a pickled True?

In this case, that True ends up being returned in
contrib.sessions.backends.base.SessionBase.get() (line 64).

Thus, of course an error is raised.  We are unable to understand why
the key 1 is set to pickled True in the locmem backend.

NOW THE STRANGE PART:

Iff we step in with a debugger and wait for > 3 seconds or so, the
method no longer returns True and instead returns an empty dict.  In
this case, the test passes!

We are baffled.  Is this possibly an underlying race condition or
hotel room scenario (http://stackoverflow.com/questions/6441218)?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.