2008-12-15 05:55:04 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
This module defines the database models for all in-game objects, that
|
2012-03-30 23:47:22 +02:00
|
|
|
is, all objects that has an actual existence in-game.
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
Each database object is 'decorated' with a 'typeclass', a normal
|
|
|
|
|
python class that implements all the various logics needed by the game
|
|
|
|
|
in question. Objects created of this class transparently communicate
|
|
|
|
|
with its related database object for storing all attributes. The
|
|
|
|
|
admin should usually not have to deal directly with this database
|
|
|
|
|
object layer.
|
|
|
|
|
|
|
|
|
|
Attributes are separate objects that store values persistently onto
|
|
|
|
|
the database object. Like everything else, they can be accessed
|
|
|
|
|
transparently through the decorating TypeClass.
|
2008-12-15 05:55:04 +00:00
|
|
|
"""
|
2011-02-27 22:27:56 +00:00
|
|
|
|
2011-06-26 14:35:02 +00:00
|
|
|
import traceback
|
2006-11-20 18:54:10 +00:00
|
|
|
from django.db import models
|
2008-12-15 05:55:04 +00:00
|
|
|
from django.conf import settings
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2010-10-30 18:42:37 +00:00
|
|
|
from src.utils.idmapper.models import SharedMemoryModel
|
2012-02-26 01:26:38 +01:00
|
|
|
from src.typeclasses.models import Attribute, TypedObject, TypeNick, TypeNickHandler
|
2012-11-01 11:20:07 +01:00
|
|
|
from src.server.caches import get_field_cache, set_field_cache, del_field_cache
|
2013-02-02 22:41:56 +01:00
|
|
|
from src.server.caches import get_prop_cache, set_prop_cache, del_prop_cache
|
2010-08-29 18:46:58 +00:00
|
|
|
from src.typeclasses.typeclass import TypeClass
|
2012-10-14 17:24:30 +02:00
|
|
|
from src.players.models import PlayerNick
|
2010-08-29 18:46:58 +00:00
|
|
|
from src.objects.manager import ObjectManager
|
2011-03-20 19:45:56 +00:00
|
|
|
from src.commands.cmdsethandler import CmdSetHandler
|
2011-04-23 11:54:08 +00:00
|
|
|
from src.commands import cmdhandler
|
2011-03-20 19:45:56 +00:00
|
|
|
from src.scripts.scripthandler import ScriptHandler
|
2010-08-29 18:46:58 +00:00
|
|
|
from src.utils import logger
|
2012-05-17 19:42:37 +02:00
|
|
|
from src.utils.utils import make_iter, to_unicode, variable_from_module, inherits_from
|
2009-05-02 19:02:36 +00:00
|
|
|
|
2012-06-14 08:56:57 +02:00
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
|
|
2012-03-31 15:09:22 +02:00
|
|
|
#__all__ = ("ObjAttribute", "Alias", "ObjectNick", "ObjectDB")
|
|
|
|
|
|
2013-02-18 20:08:05 +01:00
|
|
|
_ScriptDB = None
|
2012-04-22 12:23:42 +02:00
|
|
|
_AT_SEARCH_RESULT = variable_from_module(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2012-03-31 13:06:29 +02:00
|
|
|
_GA = object.__getattribute__
|
|
|
|
|
_SA = object.__setattr__
|
|
|
|
|
_DA = object.__delattr__
|
2012-02-25 23:56:31 +01:00
|
|
|
|
2012-09-17 15:31:50 +02:00
|
|
|
_ME = _("me")
|
|
|
|
|
_SELF = _("self")
|
|
|
|
|
_HERE = _("here")
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# ObjAttribute
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class ObjAttribute(Attribute):
|
|
|
|
|
"Attributes for ObjectDB objects."
|
|
|
|
|
db_obj = models.ForeignKey("ObjectDB")
|
2009-11-25 19:27:32 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
class Meta:
|
|
|
|
|
"Define Django meta options"
|
|
|
|
|
verbose_name = "Object Attribute"
|
|
|
|
|
verbose_name_plural = "Object Attributes"
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2010-10-30 18:42:37 +00:00
|
|
|
#------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Alias
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
class Alias(SharedMemoryModel):
|
|
|
|
|
"""
|
|
|
|
|
This model holds a range of alternate names for an object.
|
|
|
|
|
These are intrinsic properties of the object. The split
|
|
|
|
|
is so as to allow for effective global searches also by
|
2012-03-30 23:47:22 +02:00
|
|
|
alias.
|
|
|
|
|
"""
|
2012-02-06 13:18:25 +01:00
|
|
|
db_key = models.CharField('alias', max_length=255, db_index=True)
|
2011-10-02 01:21:03 +02:00
|
|
|
db_obj = models.ForeignKey("ObjectDB", verbose_name='object')
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-10-30 18:42:37 +00:00
|
|
|
class Meta:
|
|
|
|
|
"Define Django meta options"
|
|
|
|
|
verbose_name = "Object alias"
|
|
|
|
|
verbose_name_plural = "Object aliases"
|
2011-03-15 16:08:32 +00:00
|
|
|
def __unicode__(self):
|
|
|
|
|
return u"%s" % self.db_key
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return str(self.db_key)
|
2012-03-30 23:47:22 +02:00
|
|
|
|
|
|
|
|
|
2010-10-30 18:42:37 +00:00
|
|
|
|
2011-02-27 22:27:56 +00:00
|
|
|
#------------------------------------------------------------
|
|
|
|
|
#
|
2011-04-23 11:54:08 +00:00
|
|
|
# Object Nicks
|
2011-02-27 22:27:56 +00:00
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------
|
|
|
|
|
|
2011-04-23 11:54:08 +00:00
|
|
|
class ObjectNick(TypeNick):
|
2011-02-27 22:27:56 +00:00
|
|
|
"""
|
2012-03-30 23:47:22 +02:00
|
|
|
|
|
|
|
|
The default nick types used by Evennia are:
|
2011-02-27 22:27:56 +00:00
|
|
|
inputline (default) - match against all input
|
|
|
|
|
player - match against player searches
|
2012-03-30 23:47:22 +02:00
|
|
|
obj - match against object searches
|
2011-02-27 22:27:56 +00:00
|
|
|
channel - used to store own names for channels
|
|
|
|
|
"""
|
2011-10-02 01:21:03 +02:00
|
|
|
db_obj = models.ForeignKey("ObjectDB", verbose_name='object')
|
2011-02-27 22:27:56 +00:00
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
"Define Django meta options"
|
2011-04-23 11:54:08 +00:00
|
|
|
verbose_name = "Nickname for Objects"
|
2011-10-02 01:21:03 +02:00
|
|
|
verbose_name_plural = "Nicknames for Objects"
|
2011-02-27 22:27:56 +00:00
|
|
|
unique_together = ("db_nick", "db_type", "db_obj")
|
|
|
|
|
|
2011-04-23 11:54:08 +00:00
|
|
|
class ObjectNickHandler(TypeNickHandler):
|
2011-03-15 16:08:32 +00:00
|
|
|
"""
|
|
|
|
|
Handles nick access and setting. Accessed through ObjectDB.nicks
|
2012-03-30 23:47:22 +02:00
|
|
|
"""
|
2011-04-23 11:54:08 +00:00
|
|
|
NickClass = ObjectNick
|
2011-03-15 16:08:32 +00:00
|
|
|
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# ObjectDB
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------
|
2009-01-18 04:54:05 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
class ObjectDB(TypedObject):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
All objects in the game use the ObjectDB model to store
|
|
|
|
|
data in the database. This is handled transparently through
|
|
|
|
|
the typeclass system.
|
|
|
|
|
|
|
|
|
|
Note that the base objectdb is very simple, with
|
|
|
|
|
few defined fields. Use attributes to extend your
|
2012-03-30 23:47:22 +02:00
|
|
|
type class with new database-stored variables.
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
The TypedObject supplies the following (inherited) properties:
|
|
|
|
|
key - main name
|
|
|
|
|
name - alias for key
|
|
|
|
|
typeclass_path - the path to the decorating typeclass
|
|
|
|
|
typeclass - auto-linked typeclass
|
|
|
|
|
date_created - time stamp of object creation
|
2012-03-30 23:47:22 +02:00
|
|
|
permissions - perm strings
|
2011-03-15 16:08:32 +00:00
|
|
|
locks - lock definitions (handler)
|
2012-03-30 23:47:22 +02:00
|
|
|
dbref - #id of object
|
2010-08-29 18:46:58 +00:00
|
|
|
db - persistent attribute storage
|
2012-03-30 23:47:22 +02:00
|
|
|
ndb - non-persistent attribute storage
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
The ObjectDB adds the following properties:
|
|
|
|
|
player - optional connected player
|
|
|
|
|
location - in-game location of object
|
2011-03-15 16:08:32 +00:00
|
|
|
home - safety location for object (handler)
|
|
|
|
|
|
|
|
|
|
scripts - scripts assigned to object (handler from typeclass)
|
|
|
|
|
cmdset - active cmdset on object (handler from typeclass)
|
|
|
|
|
aliases - aliases for this object (property)
|
2012-03-30 23:47:22 +02:00
|
|
|
nicks - nicknames for *other* things in Evennia (handler)
|
2010-08-29 18:46:58 +00:00
|
|
|
sessions - sessions connected to this object (see also player)
|
|
|
|
|
has_player - bool if an active player is currently connected
|
|
|
|
|
contents - other objects having this object as location
|
2011-03-15 16:08:32 +00:00
|
|
|
exits - exits from this object
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2009-09-27 16:36:03 +00:00
|
|
|
|
2009-10-14 18:15:15 +00:00
|
|
|
#
|
2010-08-29 18:46:58 +00:00
|
|
|
# ObjectDB Database model setup
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# inherited fields (from TypedObject):
|
2012-03-30 23:47:22 +02:00
|
|
|
# db_key (also 'name' works), db_typeclass_path, db_date_created,
|
2010-08-29 18:46:58 +00:00
|
|
|
# db_permissions
|
|
|
|
|
#
|
|
|
|
|
# These databse fields (including the inherited ones) are all set
|
|
|
|
|
# using their corresponding properties, named same as the field,
|
|
|
|
|
# but withtout the db_* prefix.
|
|
|
|
|
|
|
|
|
|
# If this is a character object, the player is connected here.
|
2012-03-30 23:47:22 +02:00
|
|
|
db_player = models.ForeignKey("players.PlayerDB", blank=True, null=True, verbose_name='player',
|
|
|
|
|
help_text='a Player connected to this object, if any.')
|
2013-02-01 22:03:55 +01:00
|
|
|
# the session id associated with this player, if any
|
|
|
|
|
db_sessid = models.IntegerField(null=True, verbose_name="session id",
|
2013-02-02 22:41:56 +01:00
|
|
|
help_text="unique session id of connected Player, if any.")
|
2010-08-29 18:46:58 +00:00
|
|
|
# The location in the game world. Since this one is likely
|
|
|
|
|
# to change often, we set this with the 'location' property
|
2012-03-30 23:47:22 +02:00
|
|
|
# to transparently handle Typeclassing.
|
2012-02-06 13:18:25 +01:00
|
|
|
db_location = models.ForeignKey('self', related_name="locations_set",db_index=True,
|
2011-10-02 01:21:03 +02:00
|
|
|
blank=True, null=True, verbose_name='game location')
|
2010-08-29 18:46:58 +00:00
|
|
|
# a safety location, this usually don't change much.
|
|
|
|
|
db_home = models.ForeignKey('self', related_name="homes_set",
|
2011-10-02 01:21:03 +02:00
|
|
|
blank=True, null=True, verbose_name='home location')
|
2011-04-08 23:10:04 +00:00
|
|
|
# destination of this object - primarily used by exits.
|
2012-02-06 13:18:25 +01:00
|
|
|
db_destination = models.ForeignKey('self', related_name="destinations_set", db_index=True,
|
2011-10-02 01:21:03 +02:00
|
|
|
blank=True, null=True, verbose_name='destination',
|
|
|
|
|
help_text='a destination, used only by exit objects.')
|
2011-03-20 19:45:56 +00:00
|
|
|
# database storage of persistant cmdsets.
|
2011-10-02 22:37:07 +02:00
|
|
|
db_cmdset_storage = models.CharField('cmdset', max_length=255, null=True, blank=True,
|
|
|
|
|
help_text="optional python path to a cmdset class.")
|
2010-08-29 18:46:58 +00:00
|
|
|
# Database manager
|
|
|
|
|
objects = ObjectManager()
|
2009-10-14 18:15:15 +00:00
|
|
|
|
2011-03-15 16:08:32 +00:00
|
|
|
# Add the object-specific handlers
|
2011-03-20 19:45:56 +00:00
|
|
|
|
2011-03-15 16:08:32 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
"Parent must be initialized first."
|
2012-03-30 23:47:22 +02:00
|
|
|
TypedObject.__init__(self, *args, **kwargs)
|
|
|
|
|
# handlers
|
2012-09-20 23:18:52 +02:00
|
|
|
_SA(self, "cmdset", CmdSetHandler(self))
|
|
|
|
|
_GA(self, "cmdset").update(init_mode=True)
|
|
|
|
|
_SA(self, "scripts", ScriptHandler(self))
|
|
|
|
|
_SA(self, "nicks", ObjectNickHandler(self))
|
2012-02-05 21:04:10 +01:00
|
|
|
# store the attribute class
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# 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
|
2012-03-30 23:47:22 +02:00
|
|
|
# defined that allows the user to do self.attr = value,
|
|
|
|
|
# value = self.attr and del self.attr respectively (where self
|
2010-08-29 18:46:58 +00:00
|
|
|
# is the object in question).
|
|
|
|
|
|
|
|
|
|
# aliases property (wraps (db_aliases)
|
2012-03-30 23:47:22 +02:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __aliases_get(self):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Getter. Allows for value = self.aliases"
|
2012-11-01 11:20:07 +01:00
|
|
|
aliases = get_prop_cache(self, "_aliases")
|
|
|
|
|
if aliases == None:
|
2012-02-25 23:56:31 +01:00
|
|
|
aliases = list(Alias.objects.filter(db_obj=self).values_list("db_key", flat=True))
|
2012-11-01 11:20:07 +01:00
|
|
|
set_prop_cache(self, "_aliases", aliases)
|
|
|
|
|
return aliases
|
2010-08-29 18:46:58 +00:00
|
|
|
#@aliases.setter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __aliases_set(self, aliases):
|
2012-03-30 23:47:22 +02:00
|
|
|
"Setter. Allows for self.aliases = value"
|
2012-02-25 23:56:31 +01:00
|
|
|
for alias in make_iter(aliases):
|
2010-10-30 18:42:37 +00:00
|
|
|
new_alias = Alias(db_key=alias, db_obj=self)
|
|
|
|
|
new_alias.save()
|
2013-02-01 21:03:03 +01:00
|
|
|
set_prop_cache(self, "_aliases", make_iter(aliases))
|
2010-08-29 18:46:58 +00:00
|
|
|
#@aliases.deleter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __aliases_del(self):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Deleter. Allows for del self.aliases"
|
2010-10-30 18:42:37 +00:00
|
|
|
for alias in Alias.objects.filter(db_obj=self):
|
|
|
|
|
alias.delete()
|
2012-11-01 11:20:07 +01:00
|
|
|
del_prop_cache(self, "_aliases")
|
2012-03-31 15:09:22 +02:00
|
|
|
aliases = property(__aliases_get, __aliases_set, __aliases_del)
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# player property (wraps db_player)
|
|
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __player_get(self):
|
2009-01-15 16:24:52 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Getter. Allows for value = self.player.
|
|
|
|
|
We have to be careful here since Player is also
|
|
|
|
|
a TypedObject, so as to not create a loop.
|
2009-01-15 16:24:52 +00:00
|
|
|
"""
|
2012-11-01 11:20:07 +01:00
|
|
|
return get_field_cache(self, "player")
|
2010-08-29 18:46:58 +00:00
|
|
|
#@player.setter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __player_set(self, player):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Setter. Allows for self.player = value"
|
2012-05-17 19:42:37 +02:00
|
|
|
if inherits_from(player, TypeClass):
|
2010-08-29 18:46:58 +00:00
|
|
|
player = player.dbobj
|
2012-11-01 11:20:07 +01:00
|
|
|
set_field_cache(self, "player", player)
|
2013-03-11 20:01:03 +01:00
|
|
|
# we must set this here or superusers won't be able to
|
|
|
|
|
# bypass lockchecks unless they start the game connected
|
|
|
|
|
# to the character in question.
|
|
|
|
|
self.locks.cache_lock_bypass(self)
|
2010-08-29 18:46:58 +00:00
|
|
|
#@player.deleter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __player_del(self):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Deleter. Allows for del self.player"
|
2012-11-01 11:20:07 +01:00
|
|
|
del_field_cache(self, "player")
|
2012-03-31 15:09:22 +02:00
|
|
|
player = property(__player_get, __player_set, __player_del)
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2013-02-01 22:03:55 +01:00
|
|
|
# sessid property (wraps db_sessid)
|
|
|
|
|
#@property
|
|
|
|
|
def __sessid_get(self):
|
|
|
|
|
"""
|
|
|
|
|
Getter. Allows for value = self.sessid. Since sessid
|
|
|
|
|
is directly related to self.player, we cannot have
|
|
|
|
|
a sessid without a player being connected (but the
|
|
|
|
|
opposite could be true).
|
|
|
|
|
"""
|
2013-02-02 22:41:56 +01:00
|
|
|
if not get_field_cache(self, "sessid"):
|
2013-02-01 22:03:55 +01:00
|
|
|
del_field_cache(self, "sessid")
|
|
|
|
|
return get_field_cache(self, "sessid")
|
2013-02-02 15:55:42 +01:00
|
|
|
#@sessid.setter
|
2013-02-02 22:41:56 +01:00
|
|
|
def __sessid_set(self, sessid):
|
2013-02-01 22:03:55 +01:00
|
|
|
"Setter. Allows for self.player = value"
|
2013-02-02 22:41:56 +01:00
|
|
|
set_field_cache(self, "sessid", sessid)
|
2013-02-02 15:55:42 +01:00
|
|
|
#@sessid.deleter
|
2013-02-02 22:41:56 +01:00
|
|
|
def __sessid_del(self):
|
2013-02-01 22:03:55 +01:00
|
|
|
"Deleter. Allows for del self.player"
|
2013-02-02 22:41:56 +01:00
|
|
|
del_field_cache(self, "sessid")
|
2013-02-03 00:25:06 +01:00
|
|
|
sessid = property(__sessid_get, __sessid_set, __sessid_del)
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# location property (wraps db_location)
|
2012-03-30 23:47:22 +02:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __location_get(self):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Getter. Allows for value = self.location."
|
2012-11-01 11:20:07 +01:00
|
|
|
loc = get_field_cache(self, "location")
|
2010-08-29 18:46:58 +00:00
|
|
|
if loc:
|
2012-09-20 02:52:21 +02:00
|
|
|
return _GA(loc, "typeclass")
|
2012-03-30 23:47:22 +02:00
|
|
|
return None
|
2010-08-29 18:46:58 +00:00
|
|
|
#@location.setter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __location_set(self, location):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Setter. Allows for self.location = location"
|
2009-01-15 16:24:52 +00:00
|
|
|
try:
|
2012-09-20 03:01:30 +02:00
|
|
|
old_loc = _GA(self, "location")
|
2012-09-20 02:52:21 +02:00
|
|
|
if ObjectDB.objects.dbref(location):
|
|
|
|
|
# dbref search
|
2011-09-07 15:47:19 +00:00
|
|
|
loc = ObjectDB.objects.dbref_search(location)
|
2012-09-20 02:52:21 +02:00
|
|
|
loc = loc and _GA(loc, "dbobj")
|
2012-09-22 13:37:22 +02:00
|
|
|
elif location and type(location) != ObjectDB:
|
2012-09-20 02:52:21 +02:00
|
|
|
loc = _GA(location, "dbobj")
|
2012-03-30 23:47:22 +02:00
|
|
|
else:
|
2012-09-20 02:52:21 +02:00
|
|
|
loc = location
|
2012-10-14 21:24:58 +02:00
|
|
|
|
|
|
|
|
# recursive location check
|
|
|
|
|
def is_loc_loop(loc, depth=0):
|
|
|
|
|
"Recursively traverse the target location to make sure we are not in it."
|
|
|
|
|
if depth > 10: return
|
|
|
|
|
elif loc == self: raise RuntimeError
|
|
|
|
|
elif loc == None: raise RuntimeWarning # just to quickly get out
|
|
|
|
|
return is_loc_loop(_GA(loc, "db_location"), depth+1)
|
|
|
|
|
# check so we don't create a location loop - if so, RuntimeError will be raised.
|
|
|
|
|
try: is_loc_loop(loc)
|
|
|
|
|
except RuntimeWarning: pass
|
|
|
|
|
|
2012-10-14 20:21:53 +02:00
|
|
|
# set the location
|
2012-11-01 11:20:07 +01:00
|
|
|
set_field_cache(self, "location", loc)
|
2012-08-19 18:48:29 +02:00
|
|
|
# update the contents of each location
|
|
|
|
|
if old_loc:
|
2012-11-01 11:20:07 +01:00
|
|
|
_GA(_GA(old_loc, "dbobj"), "contents_update")()
|
2012-08-19 21:36:01 +02:00
|
|
|
if loc:
|
2012-11-01 11:20:07 +01:00
|
|
|
_GA(loc, "contents_update")()
|
2012-10-14 20:21:53 +02:00
|
|
|
except RuntimeError:
|
2012-11-01 11:20:07 +01:00
|
|
|
string = "Cannot set location, "
|
|
|
|
|
string += "%s.location = %s would create a location-loop." % (self.key, loc)
|
2012-10-14 20:21:53 +02:00
|
|
|
_GA(self, "msg")(_(string))
|
|
|
|
|
logger.log_trace(string)
|
|
|
|
|
raise RuntimeError(string)
|
2012-11-01 11:20:07 +01:00
|
|
|
except Exception, e:
|
|
|
|
|
string = "Cannot set location (%s): " % str(e)
|
2012-10-14 20:21:53 +02:00
|
|
|
string += "%s is not a valid location." % location
|
|
|
|
|
_GA(self, "msg")(_(string))
|
2010-08-29 18:46:58 +00:00
|
|
|
logger.log_trace(string)
|
2012-10-14 20:21:53 +02:00
|
|
|
raise Exception(string)
|
2010-08-29 18:46:58 +00:00
|
|
|
#@location.deleter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __location_del(self):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Deleter. Allows for del self.location"
|
2012-11-01 11:20:07 +01:00
|
|
|
_GA(self, "location").contents_update()
|
2012-08-19 18:48:29 +02:00
|
|
|
_SA(self, "db_location", None)
|
|
|
|
|
_GA(self, "save")()
|
2012-11-01 11:20:07 +01:00
|
|
|
del_field_cache(self, "location")
|
2012-03-31 15:09:22 +02:00
|
|
|
location = property(__location_get, __location_set, __location_del)
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
# home property (wraps db_home)
|
2012-03-30 23:47:22 +02:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __home_get(self):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Getter. Allows for value = self.home"
|
2012-11-01 11:20:07 +01:00
|
|
|
home = get_field_cache(self, "home")
|
2010-08-29 18:46:58 +00:00
|
|
|
if home:
|
2012-09-20 23:18:52 +02:00
|
|
|
return _GA(home, "typeclass")
|
2012-03-30 23:47:22 +02:00
|
|
|
return None
|
2010-08-29 18:46:58 +00:00
|
|
|
#@home.setter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __home_set(self, home):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Setter. Allows for self.home = value"
|
2009-01-15 16:24:52 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
if home == None or type(home) == ObjectDB:
|
2012-03-30 23:47:22 +02:00
|
|
|
hom = home
|
2010-08-29 18:46:58 +00:00
|
|
|
elif ObjectDB.objects.dbref(home):
|
|
|
|
|
hom = ObjectDB.objects.dbref_search(home)
|
|
|
|
|
if hom and hasattr(hom,'dbobj'):
|
2012-09-20 23:18:52 +02:00
|
|
|
hom = _GA(hom, "dbobj")
|
2010-08-29 18:46:58 +00:00
|
|
|
else:
|
2012-09-20 23:18:52 +02:00
|
|
|
hom = _GA(home, "dbobj")
|
2012-03-30 23:47:22 +02:00
|
|
|
else:
|
2012-09-20 23:18:52 +02:00
|
|
|
hom = _GA(home, "dbobj")
|
2012-11-01 11:20:07 +01:00
|
|
|
set_field_cache(self, "home", hom)
|
2010-08-29 18:46:58 +00:00
|
|
|
except Exception:
|
|
|
|
|
string = "Cannot set home: "
|
2012-03-30 23:47:22 +02:00
|
|
|
string += "%s is not a valid home."
|
2012-09-20 23:18:52 +02:00
|
|
|
_GA(self, "msg")(_(string) % home)
|
2010-08-29 18:46:58 +00:00
|
|
|
logger.log_trace(string)
|
2012-03-30 23:47:22 +02:00
|
|
|
#raise
|
2010-08-29 18:46:58 +00:00
|
|
|
#@home.deleter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __home_del(self):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Deleter. Allows for del self.home."
|
2012-09-20 23:18:52 +02:00
|
|
|
_SA(self, "db_home", None)
|
|
|
|
|
_GA(self, "save")()
|
2012-11-01 11:20:07 +01:00
|
|
|
del_field_cache(self, "home")
|
2012-03-31 15:09:22 +02:00
|
|
|
home = property(__home_get, __home_set, __home_del)
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2011-04-08 23:10:04 +00:00
|
|
|
# destination property (wraps db_destination)
|
2012-03-30 23:47:22 +02:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __destination_get(self):
|
2011-04-08 23:10:04 +00:00
|
|
|
"Getter. Allows for value = self.destination."
|
2012-11-01 11:20:07 +01:00
|
|
|
dest = get_field_cache(self, "destination")
|
2011-04-08 23:10:04 +00:00
|
|
|
if dest:
|
2012-09-20 02:52:21 +02:00
|
|
|
return _GA(dest, "typeclass")
|
2012-03-30 23:47:22 +02:00
|
|
|
return None
|
2011-04-08 23:10:04 +00:00
|
|
|
#@destination.setter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __destination_set(self, destination):
|
2011-04-08 23:10:04 +00:00
|
|
|
"Setter. Allows for self.destination = destination"
|
|
|
|
|
try:
|
|
|
|
|
if destination == None or type(destination) == ObjectDB:
|
|
|
|
|
# destination is None or a valid object
|
2012-03-30 23:47:22 +02:00
|
|
|
dest = destination
|
2011-04-08 23:10:04 +00:00
|
|
|
elif ObjectDB.objects.dbref(destination):
|
|
|
|
|
# destination is a dbref; search
|
|
|
|
|
dest = ObjectDB.objects.dbref_search(destination)
|
2012-09-20 23:18:52 +02:00
|
|
|
if dest and _GA(self, "_hasattr")(dest,'dbobj'):
|
2012-09-20 02:52:21 +02:00
|
|
|
dest = _GA(dest, "dbobj")
|
2011-04-08 23:10:04 +00:00
|
|
|
else:
|
2012-09-20 02:52:21 +02:00
|
|
|
dest = _GA(destination, "dbobj")
|
2012-03-30 23:47:22 +02:00
|
|
|
else:
|
|
|
|
|
dest = destination.dbobj
|
2012-11-01 11:20:07 +01:00
|
|
|
set_field_cache(self, "destination", dest)
|
2011-04-08 23:10:04 +00:00
|
|
|
except Exception:
|
|
|
|
|
string = "Cannot set destination: "
|
2012-09-20 23:18:52 +02:00
|
|
|
string += "%s is not a valid destination." % destination
|
|
|
|
|
_GA(self, "msg")(string)
|
2011-04-08 23:10:04 +00:00
|
|
|
logger.log_trace(string)
|
2012-03-30 23:47:22 +02:00
|
|
|
raise
|
2011-04-08 23:10:04 +00:00
|
|
|
#@destination.deleter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __destination_del(self):
|
2011-04-08 23:10:04 +00:00
|
|
|
"Deleter. Allows for del self.destination"
|
2012-09-20 02:52:21 +02:00
|
|
|
_SA(self, "db_destination", None)
|
|
|
|
|
_GA(self, "save")()
|
2012-11-01 11:20:07 +01:00
|
|
|
del_field_cache(self, "destination")
|
2012-03-31 15:09:22 +02:00
|
|
|
destination = property(__destination_get, __destination_set, __destination_del)
|
2011-04-08 23:10:04 +00:00
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
# cmdset_storage property.
|
2012-02-26 12:43:16 +01:00
|
|
|
# This seems very sensitive to caching, so leaving it be for now. /Griatch
|
2011-03-20 19:45:56 +00:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __cmdset_storage_get(self):
|
2011-03-20 19:45:56 +00:00
|
|
|
"Getter. Allows for value = self.name. Returns a list of cmdset_storage."
|
2012-09-20 23:18:52 +02:00
|
|
|
if _GA(self, "db_cmdset_storage"):
|
|
|
|
|
return [path.strip() for path in _GA(self, "db_cmdset_storage").split(',')]
|
2011-03-20 19:45:56 +00:00
|
|
|
return []
|
|
|
|
|
#@cmdset_storage.setter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __cmdset_storage_set(self, value):
|
2011-03-20 19:45:56 +00:00
|
|
|
"Setter. Allows for self.name = value. Stores as a comma-separated string."
|
2012-02-26 12:07:25 +01:00
|
|
|
value = ",".join(str(val).strip() for val in make_iter(value))
|
2012-09-20 23:18:52 +02:00
|
|
|
_SA(self, "db_cmdset_storage", value)
|
|
|
|
|
_GA(self, "save")()
|
2011-03-20 19:45:56 +00:00
|
|
|
#@cmdset_storage.deleter
|
2012-03-31 15:09:22 +02:00
|
|
|
def __cmdset_storage_del(self):
|
2011-03-20 19:45:56 +00:00
|
|
|
"Deleter. Allows for del self.name"
|
2012-09-20 23:18:52 +02:00
|
|
|
_SA(self, "db_cmdset_storage", "")
|
|
|
|
|
_GA(self, "save")()
|
2012-03-31 15:09:22 +02:00
|
|
|
cmdset_storage = property(__cmdset_storage_get, __cmdset_storage_set, __cmdset_storage_del)
|
2011-03-20 19:45:56 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
class Meta:
|
|
|
|
|
"Define Django meta options"
|
|
|
|
|
verbose_name = "Object"
|
|
|
|
|
verbose_name_plural = "Objects"
|
Implemented locks.
The main command to use is @lock, which accept three types of locks at the moment, and three types of keys:
Locks: DefaultLock, UseLock, EnterLock
Keys: ObjectIDs, Groups, Permissions
This offers the most useful functionality - stopping people from picking up things, blocking exits and stopping
anyone from using an object.
If the attributes lock_msg, use_lock_msg and enter_lock_msg are defined on the locked object, these will be used
as error messages instead of a standard one (so "the door is locked" instead of "you cannot traverse that exit").
Behind the scenes, there is a new module, src/locks.py that defines Keys and Locks. A Locks object is a collection
of Lock types. This is stored in the LOCKS attribute on objects. Each Lock contains a set of Keys that might be
of mixed type and which the player must match in order to pass the lock.
/Griatch
2009-10-05 20:04:15 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
|
|
|
|
# ObjectDB class access methods/properties
|
2012-03-30 23:47:22 +02:00
|
|
|
#
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2011-05-13 22:26:08 +00:00
|
|
|
# this is required to properly handle attributes and typeclass loading.
|
2012-03-31 13:06:29 +02:00
|
|
|
_typeclass_paths = settings.OBJECT_TYPECLASS_PATHS
|
|
|
|
|
_attribute_class = ObjAttribute
|
|
|
|
|
_db_model_name = "objectdb" # used by attributes to safely store objects
|
|
|
|
|
_default_typeclass_path = settings.BASE_OBJECT_TYPECLASS or "src.objects.objects.Object"
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __sessions_get(self):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Retrieve sessions connected to this object.
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2012-03-30 23:47:22 +02:00
|
|
|
# if the player is not connected, this will simply be an empty list.
|
2012-09-20 00:47:28 +02:00
|
|
|
if _GA(self, "player"):
|
|
|
|
|
return _GA(_GA(self, "player"), "sessions")
|
2010-08-29 18:46:58 +00:00
|
|
|
return []
|
2012-03-31 15:09:22 +02:00
|
|
|
sessions = property(__sessions_get)
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __has_player_get(self):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Convenience function for checking if an active player is
|
|
|
|
|
currently connected to this object
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2012-09-20 00:47:28 +02:00
|
|
|
return any(_GA(self, "sessions"))
|
2012-03-31 15:09:22 +02:00
|
|
|
has_player = property(__has_player_get)
|
|
|
|
|
is_player = property(__has_player_get)
|
2011-06-26 14:35:02 +00:00
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __is_superuser_get(self):
|
2011-06-26 14:35:02 +00:00
|
|
|
"Check if user has a player, and if so, if it is a superuser."
|
2012-09-20 00:47:28 +02:00
|
|
|
return any(_GA(self, "sessions")) and _GA(_GA(self, "player"), "is_superuser")
|
2012-03-31 15:09:22 +02:00
|
|
|
is_superuser = property(__is_superuser_get)
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
|
2012-08-19 18:48:29 +02:00
|
|
|
# contents
|
|
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
#@property
|
2011-05-01 18:04:15 +00:00
|
|
|
def contents_get(self, exclude=None):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Returns the contents of this object, i.e. all
|
|
|
|
|
objects that has this object set as its location.
|
2012-03-31 15:09:22 +02:00
|
|
|
This should be publically available.
|
2012-08-19 18:48:29 +02:00
|
|
|
|
|
|
|
|
exclude is one or more objects to not return
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2012-11-01 11:20:07 +01:00
|
|
|
cont = get_prop_cache(self, "_contents")
|
|
|
|
|
exclude = make_iter(exclude)
|
|
|
|
|
if cont == None:
|
|
|
|
|
cont = _GA(self, "contents_update")()
|
|
|
|
|
return [obj for obj in cont if obj not in exclude]
|
2010-08-29 18:46:58 +00:00
|
|
|
contents = property(contents_get)
|
2009-01-15 16:24:52 +00:00
|
|
|
|
2012-11-01 11:20:07 +01:00
|
|
|
def contents_update(self):
|
2012-08-19 18:48:29 +02:00
|
|
|
"""
|
2012-11-01 11:20:07 +01:00
|
|
|
Updates the contents property of the object with a new
|
|
|
|
|
object Called by
|
2012-08-19 18:48:29 +02:00
|
|
|
self.location_set.
|
2012-11-01 11:20:07 +01:00
|
|
|
|
|
|
|
|
obj -
|
|
|
|
|
remove (true/false) - remove obj from content list
|
2012-08-19 18:48:29 +02:00
|
|
|
"""
|
2012-11-01 11:20:07 +01:00
|
|
|
cont = ObjectDB.objects.get_contents(self)
|
|
|
|
|
set_prop_cache(self, "_contents", cont)
|
|
|
|
|
return cont
|
2012-08-19 18:48:29 +02:00
|
|
|
|
2011-02-14 17:18:31 +00:00
|
|
|
#@property
|
2012-03-31 15:09:22 +02:00
|
|
|
def __exits_get(self):
|
2011-02-14 17:18:31 +00:00
|
|
|
"""
|
|
|
|
|
Returns all exits from this object, i.e. all objects
|
2011-04-08 23:10:04 +00:00
|
|
|
at this location having the property destination != None.
|
2011-02-14 17:18:31 +00:00
|
|
|
"""
|
2012-09-20 23:18:52 +02:00
|
|
|
return [exi for exi in _GA(self, "contents")
|
2011-04-08 23:10:04 +00:00
|
|
|
if exi.destination]
|
2012-03-31 15:09:22 +02:00
|
|
|
exits = property(__exits_get)
|
2011-03-15 16:08:32 +00:00
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
|
|
|
|
# Main Search method
|
|
|
|
|
#
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def search(self, ostring,
|
|
|
|
|
global_search=False,
|
2012-12-08 14:09:42 +01:00
|
|
|
global_dbref=False,
|
2010-08-29 18:46:58 +00:00
|
|
|
attribute_name=None,
|
2011-02-27 22:55:42 +00:00
|
|
|
use_nicks=False, location=None,
|
2012-09-17 15:31:50 +02:00
|
|
|
player=False,
|
|
|
|
|
ignore_errors=False, exact=False):
|
2009-05-02 19:02:36 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Perform a standard object search in the database, handling
|
|
|
|
|
multiple results and lack thereof gracefully.
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
ostring: (str) The string to match object names against.
|
|
|
|
|
Obs - To find a player, append * to the
|
2012-03-30 23:47:22 +02:00
|
|
|
start of ostring.
|
2010-10-21 18:58:47 +00:00
|
|
|
global_search: Search all objects, not just the current
|
2012-09-17 15:31:50 +02:00
|
|
|
location/inventory. This is overruled if location keyword is given.
|
2012-12-08 14:09:42 +01:00
|
|
|
global_dbref: Search globally -only- if a valid #dbref is given, otherwise local.
|
2012-09-17 15:31:50 +02:00
|
|
|
attribute_name: (string) Which attribute to match (if None, uses default 'name')
|
2012-03-30 23:47:22 +02:00
|
|
|
use_nicks : Use nickname replace (off by default)
|
2012-09-21 08:36:59 +02:00
|
|
|
location : If None, use caller's current location, and caller.contents.
|
|
|
|
|
This can also be a list of locations
|
2012-09-17 15:31:50 +02:00
|
|
|
player: return the Objects' controlling Player, instead, if available
|
2010-08-29 18:46:58 +00:00
|
|
|
ignore_errors : Don't display any error messages even
|
2012-03-30 23:47:22 +02:00
|
|
|
if there are none/multiple matches -
|
|
|
|
|
just return the result as a list.
|
2012-09-17 15:31:50 +02:00
|
|
|
exact: Determines if the search must exactly match the key/alias of the
|
|
|
|
|
given object or if partial matches the beginnings of one or more
|
|
|
|
|
words in the name is enough. Exact matching is faster if using
|
|
|
|
|
global search. Also, if attribute_name is set, matching is always exact.
|
2011-04-23 11:54:08 +00:00
|
|
|
|
2012-03-24 18:25:32 +01:00
|
|
|
Returns - a unique Object/Player match or None. All error
|
|
|
|
|
messages are handled by system-commands and the parser-handlers
|
2012-03-30 23:47:22 +02:00
|
|
|
specified in settings.
|
2012-03-24 18:25:32 +01:00
|
|
|
|
2011-04-23 11:54:08 +00:00
|
|
|
Use *<string> to search for objects controlled by a specific
|
|
|
|
|
player. Note that the object controlled by the player will be
|
|
|
|
|
returned, not the player object itself. This also means that
|
|
|
|
|
this will not find Players without a character. Use the keyword
|
2012-03-30 23:47:22 +02:00
|
|
|
player=True to find player objects.
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
Note - for multiple matches, the engine accepts a number
|
|
|
|
|
linked to the key in order to separate the matches from
|
|
|
|
|
each other without showing the dbref explicitly. Default
|
|
|
|
|
syntax for this is 'N-searchword'. So for example, if there
|
|
|
|
|
are three objects in the room all named 'ball', you could
|
|
|
|
|
address the individual ball as '1-ball', '2-ball', '3-ball'
|
2012-03-30 23:47:22 +02:00
|
|
|
etc.
|
2010-08-29 18:46:58 +00:00
|
|
|
"""
|
2012-09-17 15:31:50 +02:00
|
|
|
# handle some common self-references:
|
|
|
|
|
if ostring == _HERE:
|
|
|
|
|
return self.location
|
|
|
|
|
if ostring in (_ME, _SELF, '*' + _ME, '*' + _SELF):
|
|
|
|
|
return self
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
if use_nicks:
|
2012-10-14 17:24:30 +02:00
|
|
|
nick = None
|
|
|
|
|
nicktype = "object"
|
|
|
|
|
if player or ostring.startswith('*'):
|
|
|
|
|
ostring = ostring.lstrip("*")
|
|
|
|
|
nicktype = "player"
|
|
|
|
|
# look up nicks
|
|
|
|
|
nicks = ObjectNick.objects.filter(db_obj=self, db_type=nicktype)
|
|
|
|
|
if self.has_player:
|
|
|
|
|
nicks = list(nicks) + list(PlayerNick.objects.filter(db_obj=self.db_player, db_type=nicktype))
|
|
|
|
|
for nick in nicks:
|
|
|
|
|
if ostring == nick.db_nick:
|
|
|
|
|
ostring = nick.db_real
|
|
|
|
|
break
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2012-09-17 15:31:50 +02:00
|
|
|
candidates=None
|
2012-12-08 14:09:42 +01:00
|
|
|
if global_search or (global_dbref and ostring.startswith("#")):
|
2012-09-17 15:31:50 +02:00
|
|
|
# only allow exact matching if searching the entire database
|
|
|
|
|
exact = True
|
2012-09-21 08:36:59 +02:00
|
|
|
elif location:
|
|
|
|
|
# location(s) were given
|
|
|
|
|
candidates = []
|
|
|
|
|
for obj in make_iter(location):
|
|
|
|
|
candidates.extend([o.dbobj for o in obj.contents])
|
2011-04-23 11:54:08 +00:00
|
|
|
else:
|
2012-09-17 15:31:50 +02:00
|
|
|
# local search. Candidates are self.contents, self.location and self.location.contents
|
2012-09-21 08:36:59 +02:00
|
|
|
location = self.location
|
2012-09-17 15:31:50 +02:00
|
|
|
candidates = self.contents
|
|
|
|
|
if location:
|
|
|
|
|
candidates = candidates + [location] + location.contents
|
|
|
|
|
else:
|
|
|
|
|
candidates.append(self) # normally we are included in location.contents
|
|
|
|
|
# db manager expects database objects
|
|
|
|
|
candidates = [obj.dbobj for obj in candidates]
|
|
|
|
|
|
|
|
|
|
results = ObjectDB.objects.object_search(ostring, caller=self,
|
|
|
|
|
attribute_name=attribute_name,
|
|
|
|
|
candidates=candidates,
|
|
|
|
|
exact=exact)
|
2012-09-18 21:48:41 +02:00
|
|
|
if ignore_errors:
|
|
|
|
|
return results
|
|
|
|
|
result = _AT_SEARCH_RESULT(self, ostring, results, global_search)
|
2012-09-17 15:31:50 +02:00
|
|
|
if player and result:
|
|
|
|
|
return result.player
|
|
|
|
|
return result
|
|
|
|
|
|
2009-08-16 01:18:58 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
|
|
|
|
# Execution/action methods
|
|
|
|
|
#
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2013-02-02 22:41:56 +01:00
|
|
|
def execute_cmd(self, raw_string, sessid=None):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Do something as this object. This command transparently
|
2012-03-24 18:25:32 +01:00
|
|
|
lets its typeclass execute the command. Evennia also calls
|
|
|
|
|
this method whenever the player sends a command on the command line.
|
|
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
Argument:
|
2012-03-24 18:25:32 +01:00
|
|
|
raw_string (string) - raw command input
|
|
|
|
|
|
|
|
|
|
Returns Deferred - this is an asynchronous Twisted object that will
|
|
|
|
|
not fire until the command has actually finished executing. To overload
|
2012-03-30 23:47:22 +02:00
|
|
|
this one needs to attach callback functions to it, with addCallback(function).
|
2012-03-24 18:25:32 +01:00
|
|
|
This function will be called with an eventual return value from the command
|
2012-03-30 23:47:22 +02:00
|
|
|
execution.
|
2011-10-27 10:18:18 +02:00
|
|
|
|
2012-03-24 18:25:32 +01:00
|
|
|
This return is not used at all by Evennia by default, but might be useful
|
2012-03-30 23:47:22 +02:00
|
|
|
for coders intending to implement some sort of nested command structure.
|
|
|
|
|
"""
|
2011-02-27 22:27:56 +00:00
|
|
|
# nick replacement - we require full-word matching.
|
2012-03-30 23:47:22 +02:00
|
|
|
|
|
|
|
|
# do text encoding conversion
|
2011-04-21 16:45:18 +00:00
|
|
|
raw_string = to_unicode(raw_string)
|
|
|
|
|
|
2011-02-27 22:27:56 +00:00
|
|
|
raw_list = raw_string.split(None)
|
|
|
|
|
raw_list = [" ".join(raw_list[:i+1]) for i in range(len(raw_list)) if raw_list[:i+1]]
|
2012-10-14 17:24:30 +02:00
|
|
|
nicks = ObjectNick.objects.filter(db_obj=self, db_type__in=("inputline", "channel"))
|
|
|
|
|
if self.has_player:
|
|
|
|
|
nicks = list(nicks) + list(PlayerNick.objects.filter(db_obj=self.db_player, db_type__in=("inputline","channel")))
|
|
|
|
|
for nick in nicks:
|
2011-02-27 22:27:56 +00:00
|
|
|
if nick.db_nick in raw_list:
|
2012-03-30 23:47:22 +02:00
|
|
|
raw_string = raw_string.replace(nick.db_nick, nick.db_real, 1)
|
|
|
|
|
break
|
2013-02-02 22:41:56 +01:00
|
|
|
return cmdhandler.cmdhandler(_GA(self, "typeclass"), raw_string, sessid=sessid)
|
2009-11-01 15:12:38 +00:00
|
|
|
|
2013-02-17 18:48:48 +01:00
|
|
|
def msg(self, msg=None, from_obj=None, data=None, sessid=0):
|
2009-11-01 15:12:38 +00:00
|
|
|
"""
|
2013-02-02 22:41:56 +01:00
|
|
|
Emits something to a session attached to the object.
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
message (str): The message to send
|
|
|
|
|
from_obj (obj): object that is sending.
|
2010-12-07 02:34:59 +00:00
|
|
|
data (object): an optional data object that may or may not
|
2012-03-30 23:47:22 +02:00
|
|
|
be used by the protocol.
|
2013-02-17 18:48:48 +01:00
|
|
|
sessid (int): sessid to relay to, if any.
|
2013-02-17 20:21:23 +01:00
|
|
|
If set to 0 (default), use either from_obj.sessid (if set) or self.sessid automatically
|
2013-02-17 18:48:48 +01:00
|
|
|
If None, echo to all connected sessions
|
2010-08-29 18:46:58 +00:00
|
|
|
"""
|
2012-09-18 01:03:35 +02:00
|
|
|
if _GA(self, 'player'):
|
2013-02-02 22:41:56 +01:00
|
|
|
# note that we must call the player *typeclass'* msg(), otherwise one couldn't overload it.
|
2013-02-17 20:21:23 +01:00
|
|
|
if sessid == 0:
|
|
|
|
|
sessid = None
|
|
|
|
|
if from_obj and hasattr(from_obj, "sessid"):
|
|
|
|
|
sessid = from_obj.sessid
|
|
|
|
|
elif hasattr(self, "sessid"):
|
|
|
|
|
sessid = self.sessid
|
|
|
|
|
_GA(_GA(self, 'player'), "typeclass").msg(msg, from_obj=from_obj, data=data, sessid=sessid)
|
2009-11-22 21:18:55 +00:00
|
|
|
|
2010-12-07 02:34:59 +00:00
|
|
|
def emit_to(self, message, from_obj=None, data=None):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Deprecated. Alias for msg"
|
2011-03-15 16:08:32 +00:00
|
|
|
logger.log_depmsg("emit_to() is deprecated. Use msg() instead.")
|
2012-09-18 01:03:35 +02:00
|
|
|
_GA(self, "msg")(message, from_obj, data)
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-12-07 02:34:59 +00:00
|
|
|
def msg_contents(self, message, exclude=None, from_obj=None, data=None):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Emits something to all objects inside an object.
|
2009-01-18 02:40:57 +00:00
|
|
|
|
2010-12-07 02:34:59 +00:00
|
|
|
exclude is a list of objects not to send to. See self.msg() for more info.
|
2009-01-18 02:40:57 +00:00
|
|
|
"""
|
2012-09-20 23:18:52 +02:00
|
|
|
contents = _GA(self, "contents")
|
2010-08-29 18:46:58 +00:00
|
|
|
if exclude:
|
2012-02-26 01:10:20 +01:00
|
|
|
exclude = make_iter(exclude)
|
2010-08-29 18:46:58 +00:00
|
|
|
contents = [obj for obj in contents
|
|
|
|
|
if (obj not in exclude and obj not in exclude)]
|
|
|
|
|
for obj in contents:
|
2010-12-07 02:34:59 +00:00
|
|
|
obj.msg(message, from_obj=from_obj, data=data)
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2010-12-07 02:34:59 +00:00
|
|
|
def emit_to_contents(self, message, exclude=None, from_obj=None, data=None):
|
2010-08-29 18:46:58 +00:00
|
|
|
"Deprecated. Alias for msg_contents"
|
2011-03-15 16:08:32 +00:00
|
|
|
logger.log_depmsg("emit_to_contents() is deprecated. Use msg_contents() instead.")
|
2010-12-07 02:34:59 +00:00
|
|
|
self.msg_contents(message, exclude=exclude, from_obj=from_obj, data=data)
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def move_to(self, destination, quiet=False,
|
2012-10-23 22:31:51 +02:00
|
|
|
emit_to_obj=None, use_destination=True, to_none=False):
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Moves this object to a new location.
|
2012-03-24 18:25:32 +01:00
|
|
|
|
|
|
|
|
Moves this object to a new location. Note that if <destination> is an
|
|
|
|
|
exit object (i.e. it has "destination"!=None), the move_to will
|
|
|
|
|
happen to this destination and -not- into the exit object itself, unless
|
|
|
|
|
use_destination=False. Note that no lock checks are done by this function,
|
2012-03-30 23:47:22 +02:00
|
|
|
such things are assumed to have been handled before calling move_to.
|
|
|
|
|
|
2011-02-14 17:18:31 +00:00
|
|
|
destination: (Object) Reference to the object to move to. This
|
2011-04-08 23:10:04 +00:00
|
|
|
can also be an exit object, in which case the destination
|
2012-03-30 23:47:22 +02:00
|
|
|
property is used as destination.
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
quiet: (bool) If true, don't emit left/arrived messages.
|
2010-08-29 18:46:58 +00:00
|
|
|
emit_to_obj: (Object) object to receive error messages
|
2012-03-24 18:25:32 +01:00
|
|
|
use_destination (bool): Default is for objects to use the "destination" property
|
|
|
|
|
of destinations as the target to move to. Turning off this
|
2012-03-30 23:47:22 +02:00
|
|
|
keyword allows objects to move "inside" exit objects.
|
2012-10-23 22:31:51 +02:00
|
|
|
to_none - allow destination to be None. Note that no hooks are run when moving
|
|
|
|
|
to a None location. If you want to run hooks, run them manually.
|
2012-03-24 18:25:32 +01:00
|
|
|
|
|
|
|
|
Returns True/False depending on if there were problems with the move. This method
|
2012-03-30 23:47:22 +02:00
|
|
|
may also return various error messages to the emit_to_obj.
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
"""
|
2011-06-26 14:35:02 +00:00
|
|
|
def logerr(string=""):
|
|
|
|
|
trc = traceback.format_exc()
|
|
|
|
|
errstring = "%s%s" % (trc, string)
|
|
|
|
|
logger.log_trace()
|
2012-09-20 23:18:52 +02:00
|
|
|
_GA(self, "msg")(errstring)
|
2011-06-26 14:35:02 +00:00
|
|
|
|
2012-06-14 08:56:57 +02:00
|
|
|
errtxt = _("Couldn't perform move ('%s'). Contact an admin.")
|
2010-08-29 18:46:58 +00:00
|
|
|
if not emit_to_obj:
|
|
|
|
|
emit_to_obj = self
|
|
|
|
|
|
|
|
|
|
if not destination:
|
2012-10-23 22:31:51 +02:00
|
|
|
if to_none:
|
|
|
|
|
# immediately move to None. There can be no hooks called since
|
|
|
|
|
# there is no destination to call them with.
|
|
|
|
|
self.location = None
|
|
|
|
|
return True
|
2012-06-14 08:56:57 +02:00
|
|
|
emit_to_obj.msg(_("The destination doesn't exist."))
|
2012-03-30 23:47:22 +02:00
|
|
|
return
|
2012-04-15 22:04:15 +02:00
|
|
|
if destination.destination and use_destination:
|
2011-02-14 17:18:31 +00:00
|
|
|
# traverse exits
|
2011-04-08 23:10:04 +00:00
|
|
|
destination = destination.destination
|
2009-12-20 20:51:26 +00:00
|
|
|
|
2009-10-24 03:49:14 +00:00
|
|
|
# Before the move, call eventual pre-commands.
|
2009-12-20 20:51:26 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
if not self.at_before_move(destination):
|
2009-12-20 20:51:26 +00:00
|
|
|
return
|
2010-08-29 18:46:58 +00:00
|
|
|
except Exception:
|
2011-06-26 14:35:02 +00:00
|
|
|
logerr(errtxt % "at_before_move()")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "at_before_move()")
|
|
|
|
|
#logger.log_trace()
|
2010-08-29 18:46:58 +00:00
|
|
|
return False
|
2012-03-30 23:47:22 +02:00
|
|
|
|
|
|
|
|
# Save the old location
|
2012-09-20 23:18:52 +02:00
|
|
|
source_location = _GA(self, "location")
|
2010-08-29 18:46:58 +00:00
|
|
|
if not source_location:
|
|
|
|
|
# there was some error in placing this room.
|
|
|
|
|
# we have to set one or we won't be able to continue
|
2012-09-20 23:18:52 +02:00
|
|
|
if _GA(self, "home"):
|
|
|
|
|
source_location = _GA(self, "home")
|
2010-08-29 18:46:58 +00:00
|
|
|
else:
|
2011-08-06 19:39:06 +00:00
|
|
|
default_home = ObjectDB.objects.get_id(settings.CHARACTER_DEFAULT_HOME)
|
2010-08-29 18:46:58 +00:00
|
|
|
source_location = default_home
|
|
|
|
|
|
|
|
|
|
# Call hook on source location
|
|
|
|
|
try:
|
|
|
|
|
source_location.at_object_leave(self, destination)
|
|
|
|
|
except Exception:
|
2011-06-26 14:35:02 +00:00
|
|
|
logerr(errtxt % "at_object_leave()")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "at_object_leave()")
|
|
|
|
|
#logger.log_trace()
|
2010-08-29 18:46:58 +00:00
|
|
|
return False
|
2012-03-30 23:47:22 +02:00
|
|
|
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
if not quiet:
|
2009-09-19 15:18:42 +00:00
|
|
|
#tell the old room we are leaving
|
2009-12-20 20:51:26 +00:00
|
|
|
try:
|
2012-03-30 23:47:22 +02:00
|
|
|
self.announce_move_from(destination)
|
2010-08-29 18:46:58 +00:00
|
|
|
except Exception:
|
2012-03-30 23:47:22 +02:00
|
|
|
logerr(errtxt % "at_announce_move()")
|
2011-06-26 14:35:02 +00:00
|
|
|
#emit_to_obj.msg(errtxt % "at_announce_move()" )
|
|
|
|
|
#logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
2011-04-24 11:26:51 +00:00
|
|
|
|
2009-10-24 03:49:14 +00:00
|
|
|
# Perform move
|
2010-08-29 18:46:58 +00:00
|
|
|
try:
|
2012-09-20 23:18:52 +02:00
|
|
|
_SA(self, "location", destination)
|
2010-08-29 18:46:58 +00:00
|
|
|
except Exception:
|
|
|
|
|
emit_to_obj.msg(errtxt % "location change")
|
|
|
|
|
logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
|
|
|
|
|
basicobject.py
---------------
- Checks for NULL description on objects- if Null, it doesn't print the extra line any more.
- Made the checks for contents a little less ambiguous
cmdhandler.py
--------------
- Added new method 'parse_command' which takes a command string and tries to break it up based on common command parsing rules. Mostly complete, but could use some work on the edge cases. Check out the docstring on the function- I tried to make it fairly well documented.
- Changed the check for 'non-standard characters' to just return, rather than throw an Exception. Not sure if this causes any issues, but I noticed that when you hit enter without entering a command it would trigger this code. Now it just fails silently.
- The handle function now calls the parse_command function now and stores the results in parsed_input['parsed_command']. This then gets put into cdat['uinput'] at the end of handle() like before. The old data in parsed_input is still there, this is just a new field.
- Added cdat['raw_input'] to pass the full, untouched command string on. This is also stored in parsed_input['parsed_command']['raw_command'] so not sure fi this is necessary any longer, probably not.
cmdtable.py
------------
- Just cleaned it up a bit and straightened out the columns after changing 3-4 space indentation.
apps/objects/models.py
-----------------------
- set_description now sets the description attribute to 'None' (or Null in the db) when given a blank description. This is used for the change mentioned above in basicobject.py
- get_description now returns None if self.description is None
- used defines_global in the comparison methods like is_player
functions_db.py
----------------
- Changed import defines_global as defines_global to just 'import defines_global'- wasn't sure why this was this way, if I broke something (I didn't seem to) let me know.
- renamed player_search to player_name_search. Removed the use of local_and_global_search inside of it. local_and_global_search now calls it when it receives a search_string that starts with *.
- alias_search now only looks at attributes with attr_name == ALIAS. It used to just look at attr_value, which could match anything, it seemed.
- added 'dbref_search'
- local_and_global_search changes:
- Now uses dbref_search & player_search if the string starts with "#" or "*" respectively
- Changed when it uses dbref_search to whenever the search_string is a dbref. It used to check that it was a dbref, and that search_contents & search_location were set, but I *believe* in most MU*'s when you supply a dbref it never fails to find the object.
commands/unloggedin.py
-----------------------
- removed hardcoded object type #'s and started using defines_global instead
- when creating a new account, made sure that no object with an alias matching the player name requested exists. This is behavior from TinyMUSH, and I think most MUSHs follow this, but if not this is easy enough to change back.
commands/general.py
--------------------
- Rewrote cmd_page:
- New Features
- Page by dbref
- Page multiple people
- pose (:) and no space pose (;) pages
- When someone hits page without a target or data, it now will tell the player who they last paged, or say they haven't paged anyone if they don't have a LASTPAGED
- uses parse_command, made it a lot easier to work through the extra functionality added above
- When there are multiple words in a page target, it first tries to find a player that matches the entire string. If that fails, then it goes through each word, assuming each is a separate target, and works out paging them.
commands/objmanip.py
---------------------
- I started to muck with cmd_name & cmd_page, but decided to hold off for now. Largely, if everyone is cool with the idea that names & aliases should be totally unique, then we need to go ahead and re-write these. I'll do that if everyone is cool with it.
2008-06-13 18:15:54 +00:00
|
|
|
if not quiet:
|
2012-03-30 23:47:22 +02:00
|
|
|
# Tell the new room we are there.
|
2009-12-20 20:51:26 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
self.announce_move_to(source_location)
|
|
|
|
|
except Exception:
|
2011-06-26 14:35:02 +00:00
|
|
|
logerr(errtxt % "announce_move_to()")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "announce_move_to()")
|
|
|
|
|
#logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
|
|
|
|
|
2011-06-26 14:35:02 +00:00
|
|
|
# Perform eventual extra commands on the receiving location
|
|
|
|
|
# (the object has already arrived at this point)
|
|
|
|
|
try:
|
|
|
|
|
destination.at_object_receive(self, source_location)
|
|
|
|
|
except Exception:
|
|
|
|
|
logerr(errtxt % "at_object_receive()")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "at_object_receive()")
|
|
|
|
|
#logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
2011-06-26 14:35:02 +00:00
|
|
|
|
2009-10-24 03:49:14 +00:00
|
|
|
# Execute eventual extra commands on this object after moving it
|
2010-08-29 18:46:58 +00:00
|
|
|
# (usually calling 'look')
|
2009-12-20 20:51:26 +00:00
|
|
|
try:
|
2010-08-29 18:46:58 +00:00
|
|
|
self.at_after_move(source_location)
|
|
|
|
|
except Exception:
|
2011-06-26 14:35:02 +00:00
|
|
|
logerr(errtxt % "at_after_move")
|
|
|
|
|
#emit_to_obj.msg(errtxt % "at_after_move()")
|
|
|
|
|
#logger.log_trace()
|
2012-03-30 23:47:22 +02:00
|
|
|
return False
|
|
|
|
|
return True
|
2009-08-16 01:18:58 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
#
|
2012-03-30 23:47:22 +02:00
|
|
|
# Object Swap, Delete and Cleanup methods
|
|
|
|
|
#
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def clear_exits(self):
|
2009-12-03 00:41:53 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Destroys all of the exits and any exits pointing to this
|
|
|
|
|
object as a destination.
|
2009-12-03 00:41:53 +00:00
|
|
|
"""
|
2011-09-03 10:22:19 +00:00
|
|
|
for out_exit in [exi for exi in ObjectDB.objects.get_contents(self) if exi.db_destination]:
|
2010-08-29 18:46:58 +00:00
|
|
|
out_exit.delete()
|
2011-04-08 23:10:04 +00:00
|
|
|
for in_exit in ObjectDB.objects.filter(db_destination=self):
|
2010-08-29 18:46:58 +00:00
|
|
|
in_exit.delete()
|
2009-12-03 00:41:53 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
def clear_contents(self):
|
2009-12-03 00:41:53 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
Moves all objects (players/things) to their home
|
2012-03-30 23:47:22 +02:00
|
|
|
location or to default home.
|
2009-12-03 00:41:53 +00:00
|
|
|
"""
|
2010-08-29 18:46:58 +00:00
|
|
|
# Gather up everything that thinks this is its location.
|
|
|
|
|
objs = ObjectDB.objects.filter(db_location=self)
|
2012-10-14 16:24:21 +02:00
|
|
|
default_home_id = int(settings.CHARACTER_DEFAULT_HOME.lstrip("#"))
|
2010-08-29 18:46:58 +00:00
|
|
|
try:
|
|
|
|
|
default_home = ObjectDB.objects.get(id=default_home_id)
|
2012-09-20 23:18:52 +02:00
|
|
|
if default_home.dbid == _GA(self, "dbid"):
|
2011-11-05 21:19:57 +01:00
|
|
|
# we are deleting default home!
|
2012-03-30 23:47:22 +02:00
|
|
|
default_home = None
|
2010-08-29 18:46:58 +00:00
|
|
|
except Exception:
|
2012-06-14 08:56:57 +02:00
|
|
|
string = _("Could not find default home '(#%d)'.")
|
2010-08-29 18:46:58 +00:00
|
|
|
logger.log_errmsg(string % default_home_id)
|
2012-03-30 23:47:22 +02:00
|
|
|
default_home = None
|
2010-08-29 18:46:58 +00:00
|
|
|
|
2012-03-30 23:47:22 +02:00
|
|
|
for obj in objs:
|
|
|
|
|
home = obj.home
|
2010-08-29 18:46:58 +00:00
|
|
|
# Obviously, we can't send it back to here.
|
2012-09-20 23:18:52 +02:00
|
|
|
if not home or (home and home.dbid == _GA(self, "dbid")):
|
2012-03-30 23:47:22 +02:00
|
|
|
obj.home = default_home
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# If for some reason it's still None...
|
2011-11-05 21:19:57 +01:00
|
|
|
if not obj.home:
|
2010-08-29 18:46:58 +00:00
|
|
|
string = "Missing default home, '%s(#%d)' "
|
|
|
|
|
string += "now has a null location."
|
2012-03-30 23:47:22 +02:00
|
|
|
obj.location = None
|
2012-06-14 08:56:57 +02:00
|
|
|
obj.msg(_("Something went wrong! You are dumped into nowhere. Contact an admin."))
|
2012-04-26 17:47:25 +02:00
|
|
|
logger.log_errmsg(string % (obj.name, obj.dbid))
|
2012-03-30 23:47:22 +02:00
|
|
|
return
|
|
|
|
|
|
2011-11-05 21:19:57 +01:00
|
|
|
if obj.has_player:
|
2012-03-30 23:47:22 +02:00
|
|
|
if home:
|
2010-08-29 18:46:58 +00:00
|
|
|
string = "Your current location has ceased to exist,"
|
|
|
|
|
string += " moving you to %s(#%d)."
|
2012-06-14 08:56:57 +02:00
|
|
|
obj.msg(_(string) % (home.name, home.dbid))
|
2010-08-29 18:46:58 +00:00
|
|
|
else:
|
|
|
|
|
# Famous last words: The player should never see this.
|
|
|
|
|
string = "This place should not exist ... contact an admin."
|
2012-06-14 08:56:57 +02:00
|
|
|
obj.msg(_(string))
|
2010-08-29 18:46:58 +00:00
|
|
|
obj.move_to(home)
|
2009-05-01 15:34:43 +00:00
|
|
|
|
2011-05-01 18:04:15 +00:00
|
|
|
def copy(self, new_key=None):
|
2012-03-30 23:47:22 +02:00
|
|
|
"""
|
2012-03-24 18:25:32 +01:00
|
|
|
Makes an identical copy of this object. If you want to customize the copy by
|
|
|
|
|
changing some settings, use ObjectDB.object.copy_object() directly.
|
|
|
|
|
|
|
|
|
|
new_key (string) - new key/name of copied object. If new_key is not specified, the copy will be named
|
2012-03-30 23:47:22 +02:00
|
|
|
<old_key>_copy by default.
|
|
|
|
|
Returns: Object (copy of this one)
|
2011-05-01 18:04:15 +00:00
|
|
|
"""
|
2012-09-11 23:47:29 +02:00
|
|
|
def find_clone_key():
|
|
|
|
|
"""
|
|
|
|
|
Append 01, 02 etc to obj.key. Checks next higher number in the
|
|
|
|
|
same location, then adds the next number available
|
|
|
|
|
|
|
|
|
|
returns the new clone name on the form keyXX
|
|
|
|
|
"""
|
2012-09-20 23:18:52 +02:00
|
|
|
key = _GA(self, "key")
|
2012-09-11 23:47:29 +02:00
|
|
|
num = 1
|
2012-10-14 16:31:22 +02:00
|
|
|
for obj in (obj for obj in self.location.contents
|
2012-09-11 23:47:29 +02:00
|
|
|
if obj.key.startswith(key) and obj.key.lstrip(key).isdigit()):
|
|
|
|
|
num += 1
|
2012-10-14 16:31:22 +02:00
|
|
|
return "%s%03i" % (key, num)
|
|
|
|
|
new_key = new_key or find_clone_key()
|
2011-05-01 18:04:15 +00:00
|
|
|
return ObjectDB.objects.copy_object(self, new_key=new_key)
|
|
|
|
|
|
2011-09-03 10:22:19 +00:00
|
|
|
delete_iter = 0
|
2012-03-30 23:47:22 +02:00
|
|
|
def delete(self):
|
2009-10-14 18:15:15 +00:00
|
|
|
"""
|
2012-03-30 23:47:22 +02:00
|
|
|
Deletes this object.
|
2010-08-29 18:46:58 +00:00
|
|
|
Before deletion, this method makes sure to move all contained
|
|
|
|
|
objects to their respective home locations, as well as clean
|
|
|
|
|
up all exits to/from the object.
|
2009-05-01 15:34:43 +00:00
|
|
|
"""
|
2013-02-18 20:08:05 +01:00
|
|
|
global _ScriptDB
|
|
|
|
|
if not _ScriptDB:
|
|
|
|
|
from src.scripts.models import ScriptDB as _ScriptDB
|
|
|
|
|
|
2012-09-20 23:18:52 +02:00
|
|
|
if _GA(self, "delete_iter") > 0:
|
2011-09-03 10:22:19 +00:00
|
|
|
# make sure to only call delete once on this object
|
|
|
|
|
# (avoid recursive loops)
|
|
|
|
|
return False
|
2011-08-06 18:15:04 +00:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
if not self.at_object_delete():
|
|
|
|
|
# this is an extra pre-check
|
|
|
|
|
# run before deletion mechanism
|
2012-03-30 23:47:22 +02:00
|
|
|
# is kicked into gear.
|
2012-09-20 23:18:52 +02:00
|
|
|
_SA(self, "delete_iter", 0)
|
2009-10-20 22:21:01 +00:00
|
|
|
return False
|
2009-05-01 15:34:43 +00:00
|
|
|
|
2011-09-03 10:22:19 +00:00
|
|
|
self.delete_iter += 1
|
|
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# See if we need to kick the player off.
|
2011-04-23 11:54:08 +00:00
|
|
|
|
2012-09-20 23:18:52 +02:00
|
|
|
for session in _GA(self, "sessions"):
|
|
|
|
|
session.msg(_("Your character %s has been destroyed.") % _GA(self, "key"))
|
2012-03-30 23:47:22 +02:00
|
|
|
# no need to disconnect, Player just jumps to OOC mode.
|
2011-04-23 11:54:08 +00:00
|
|
|
# sever the connection (important!)
|
2012-09-20 23:18:52 +02:00
|
|
|
if _GA(self, 'player'):
|
|
|
|
|
_SA(_GA(self, "player"), "character", None)
|
|
|
|
|
_SA(self, "player", None)
|
2011-08-11 21:16:35 +00:00
|
|
|
|
2013-02-18 20:08:05 +01:00
|
|
|
for script in _ScriptDB.objects.get_all_scripts_on_obj(self):
|
2011-08-11 21:16:35 +00:00
|
|
|
script.stop()
|
2013-02-18 20:08:05 +01:00
|
|
|
#for script in _GA(self, "scripts").all():
|
|
|
|
|
# script.stop()
|
2012-03-30 23:47:22 +02:00
|
|
|
|
2010-08-29 18:46:58 +00:00
|
|
|
# if self.player:
|
2012-03-30 23:47:22 +02:00
|
|
|
# self.player.user.is_active = False
|
2011-11-05 21:19:57 +01:00
|
|
|
# self.player.user.save(
|
2010-08-29 18:46:58 +00:00
|
|
|
|
|
|
|
|
# Destroy any exits to and from this room, if any
|
2012-09-20 23:18:52 +02:00
|
|
|
_GA(self, "clear_exits")()
|
2010-08-29 18:46:58 +00:00
|
|
|
# Clear out any non-exit objects located within the object
|
2012-09-20 23:18:52 +02:00
|
|
|
_GA(self, "clear_contents")()
|
2012-11-01 11:20:07 +01:00
|
|
|
old_loc = _GA(self, "location")
|
2010-08-29 18:46:58 +00:00
|
|
|
# Perform the deletion of the object
|
|
|
|
|
super(ObjectDB, self).delete()
|
2012-11-01 11:20:07 +01:00
|
|
|
# clear object's old location's content cache of this object
|
|
|
|
|
if old_loc:
|
|
|
|
|
old_loc.contents_update()
|
2012-03-30 23:47:22 +02:00
|
|
|
return True
|