Author: floguy
Date: Sun Sep 21 02:12:46 2008
New Revision: 29
Modified:
trunk/things/__init__.py
trunk/things/options.py
Log:
Enabled the ability to use arbitrary QuerySets, which has a use case in
Pinax already where we need to use extra() to do some aggregate calculation.
Modified: trunk/things/__init__.py
==============================================================================
--- trunk/things/__init__.py (original)
+++ trunk/things/__init__.py Sun Sep 21 02:12:46 2008
@@ -1,4 +1,4 @@
-from things.options import ModelThing
+from things.options import ModelThing, BaseThing
from things.sites import ThingSite, site
from things.fields import OrderField
Modified: trunk/things/options.py
==============================================================================
--- trunk/things/options.py (original)
+++ trunk/things/options.py Sun Sep 21 02:12:46 2008
@@ -20,6 +20,7 @@
attrs['fields'] = fields
new_class = super(BaseThingMetaclass, cls).__new__(cls, name,
bases,
attrs)
+ new_class.qs = property(new_class.get_query_set)
return new_class
class BaseThing(object):
@@ -126,6 +127,9 @@
for (name, field) in self.fields.iteritems()
])
return patterns('', *tmp_urls)
+
+ def get_query_set(self):
+ raise NotImplementedError
class ModelThing(BaseThing):
def __init__(self, model):
@@ -133,6 +137,5 @@
self.opts = model._meta
super(ModelThing, self).__init__()
- def _get_qs(self):
- return self.model._default_manager.all()
- qs = property(_get_qs)
\ No newline at end of file
+ def get_query_set(self):
+ return self.model._default_manager.all()
\ No newline at end of file
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---