Added alternative function names to create module, for consistency with the search module. This means you can do create.objects() now too.

This commit is contained in:
Griatch 2012-03-25 14:01:51 +02:00
parent 88c0087fbd
commit 3408f3ca3f

View file

@ -1,13 +1,17 @@
""" """
This module gathers all the essential database-creation This module gathers all the essential database-creation
methods for the game engine's various object types. functions for the game engine's various object types.
Only objects created 'stand-alone' are in here,
e.g. object Attributes are always created directly through their
respective objects.
The respective object managers hold more methods for Only objects created 'stand-alone' are in here, e.g. object Attributes
manipulating and searching objects already existing in are always created directly through their respective objects.
the database.
Each creation_* function also has an alias named for the entity being
created, such as create_object() and object(). This is for
consistency with the utils.search module and allows you to do the
shorter "create.object()".
The respective object managers hold more methods for manipulating and
searching objects already existing in the database.
Models covered: Models covered:
Objects Objects
@ -25,6 +29,9 @@ from src.utils.idmapper.models import SharedMemoryModel
from src.utils import logger, utils, idmapper from src.utils import logger, utils, idmapper
from src.utils.utils import is_iter, has_parent, inherits_from from src.utils.utils import is_iter, has_parent, inherits_from
# limit symbol import from API
__all__ = ("object", "script", "help_entry", "message", "channel", "player")
# #
# Game Object creation # Game Object creation
# #
@ -122,6 +129,9 @@ def create_object(typeclass, key=None, location=None,
new_object.save() new_object.save()
return new_object return new_object
#alias for create_object
object = create_object
# #
# Script creation # Script creation
# #
@ -217,6 +227,8 @@ def create_script(typeclass, key=None, obj=None, locks=None,
new_db_script.save() new_db_script.save()
return new_script return new_script
#alias
script = create_script
# #
# Help entry creation # Help entry creation
@ -248,7 +260,8 @@ def create_help_entry(key, entrytext, category="General", locks=None):
except Exception: except Exception:
logger.log_trace() logger.log_trace()
return None return None
# alias
help_entry = create_help_entry
# #
# Comm system methods # Comm system methods
@ -317,6 +330,8 @@ def create_message(senderobj, message, channels=None,
new_message.save() new_message.save()
return new_message return new_message
message = create_message
def create_channel(key, aliases=None, desc=None, def create_channel(key, aliases=None, desc=None,
locks=None, keep_log=True): locks=None, keep_log=True):
""" """
@ -352,6 +367,8 @@ def create_channel(key, aliases=None, desc=None,
new_channel.save() new_channel.save()
channelhandler.CHANNELHANDLER.add_channel(new_channel) channelhandler.CHANNELHANDLER.add_channel(new_channel)
return new_channel return new_channel
channel = create_channel
# #
# Player creation methods # Player creation methods
@ -494,3 +511,5 @@ def create_player(name, email, password,
except Exception: except Exception:
pass pass
# alias
player = create_player