Re: [Django] #9676: Explicit default managers

2009-03-13 Thread Django
#9676: Explicit default managers
---+
  Reporter:  mrts  | Owner:  mtredinnick
Status:  assigned  | Milestone: 
 Component:  Database layer (models, ORM)  |   Version:  1.0
Resolution:|  Keywords: 
 Stage:  Design decision needed| Has_patch:  0  
Needs_docs:  1 |   Needs_tests:  0  
Needs_better_patch:  0 |  
---+
Changes (by mtredinnick):

  * owner:  nobody => mtredinnick
  * status:  new => assigned

Comment:

 Run out of time today. I'll commit this change tomorrow; I've got it done
 and ready to go.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9676: Explicit default managers

2009-03-13 Thread Django
#9676: Explicit default managers
---+
  Reporter:  mrts  | Owner:  nobody
Status:  new   | Milestone:
 Component:  Database layer (models, ORM)  |   Version:  1.0   
Resolution:|  Keywords:
 Stage:  Design decision needed| Has_patch:  0 
Needs_docs:  1 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Comment (by mtredinnick):

 I'm not going to worry about whether or not to make `_default_manager`
 public here, since that isn't a well defined problem at the moment, so a
 "fix" isn't going to clearly correct or incorrect (working out whether
 access to that parameter is part of the problem). Normally, if you're
 referring to some other model you either know the model you're referring
 to, so can use the right manager, or it's a relation, in which case the
 manager choice is automatic. It's only real edge-cases that need to
 understand the concept of a default manager and won't know it's name (such
 as the admin) and they are a corner case in the application space. I've
 moved that to #10499 and leaving this ticket as being about interleaving
 new default managers.

 The other problem is already possible to solve using class inheritance
 (mixins, since it's mixing in a new default manager to the default
 hierarchy). No new feature is required there. I'm about to commit some
 documentation to explain that pattern explicitly in the documentation.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9676: Explicit default managers

2009-02-26 Thread Django
#9676: Explicit default managers
---+
  Reporter:  mrts  | Owner:  nobody
Status:  new   | Milestone:
 Component:  Database layer (models, ORM)  |   Version:  1.0   
Resolution:|  Keywords:
 Stage:  Design decision needed| Has_patch:  0 
Needs_docs:  1 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by jacob):

  * stage:  Unreviewed => Design decision needed

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9676: Explicit default managers

2008-12-15 Thread Django
#9676: Explicit default managers
---+
  Reporter:  mrts  | Owner:  nobody
Status:  new   | Milestone:
 Component:  Database layer (models, ORM)  |   Version:  1.0   
Resolution:|  Keywords:
 Stage:  Unreviewed| Has_patch:  0 
Needs_docs:  1 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Comment (by mrts):

 Perhaps it is better to just make `objects` the (overrideable) default
 manager as suggested in http://groups.google.com/group/django-
 developers/browse_thread/thread/480fe23f12e55cf7 . I.e. the concept needs
 a little thought, care and love.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #9676: Explicit default managers

2008-11-24 Thread Django
#9676: Explicit default managers
---+
  Reporter:  mrts  | Owner:  nobody
Status:  new   | Milestone:
 Component:  Database layer (models, ORM)  |   Version:  1.0   
Resolution:|  Keywords:
 Stage:  Unreviewed| Has_patch:  0 
Needs_docs:  1 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by anonymous):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 1

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #9676: Explicit default managers

2008-11-24 Thread Django
#9676: Explicit default managers
--+-
 Reporter:  mrts  |   Owner:  nobody
   Status:  new   |   Milestone:
Component:  Database layer (models, ORM)  | Version:  1.0   
 Keywords:|   Stage:  Unreviewed
Has_patch:  0 |  
--+-
 Currently, "the first manager declared is the default manager".

 However, given the following hierarchy:

 {{{
 class PublishedObjectManager(models.Manager):
 def get_query_set(self):
 return super(PublishedObjectManager, self).get_query_set()\
 .filter(is_published=True)

 class PublicationBase(models.Model):
 ...
 objects = models.Manager()
 published_objects = PublishedObjectManager()

 class Meta:
 abstract = True

 class ToplevelPageManager(PublishedObjectManager):
 def get_query_set(self):
 return super(ToplevelPageManager, self).get_query_set()\
 .filter(parent=None)

 class PageBase(PublicationBase):
 ...
 toplevel_pages = ToplevelPageManager()

 class Meta:
 abstract = True
 }}}

 all classes inheriting from `PageBase` get `toplevel_pages` as their
 default manager.
 To make `objects` default, repetition is necessary:

 {{{
 class PageBase(PublicationBase):
 ...
 objects = models.Manager()
 toplevel_pages = ToplevelPageManager()

 class Meta:
 abstract = True
 }}}

 only to specify the default manager. A way to explicitly say
 "this is the default manager that should be honoured throughout the
 inheritance hierarchy" would be appropriate. Also, the `_` in front of
 `_default_manager` implies that it is an implementation detail, neither is
 accessing default managers documented. But all reusable app
 writers should really use `model._default_manager` instead of
 `model.objects` for any foreign models they must handle.

 Generally, there should be an explicit, documented way to set and get
 the default manager.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---