Re: Inconsistent behavior when deleting related records for a model instance

2011-08-25 Thread Chad Lyon
That is exactly what I want.

Thanks

On Aug 18, 5:38 pm, Anssi Kääriäinen  wrote:
> On Aug 18, 11:55 pm,ChadLyon wrote:
>
>
>
>
>
>
>
>
>
> > I have a problem with the way django deletes related objects. I have
> > overridden the delete() method for my app so that I may do some
> > "specialness" when something is deleted (if you must know I log the
> > full deleted record to another mysql db). I have done this abstractly
> > for all models in my app.
>
> > The issue is when deleting related records for a model instance django
> > eventually calls the following method on django.db.models.Model:
>
> > def delete(self, using=None):
> >         using = using or router.db_for_write(self.__class__,
> > instance=self)
> >         assert self._get_pk_val() is not None, "%s object can't be
> > deleted because its %s attribute is set to None." %
> > (self._meta.object_name, self._meta.pk.attname)
>
> >         # Find all the objects than need to be deleted.
> >         seen_objs = CollectedObjects()
> >         self._collect_sub_objects(seen_objs)
>
> >         # Actually delete the objects.
> >         delete_objects(seen_objs, using)
>
> > There is a problem with this method in that it calls
> > delete_objects(...) which descends into all children and deletes them
> > by constructing SQL (FWIU) to perform the delete. This circumvents the
> > delete(self, using=None) method on the Child objects. Meaning if I
> > have overridden delete() then my overridden routine doesn't get called
> > for my Children only for the Parent. This seems to be inconsistent
> > behavior. Don't you think delete() should be called on all seen_objs?
>
> I think the post_delete signal is what you want. The model.delete() is
> meant for single object deletion. Bulk delete doesn't call it. This is
> documented 
> athttps://docs.djangoproject.com/en/dev/topics/db/models/#overriding-mo
> I know that can be a little confusing, but there is a good reason for
> this. If you are deleting thousands of objects, you really, really
> don't want to delete them one at a time.

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



Re: What is Django?

2011-08-25 Thread Justin Holmes
I've put some language down to get us started:

https://docs.google.com/document/d/15iJXXKs989cIIvhToa7ttYgToPSyzJN9KL9CCkxka1o/edit?pli=1&hl=en_US



On Wed, Aug 24, 2011 at 6:31 AM, Cal Leeming [Simplicity Media Ltd]
 wrote:
>
>
> On Wed, Aug 24, 2011 at 11:04 AM, Tom Evans 
> wrote:I'll
>>
>> On Tue, Aug 23, 2011 at 6:34 PM, Cal Leeming [Simplicity Media Ltd]
>>  wrote:
>> >
>> > +1 on this idea :)
>>
>> I don't think Russell is looking for votes on whether to do it, he's
>> looking for someone to actually do it :)
>
> Lol, yeah I guessed that already. *adds into todo list*
>
>>
>> Cheers
>>
>> Tom
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers" group.
>> To post to this group, send email to django-developers@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-developers+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-developers?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To post to this group, send email to django-developers@googlegroups.com.
> To unsubscribe from this group, send email to
> django-developers+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-developers?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 developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Re: What is Django?

2011-08-25 Thread Justin Holmes
Sorry, here's the appropriate link:

https://docs.google.com/document/pub?id=15iJXXKs989cIIvhToa7ttYgToPSyzJN9KL9CCkxka1o

On Thu, Aug 25, 2011 at 2:50 PM, Justin Holmes  wrote:
> I've put some language down to get us started:
>
> https://docs.google.com/document/d/15iJXXKs989cIIvhToa7ttYgToPSyzJN9KL9CCkxka1o/edit?pli=1&hl=en_US
>
>
>
> On Wed, Aug 24, 2011 at 6:31 AM, Cal Leeming [Simplicity Media Ltd]
>  wrote:
>>
>>
>> On Wed, Aug 24, 2011 at 11:04 AM, Tom Evans 
>> wrote:I'll
>>>
>>> On Tue, Aug 23, 2011 at 6:34 PM, Cal Leeming [Simplicity Media Ltd]
>>>  wrote:
>>> >
>>> > +1 on this idea :)
>>>
>>> I don't think Russell is looking for votes on whether to do it, he's
>>> looking for someone to actually do it :)
>>
>> Lol, yeah I guessed that already. *adds into todo list*
>>
>>>
>>> Cheers
>>>
>>> Tom
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django developers" group.
>>> To post to this group, send email to django-developers@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-developers+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-developers?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers" group.
>> To post to this group, send email to django-developers@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-developers+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-developers?hl=en.
>>
>
>
>
> --
> Justin Holmes
>
> Head Instructor, SlashRoot Collective
> SlashRoot: Coffee House and Tech Dojo
> 60 Main Street
> New Paltz, NY 12561
> 845.633.8330
>



-- 
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 developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



New feature: Customizable get_queryset() for django.contrib.comments comment_list template tags

2011-08-25 Thread Jim D.
I understand that we're supposed to suggest new features here on django-dev 
first instead of opening a ticket, so here goes:

Presently in django.contrib.comments, there are two template tags that 
output a list of comments:

{% render_comment_list for [object] %}
{% get_comment_list for [object] as [varname] %}

There is a method on BaseCommentNode called get_query_set() that composes 
the queryset for these tags and returns it.

At present, there is no way to customize the queryset. I propose that we 
provided a mechanism allowing a custom comment app to define its own 
queryset for the list of comments that can be retrieved.

What's wrong with the present way?

* You can't use a custom manager. It assumes you want to use the manager 
defined on the objects attribute.
* It assumes you want at all times to apply the moderation fields if they 
exist.
* It doesn't allow you to define custom moderation filters, e.g. if you had 
a custom field with a score on your comment model and you didn't want to 
show comments below a threshold, or if you wanted to exclude comments that 
had been flagged as spam.

Is there a workaround?

You can subclass BaseCommentNode and override its get_query_set() method, 
and then implement your own template tags. Basically your just having to do 
a lot of copying and pasting to get what you need. If there is a more 
obvious or easy way of defining this that I have overlooked, do let me know.

Proposed feature

Two possibilities:

1. Define a new function as part of the present Custom comment app API. Call 
it something like get_comment_list_query_set(). Implement the present logic 
from the get_query_set() method there, and allow it to be overridden in the 
__init__.py file of the custom comment app.

2. Extend the template tag to allow a custom queryset to be passed to it. 
Something along the lines of:

{% render_comment_list for [object] with [custom_comment_list] %}
{% get_comment_list for [object] as [varname] with [custom_comment_list] %}

Neither of these two are mutually exclusive (i.e. they could both be 
implemented). I would think the second provides the most flexibility, but at 
the same time I think the first is in strong alignment behind the present 
custom comment app API philosophy.

Please let me know your thoughts/concerns/criticisms/etc. I'd be happy to 
work on a patch if there is consensus that it's a worthwhile idea. Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/9-6LEMDkYqoJ.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Re: What is Django?

2011-08-25 Thread Mikhail Korobov
Hi all,

One thing I always like about django is how the community is peaceful and 
how the django itself is peaceful and engineer-minded, not marketing-minded: 
I can't imagine whydjangoisbetterthanx.com website bashing zend, rails, 
pyramid and flask, for example. That's why the idea of putting something 
like "Django has a number of distinct, measurable advantages over similar 
web frameworks." to the djangoproject.org front page doesn't seems too 
attractive for me. 

There are many big and well-known sites built with django and I think 
mentioning these sites and providing testimonials from people working on 
these sites can be better advertisement. I respect the sites listed on 
djangoproject.org page very much but the selection is 
quite opinionated towards newspaper web sites, maybe disqus, mozilla addons, 
opera portal, yandex projects, meebo, etc. (not sure about the exact 
list) can build more trust in framework for newcomers. These are not typical 
django websites but I think they will impress people more. 

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



Re: What is Django?

2011-08-25 Thread Jacob Kaplan-Moss
On Thu, Aug 25, 2011 at 4:06 PM, Mikhail Korobov  wrote:
> One thing I always like about django is how the community is peaceful and
> how the django itself is peaceful and engineer-minded, not marketing-minded:
> I can't imagine whydjangoisbetterthanx.com website bashing zend, rails,
> pyramid and flask, for example. That's why the idea of putting something
> like "Django has a number of distinct, measurable advantages over similar
> web frameworks." to the djangoproject.org front page doesn't seems too
> attractive for me.

Well said. Language like that goes on anything officially-Django only
over my dead body.

I'm appreciating the effort y'all are putting onto a good high-level
description of Django, but let's stay FAR away from anything that's
derogatory, OK? If Django's as good as we say it is we shouldn't have
to put down other tools to promote ours.

Just so you know, there's an effort underway right now within the DSF
to refresh Django's web presence, so if you come up with something
good here there's a good chance we'll actually end up using it. So --
no pressure :)

Jacob

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



Re: What is Django?

2011-08-25 Thread Amirouche Boubekki
2011/8/25 Mikhail Korobov 

> Hi all,


Hi Mikhail,


> One thing I always like about django is how the community is peaceful and
> how the django itself is peaceful and engineer-minded,
>

then


> not marketing-minded:
>

granted. It's the case of many FOSS projects.


> There are many big and well-known sites built with django and I think
> mentioning these sites and providing testimonials from people working on
> these sites can be better advertisement.
>

Yes and no. Advertising on big websites & applications powered by django
would be a plus but it can be misleading. I think anybody could agree that
this same applications could have been done in PHP or Flask with the same
success (see Facebook ?).
Engineers and people that take decisions in general want to know if it gets
things done, but also how does it compare to other solutions.
Comparing on features would be more engineer-minded that «How do you feel
about Django». Engineering is not about feelings, it's a complex choice that
weights pros & cons which can be technical but also social and commercial...


In javascript world is common to compare frameworks based on speed, size, we
could extend this to common problems regarding website building like cache
management, authentication, authorization, L10N, I18N, db support,
professional support, community support and the like... and even do code to
code comparison if it makes sens.

Taking the time to draw an «état de l'art» of things get done today even if,
Django doesn't succeed in every aspect can only benefit Django project and
the community.

Regards,

Amirouche

PS: I will be happy to help to draw a comparison with Flask if we setup a
list of what to compare :)

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



Re: What is Django?

2011-08-25 Thread Julien Phalip
On 26 August 2011 07:55, Amirouche Boubekki wrote:

> 2011/8/25 Mikhail Korobov 
>
>
>> There are many big and well-known sites built with django and I think
>> mentioning these sites and providing testimonials from people working on
>> these sites can be better advertisement.
>>
>
> Yes and no. Advertising on big websites & applications powered by django
> would be a plus but it can be misleading. I think anybody could agree that
> this same applications could have been done in PHP or Flask with the same
> success (see Facebook ?).
>

While there are successful and large websites out there built with any
technology under the sun, I believe it is important to show that you *can*
use Django to build such sites. Nobody will trust that you are webscale™ until
you can show some concrete evidence of it :-)

Seeing that there are successful and large websites built with Django
certainly isn't enough to convince someone but it isn't just a plus either.
It is rather the *bare minimum* one needs to be reassured that they're not
wasting their time learning this new framework.


> Engineers and people that take decisions in general want to know if it gets
> things done, but also how does it compare to other solutions.
> Comparing on features would be more engineer-minded that «How do you feel
> about Django». Engineering is not about feelings, it's a complex choice that
> weights pros & cons which can be technical but also social and commercial...
>
>
> In javascript world is common to compare frameworks based on speed, size,
> we could extend this to common problems regarding website building like
> cache management, authentication, authorization, L10N, I18N, db support,
> professional support, community support and the like... and even do code to
> code comparison if it makes sens.
>

Comparisons are important but I'd rather encourage third parties to write
them up. Comparisons can really only be trusted from people who have
extended experience in all the compared frameworks and who do not appear
biased towards one or another. One should always be cautious with
websites/frameworks/products/whatever boasting that they are so much more
awesome than the others :-)

Julien

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



Re: What is Django?

2011-08-25 Thread Justin Holmes
Mikhail, et. al.,

I also love the vibe of the django community.  I did not mean, when
writing that line, to put down other communities; I was glad when I
found Django to be greeted by language that did not put down other
frameworks or their philosophies.   Nevertheless, I think that the
language in question is an empirically testable and true statement.
The inverse is also true: Some frameworks, for some use cases, have
distinct and measurable advantages over Django.

I'm not defending the language as it's written - by all means let's
change it.  However, I do think that it's worth mentioning, somehow,
that Django excels in certain areas and that those areas are largely
the result of sensible underlying philosophies.  I think that this
point answers a front-running question in the mind of project managers
who are considering framework adoption.






On Thu, Aug 25, 2011 at 6:30 PM, Julien Phalip  wrote:
> On 26 August 2011 07:55, Amirouche Boubekki 
> wrote:
>>
>> 2011/8/25 Mikhail Korobov 
>>
>>>
>>> There are many big and well-known sites built with django and I think
>>> mentioning these sites and providing testimonials from people working on
>>> these sites can be better advertisement.
>>
>> Yes and no. Advertising on big websites & applications powered by django
>> would be a plus but it can be misleading. I think anybody could agree that
>> this same applications could have been done in PHP or Flask with the same
>> success (see Facebook ?).
>
> While there are successful and large websites out there built with any
> technology under the sun, I believe it is important to show that you *can*
> use Django to build such sites. Nobody will trust that you are
> webscale™ until you can show some concrete evidence of it :-)
> Seeing that there are successful and large websites built with Django
> certainly isn't enough to convince someone but it isn't just a plus either.
> It is rather the *bare minimum* one needs to be reassured that they're not
> wasting their time learning this new framework.
>
>>
>> Engineers and people that take decisions in general want to know if it
>> gets things done, but also how does it compare to other solutions.
>> Comparing on features would be more engineer-minded that «How do you feel
>> about Django». Engineering is not about feelings, it's a complex choice that
>> weights pros & cons which can be technical but also social and commercial...
>>
>> In javascript world is common to compare frameworks based on speed, size,
>> we could extend this to common problems regarding website building like
>> cache management, authentication, authorization, L10N, I18N, db support,
>> professional support, community support and the like... and even do code to
>> code comparison if it makes sens.
>
> Comparisons are important but I'd rather encourage third parties to write
> them up. Comparisons can really only be trusted from people who have
> extended experience in all the compared frameworks and who do not appear
> biased towards one or another. One should always be cautious with
> websites/frameworks/products/whatever boasting that they are so much more
> awesome than the others :-)
> Julien
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To post to this group, send email to django-developers@googlegroups.com.
> To unsubscribe from this group, send email to
> django-developers+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-developers?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 developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.



Re: What is Django?

2011-08-25 Thread kenneth gonsalves
On Thu, 2011-08-25 at 14:51 -0400, Justin Holmes wrote:
> Sorry, here's the appropriate link:
> 
> https://docs.google.com/document/pub?id=15iJXXKs989cIIvhToa7ttYgToPSyzJN9KL9CCkxka1o
> 
> 

why not the wike?
-- 
regards
Kenneth Gonsalves

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