Some errors in the proxy setting.
This commit is contained in:
parent
236c0d17d3
commit
3adeade69a
2 changed files with 5 additions and 14 deletions
|
|
@ -51,6 +51,7 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
Overload the standard get. This will limit itself to only
|
Overload the standard get. This will limit itself to only
|
||||||
return the current typeclass.
|
return the current typeclass.
|
||||||
"""
|
"""
|
||||||
|
print self.model
|
||||||
kwargs.update({"db_typeclass_path":self.model.path})
|
kwargs.update({"db_typeclass_path":self.model.path})
|
||||||
return super(TypedObjectManager, self).get(**kwargs)
|
return super(TypedObjectManager, self).get(**kwargs)
|
||||||
|
|
||||||
|
|
@ -68,7 +69,7 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
"""
|
"""
|
||||||
return super(TypedObjectManager, self).all(**kwargs).filter(db_typeclass_path=self.model.path)
|
return super(TypedObjectManager, self).all(**kwargs).filter(db_typeclass_path=self.model.path)
|
||||||
|
|
||||||
def get_inherit(self, **kwargs):
|
def get_family(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
Variation of get that not only returns the current
|
Variation of get that not only returns the current
|
||||||
typeclass but also all subclasses of that typeclass.
|
typeclass but also all subclasses of that typeclass.
|
||||||
|
|
@ -78,7 +79,7 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
kwargs.update({"db_typeclass_path__in":paths})
|
kwargs.update({"db_typeclass_path__in":paths})
|
||||||
return super(TypedObjectManager, self).get(**kwargs)
|
return super(TypedObjectManager, self).get(**kwargs)
|
||||||
|
|
||||||
def filter_inherit(self, **kwargs):
|
def filter_family(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
Variation of filter that allows results both from typeclass
|
Variation of filter that allows results both from typeclass
|
||||||
and from subclasses of typeclass
|
and from subclasses of typeclass
|
||||||
|
|
@ -89,7 +90,7 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
kwargs.update({"db_typeclass_path__in":paths})
|
kwargs.update({"db_typeclass_path__in":paths})
|
||||||
return super(TypedObjectManager, self).filter(**kwargs)
|
return super(TypedObjectManager, self).filter(**kwargs)
|
||||||
|
|
||||||
def all_inherit(self, **kwargs):
|
def all_family(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
Return all matches, allowing matches from all subclasses of
|
Return all matches, allowing matches from all subclasses of
|
||||||
the typeclass.
|
the typeclass.
|
||||||
|
|
|
||||||
|
|
@ -425,23 +425,13 @@ class SharedMemoryModelBase(ModelBase):
|
||||||
new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
|
new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
|
||||||
return new_class
|
return new_class
|
||||||
|
|
||||||
class TypeclassModelBase(SharedMemoryModelBase):
|
|
||||||
"""
|
|
||||||
Metaclass for typeclasses
|
|
||||||
"""
|
|
||||||
def __init__(cls, *args, **kwargs):
|
def __init__(cls, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
We must define our Typeclasses as proxies. We also store the path
|
This is for the typeclass system.
|
||||||
directly on the class, this is useful for managers.
|
|
||||||
"""
|
"""
|
||||||
super(TypeclassModelBase, cls).__init__(*args, **kwargs)
|
|
||||||
class Meta:
|
|
||||||
proxy = True
|
|
||||||
cls.Meta = Meta
|
|
||||||
cls.typename = cls.__name__
|
cls.typename = cls.__name__
|
||||||
cls.path = "%s.%s" % (cls.__module__, cls.__name__)
|
cls.path = "%s.%s" % (cls.__module__, cls.__name__)
|
||||||
|
|
||||||
|
|
||||||
class SharedMemoryModel(Model):
|
class SharedMemoryModel(Model):
|
||||||
# CL: setting abstract correctly to allow subclasses to inherit the default
|
# CL: setting abstract correctly to allow subclasses to inherit the default
|
||||||
# manager.
|
# manager.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue