Removing some more .typeclass properties.

This commit is contained in:
Griatch 2014-12-22 22:04:52 +01:00
parent a93d318121
commit c6c91c7a0b
4 changed files with 19 additions and 114 deletions

View file

@ -121,8 +121,7 @@ class Msg(SharedMemoryModel):
#@property
def __senders_get(self):
"Getter. Allows for value = self.sender"
return [hasattr(o, "typeclass") and o.typeclass or o for o in
list(self.db_sender_players.all()) +
return list(self.db_sender_players.all()) +
list(self.db_sender_objects.all()) +
self.extra_senders]

View file

@ -82,100 +82,6 @@ class HelpEntry(SharedMemoryModel):
verbose_name = "Help Entry"
verbose_name_plural = "Help Entries"
# Wrapper properties to easily set database fields. These are
# @property decorators that allows to access these fields using
# normal python operations (without having to remember to save()
# etc). So e.g. a property 'attr' has a get/set/del decorator
# defined that allows the user to do self.attr = value,
# value = self.attr and del self.attr respectively (where self
# is the object in question).
# key property (wraps db_key)
#@property
#def __key_get(self):
# "Getter. Allows for value = self.key"
# return self.db_key
##@key.setter
#def __key_set(self, value):
# "Setter. Allows for self.key = value"
# self.db_key = value
# self.save()
##@key.deleter
#def __key_del(self):
# "Deleter. Allows for del self.key. Deletes entry."
# self.delete()
#key = property(__key_get, __key_set, __key_del)
## help_category property (wraps db_help_category)
##@property
#def __help_category_get(self):
# "Getter. Allows for value = self.help_category"
# return self.db_help_category
##@help_category.setter
#def __help_category_set(self, value):
# "Setter. Allows for self.help_category = value"
# self.db_help_category = value
# self.save()
##@help_category.deleter
#def __help_category_del(self):
# "Deleter. Allows for del self.help_category"
# self.db_help_category = "General"
# self.save()
#help_category = property(__help_category_get, __help_category_set, __help_category_del)
## entrytext property (wraps db_entrytext)
##@property
#def __entrytext_get(self):
# "Getter. Allows for value = self.entrytext"
# return self.db_entrytext
##@entrytext.setter
#def __entrytext_set(self, value):
# "Setter. Allows for self.entrytext = value"
# self.db_entrytext = value
# self.save()
##@entrytext.deleter
#def __entrytext_del(self):
# "Deleter. Allows for del self.entrytext"
# self.db_entrytext = ""
# self.save()
#entrytext = property(__entrytext_get, __entrytext_set, __entrytext_del)
## permissions property
##@property
#def __permissions_get(self):
# "Getter. Allows for value = self.permissions. Returns a list of permissions."
# return [perm.strip() for perm in self.db_permissions.split(',')]
##@permissions.setter
#def __permissions_set(self, value):
# "Setter. Allows for self.permissions = value. Stores as a comma-separated string."
# if is_iter(value):
# value = ",".join([str(val).strip().lower() for val in value])
# self.db_permissions = value
# self.save()
##@permissions.deleter
#def __permissions_del(self):
# "Deleter. Allows for del self.permissions"
# self.db_permissions = ""
# self.save()
#permissions = property(__permissions_get, __permissions_set, __permissions_del)
# lock_storage property (wraps db_lock_storage)
##@property
#def __lock_storage_get(self):
# "Getter. Allows for value = self.lock_storage"
# return self.db_lock_storage
##@nick.setter
#def __lock_storage_set(self, value):
# """Saves the lock_storagetodate. This is usually not called directly, but through self.lock()"""
# self.db_lock_storage = value
# self.save()
##@nick.deleter
#def __lock_storage_del(self):
# "Deleter is disabled. Use the lockhandler.delete (self.lock.delete) instead"""
# logger.log_errmsg("Lock_Storage (on %s) cannot be deleted. Use obj.lock.delete() instead." % self)
#lock_storage = property(__lock_storage_get, __lock_storage_set, __lock_storage_del)
#
#
# HelpEntry main class methods

View file

@ -510,7 +510,7 @@ class ObjectDB(TypedObject):
raw_string = to_unicode(raw_string)
raw_string = self.nicks.nickreplace(raw_string,
categories=("inputline", "channel"), include_player=True)
return cmdhandler.cmdhandler(_GA(self, "typeclass"), raw_string, callertype="object", sessid=sessid, **kwargs)
return cmdhandler.cmdhandler(self, raw_string, callertype="object", sessid=sessid, **kwargs)
def msg(self, text=None, from_obj=None, sessid=0, **kwargs):
"""
@ -543,11 +543,11 @@ class ObjectDB(TypedObject):
if from_obj:
# call hook
try:
_GA(from_obj, "at_msg_send")(text=text, to_obj=_GA(self, "typeclass"), **kwargs)
from_obj.at_msg_send(text=text, to_obj=self, **kwargs)
except Exception:
logger.log_trace()
try:
if not _GA(_GA(self, "typeclass"), "at_msg_receive")(text=text, **kwargs):
if not self.at_msg_receive(text=text, **kwargs)
# if at_msg_receive returns false, we abort message to this object
return
except Exception:
@ -625,7 +625,7 @@ class ObjectDB(TypedObject):
# Before the move, call eventual pre-commands.
try:
if not self.at_before_move(_GA(destination, "typeclass")):
if not self.at_before_move(destination):
return
except Exception:
logerr(errtxt % "at_before_move()")
@ -646,7 +646,7 @@ class ObjectDB(TypedObject):
# Call hook on source location
try:
source_location.at_object_leave(_GA(self, "typeclass"), _GA(destination, "typeclass"))
source_location.at_object_leave(self, destination)
except Exception:
logerr(errtxt % "at_object_leave()")
#emit_to_obj.msg(errtxt % "at_object_leave()")
@ -656,7 +656,7 @@ class ObjectDB(TypedObject):
if not quiet:
#tell the old room we are leaving
try:
self.announce_move_from(_GA(destination, "typeclass"))
self.announce_move_from(destination)
except Exception:
logerr(errtxt % "at_announce_move()")
#emit_to_obj.msg(errtxt % "at_announce_move()" )
@ -675,7 +675,7 @@ class ObjectDB(TypedObject):
if not quiet:
# Tell the new room we are there.
try:
self.announce_move_to(_GA(source_location, "typeclass"))
self.announce_move_to(source_location)
except Exception:
logerr(errtxt % "announce_move_to()")
#emit_to_obj.msg(errtxt % "announce_move_to()")
@ -685,7 +685,7 @@ class ObjectDB(TypedObject):
# Perform eventual extra commands on the receiving location
# (the object has already arrived at this point)
try:
destination.at_object_receive(_GA(self, "typeclass"), _GA(source_location, "typeclass"))
destination.at_object_receive(self, source_location)
except Exception:
logerr(errtxt % "at_object_receive()")
#emit_to_obj.msg(errtxt % "at_object_receive()")
@ -695,7 +695,7 @@ class ObjectDB(TypedObject):
# Execute eventual extra commands on this object after moving it
# (usually calling 'look')
try:
self.at_after_move(_GA(source_location, "typeclass"))
self.at_after_move(source_location)
except Exception:
logerr(errtxt % "at_after_move")
#emit_to_obj.msg(errtxt % "at_after_move()")

View file

@ -239,7 +239,7 @@ class PlayerDB(TypedObject, AbstractUser):
if from_obj:
# call hook
try:
_GA(from_obj, "at_msg_send")(text=text, to_obj=_GA(self, "typeclass"), **kwargs)
_GA(from_obj, "at_msg_send")(text=text, to_obj=self, **kwargs)
except Exception:
pass
sessions = _MULTISESSION_MODE > 1 and sessid and _GA(self, "get_session")(sessid) or None
@ -318,7 +318,7 @@ class PlayerDB(TypedObject, AbstractUser):
# server kill or similar
if normal_mode:
_GA(obj.typeclass, "at_pre_puppet")(_GA(self, "typeclass"), sessid=sessid)
obj.at_pre_puppet(self, sessid=sessid)
# do the connection
obj.sessid.add(sessid)
obj.player = self
@ -327,7 +327,7 @@ class PlayerDB(TypedObject, AbstractUser):
# validate/start persistent scripts on object
ScriptDB.objects.validate(obj=obj)
if normal_mode:
_GA(obj.typeclass, "at_post_puppet")()
obj.at_post_puppet()
return True
def unpuppet_object(self, sessid):
@ -345,11 +345,11 @@ class PlayerDB(TypedObject, AbstractUser):
if not obj:
return False
# do the disconnect, but only if we are the last session to puppet
_GA(obj.typeclass, "at_pre_unpuppet")()
obj.at_pre_unpuppet()
obj.dbobj.sessid.remove(sessid)
if not obj.dbobj.sessid.count():
del obj.dbobj.player
_GA(obj.typeclass, "at_post_unpuppet")(_GA(self, "typeclass"), sessid=sessid)
obj.at_post_unpuppet(self, sessid=sessid)
session.puppet = None
session.puid = None
return True
@ -377,7 +377,7 @@ class PlayerDB(TypedObject, AbstractUser):
return None
if return_dbobj:
return session.puppet
return session.puppet and session.puppet.typeclass or None
return session.puppet and session.puppet or None
def get_all_puppets(self, return_dbobj=False):
"""
@ -387,7 +387,7 @@ class PlayerDB(TypedObject, AbstractUser):
if session.puppet]
if return_dbobj:
return puppets
return [puppet.typeclass for puppet in puppets]
return [puppet for puppet in puppets]
def __get_single_puppet(self):
"""
@ -447,7 +447,7 @@ class PlayerDB(TypedObject, AbstractUser):
except IndexError:
# this can happen for bots
sessid = None
return cmdhandler.cmdhandler(self.typeclass, raw_string,
return cmdhandler.cmdhandler(self, raw_string,
callertype="player", sessid=sessid, **kwargs)
def search(self, searchdata, return_puppet=False, **kwargs):
@ -469,7 +469,7 @@ class PlayerDB(TypedObject, AbstractUser):
return_puppet = kwargs.get("return_character")
matches = _GA(self, "__class__").objects.player_search(searchdata)
matches = _AT_SEARCH_RESULT(_GA(self, "typeclass"), searchdata, matches, global_search=True)
matches = _AT_SEARCH_RESULT(self, searchdata, matches, global_search=True)
if matches and return_puppet:
try:
return _GA(matches, "puppet")