Fixed a caching issue with TypedAttributes.
This commit is contained in:
parent
82a10903d1
commit
d4c97d7df8
3 changed files with 18 additions and 5 deletions
|
|
@ -121,6 +121,8 @@ class ObjectManager(TypedObjectManager):
|
||||||
if location:
|
if location:
|
||||||
lstring = ", db_obj__db_location=location"
|
lstring = ", db_obj__db_location=location"
|
||||||
attrs = eval("ObjAttribute.objects.filter(db_key=attribute_name%s)" % lstring)
|
attrs = eval("ObjAttribute.objects.filter(db_key=attribute_name%s)" % lstring)
|
||||||
|
# since attribute values are pickled in database, we cannot search directly, but
|
||||||
|
# must loop through the results. .
|
||||||
if exact:
|
if exact:
|
||||||
return [attr.obj for attr in attrs if attribute_value == attr.value]
|
return [attr.obj for attr in attrs if attribute_value == attr.value]
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,17 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
||||||
return None
|
return None
|
||||||
return dbref
|
return dbref
|
||||||
|
|
||||||
|
@returns_typeclass_list
|
||||||
|
def get_with_attr(self, attribute_name, attribute_value=None):
|
||||||
|
"""
|
||||||
|
Returns the typeclassed entity depending on having a given attribute.
|
||||||
|
|
||||||
|
attribute_name - only entities with an attribute of this name will be included in match
|
||||||
|
attribute_value - if != None, only entities with db.attribute_name=attribute_value will match.
|
||||||
|
"""
|
||||||
|
self.filter()
|
||||||
|
|
||||||
|
|
||||||
@returns_typeclass
|
@returns_typeclass
|
||||||
def dbref_search(self, dbref):
|
def dbref_search(self, dbref):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -307,24 +307,24 @@ class Attribute(SharedMemoryModel):
|
||||||
#@property
|
#@property
|
||||||
def obj_get(self):
|
def obj_get(self):
|
||||||
"Getter. Allows for value = self.obj"
|
"Getter. Allows for value = self.obj"
|
||||||
return get_cache(self, "db_obj")
|
return get_cache(self, "obj")
|
||||||
#@obj.setter
|
#@obj.setter
|
||||||
def obj_set(self, value):
|
def obj_set(self, value):
|
||||||
"Setter. Allows for self.obj = value"
|
"Setter. Allows for self.obj = value"
|
||||||
set_cache(self, "db_obj", value)
|
set_cache(self, "obj", value)
|
||||||
#@obj.deleter
|
#@obj.deleter
|
||||||
def obj_del(self):
|
def obj_del(self):
|
||||||
"Deleter. Allows for del self.obj"
|
"Deleter. Allows for del self.obj"
|
||||||
self.db_obj = None
|
self.db_obj = None
|
||||||
self.save()
|
self.save()
|
||||||
del_cache(self, "db_obj")
|
del_cache(self, "obj")
|
||||||
obj = property(obj_get, obj_set, obj_del)
|
obj = property(obj_get, obj_set, obj_del)
|
||||||
|
|
||||||
# date_created property (wraps db_date_created)
|
# date_created property (wraps db_date_created)
|
||||||
#@property
|
#@property
|
||||||
def date_created_get(self):
|
def date_created_get(self):
|
||||||
"Getter. Allows for value = self.date_created"
|
"Getter. Allows for value = self.date_created"
|
||||||
return get_cache(self, "db_date_created")
|
return get_cache(self, "date_created")
|
||||||
#@date_created.setter
|
#@date_created.setter
|
||||||
def date_created_set(self, value):
|
def date_created_set(self, value):
|
||||||
"Setter. Allows for self.date_created = value"
|
"Setter. Allows for self.date_created = value"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue