Further cleanup of source; making class methods _private for clarity in the API.
This commit is contained in:
parent
fc156b5a54
commit
c8df141e89
18 changed files with 607 additions and 588 deletions
|
|
@ -808,4 +808,3 @@ class ExternalChannelConnection(SharedMemoryModel):
|
||||||
exec(to_str(self.external_send_code))
|
exec(to_str(self.external_send_code))
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.log_trace("Channel %s could not send to External %s" % (self.channel, self.external_key))
|
logger.log_trace("Channel %s could not send to External %s" % (self.channel, self.external_key))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ Custom manager for HelpEntry objects.
|
||||||
"""
|
"""
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from src.utils import logger, utils
|
from src.utils import logger, utils
|
||||||
|
__all__ = ("HelpEntryManager",)
|
||||||
|
|
||||||
class HelpEntryManager(models.Manager):
|
class HelpEntryManager(models.Manager):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ from src.help.manager import HelpEntryManager
|
||||||
from src.utils import ansi
|
from src.utils import ansi
|
||||||
from src.locks.lockhandler import LockHandler
|
from src.locks.lockhandler import LockHandler
|
||||||
from src.utils.utils import is_iter
|
from src.utils.utils import is_iter
|
||||||
|
__all__ = ("HelpEntry",)
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
|
@ -32,6 +33,9 @@ class HelpEntry(SharedMemoryModel):
|
||||||
entrytext - the actual help text
|
entrytext - the actual help text
|
||||||
permissions - perm strings
|
permissions - perm strings
|
||||||
|
|
||||||
|
Method:
|
||||||
|
access
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -78,88 +82,88 @@ class HelpEntry(SharedMemoryModel):
|
||||||
|
|
||||||
# key property (wraps db_key)
|
# key property (wraps db_key)
|
||||||
#@property
|
#@property
|
||||||
def key_get(self):
|
def __key_get(self):
|
||||||
"Getter. Allows for value = self.key"
|
"Getter. Allows for value = self.key"
|
||||||
return self.db_key
|
return self.db_key
|
||||||
#@key.setter
|
#@key.setter
|
||||||
def key_set(self, value):
|
def __key_set(self, value):
|
||||||
"Setter. Allows for self.key = value"
|
"Setter. Allows for self.key = value"
|
||||||
self.db_key = value
|
self.db_key = value
|
||||||
self.save()
|
self.save()
|
||||||
#@key.deleter
|
#@key.deleter
|
||||||
def key_del(self):
|
def __key_del(self):
|
||||||
"Deleter. Allows for del self.key. Deletes entry."
|
"Deleter. Allows for del self.key. Deletes entry."
|
||||||
self.delete()
|
self.delete()
|
||||||
key = property(key_get, key_set, key_del)
|
key = property(__key_get, __key_set, __key_del)
|
||||||
|
|
||||||
# help_category property (wraps db_help_category)
|
# help_category property (wraps db_help_category)
|
||||||
#@property
|
#@property
|
||||||
def help_category_get(self):
|
def __help_category_get(self):
|
||||||
"Getter. Allows for value = self.help_category"
|
"Getter. Allows for value = self.help_category"
|
||||||
return self.db_help_category
|
return self.db_help_category
|
||||||
#@help_category.setter
|
#@help_category.setter
|
||||||
def help_category_set(self, value):
|
def __help_category_set(self, value):
|
||||||
"Setter. Allows for self.help_category = value"
|
"Setter. Allows for self.help_category = value"
|
||||||
self.db_help_category = value
|
self.db_help_category = value
|
||||||
self.save()
|
self.save()
|
||||||
#@help_category.deleter
|
#@help_category.deleter
|
||||||
def help_category_del(self):
|
def __help_category_del(self):
|
||||||
"Deleter. Allows for del self.help_category"
|
"Deleter. Allows for del self.help_category"
|
||||||
self.db_help_category = "General"
|
self.db_help_category = "General"
|
||||||
self.save()
|
self.save()
|
||||||
help_category = property(help_category_get, help_category_set, help_category_del)
|
help_category = property(__help_category_get, __help_category_set, __help_category_del)
|
||||||
|
|
||||||
# entrytext property (wraps db_entrytext)
|
# entrytext property (wraps db_entrytext)
|
||||||
#@property
|
#@property
|
||||||
def entrytext_get(self):
|
def __entrytext_get(self):
|
||||||
"Getter. Allows for value = self.entrytext"
|
"Getter. Allows for value = self.entrytext"
|
||||||
return self.db_entrytext
|
return self.db_entrytext
|
||||||
#@entrytext.setter
|
#@entrytext.setter
|
||||||
def entrytext_set(self, value):
|
def __entrytext_set(self, value):
|
||||||
"Setter. Allows for self.entrytext = value"
|
"Setter. Allows for self.entrytext = value"
|
||||||
self.db_entrytext = value
|
self.db_entrytext = value
|
||||||
self.save()
|
self.save()
|
||||||
#@entrytext.deleter
|
#@entrytext.deleter
|
||||||
def entrytext_del(self):
|
def __entrytext_del(self):
|
||||||
"Deleter. Allows for del self.entrytext"
|
"Deleter. Allows for del self.entrytext"
|
||||||
self.db_entrytext = ""
|
self.db_entrytext = ""
|
||||||
self.save()
|
self.save()
|
||||||
entrytext = property(entrytext_get, entrytext_set, entrytext_del)
|
entrytext = property(__entrytext_get, __entrytext_set, __entrytext_del)
|
||||||
|
|
||||||
# permissions property
|
# permissions property
|
||||||
#@property
|
#@property
|
||||||
def permissions_get(self):
|
def __permissions_get(self):
|
||||||
"Getter. Allows for value = self.permissions. Returns a list of permissions."
|
"Getter. Allows for value = self.permissions. Returns a list of permissions."
|
||||||
return [perm.strip() for perm in self.db_permissions.split(',')]
|
return [perm.strip() for perm in self.db_permissions.split(',')]
|
||||||
#@permissions.setter
|
#@permissions.setter
|
||||||
def permissions_set(self, value):
|
def __permissions_set(self, value):
|
||||||
"Setter. Allows for self.permissions = value. Stores as a comma-separated string."
|
"Setter. Allows for self.permissions = value. Stores as a comma-separated string."
|
||||||
if is_iter(value):
|
if is_iter(value):
|
||||||
value = ",".join([str(val).strip().lower() for val in value])
|
value = ",".join([str(val).strip().lower() for val in value])
|
||||||
self.db_permissions = value
|
self.db_permissions = value
|
||||||
self.save()
|
self.save()
|
||||||
#@permissions.deleter
|
#@permissions.deleter
|
||||||
def permissions_del(self):
|
def __permissions_del(self):
|
||||||
"Deleter. Allows for del self.permissions"
|
"Deleter. Allows for del self.permissions"
|
||||||
self.db_permissions = ""
|
self.db_permissions = ""
|
||||||
self.save()
|
self.save()
|
||||||
permissions = property(permissions_get, permissions_set, permissions_del)
|
permissions = property(__permissions_get, __permissions_set, __permissions_del)
|
||||||
|
|
||||||
# lock_storage property (wraps db_lock_storage)
|
# lock_storage property (wraps db_lock_storage)
|
||||||
#@property
|
#@property
|
||||||
def lock_storage_get(self):
|
def __lock_storage_get(self):
|
||||||
"Getter. Allows for value = self.lock_storage"
|
"Getter. Allows for value = self.lock_storage"
|
||||||
return self.db_lock_storage
|
return self.db_lock_storage
|
||||||
#@nick.setter
|
#@nick.setter
|
||||||
def lock_storage_set(self, value):
|
def __lock_storage_set(self, value):
|
||||||
"""Saves the lock_storagetodate. This is usually not called directly, but through self.lock()"""
|
"""Saves the lock_storagetodate. This is usually not called directly, but through self.lock()"""
|
||||||
self.db_lock_storage = value
|
self.db_lock_storage = value
|
||||||
self.save()
|
self.save()
|
||||||
#@nick.deleter
|
#@nick.deleter
|
||||||
def lock_storage_del(self):
|
def __lock_storage_del(self):
|
||||||
"Deleter is disabled. Use the lockhandler.delete (self.lock.delete) instead"""
|
"Deleter is disabled. Use the lockhandler.delete (self.lock.delete) instead"""
|
||||||
logger.log_errmsg("Lock_Storage (on %s) cannot be deleted. Use obj.lock.delete() instead." % self)
|
logger.log_errmsg("Lock_Storage (on %s) cannot be deleted. Use obj.lock.delete() instead." % self)
|
||||||
lock_storage = property(lock_storage_get, lock_storage_set, lock_storage_del)
|
lock_storage = property(__lock_storage_get, __lock_storage_set, __lock_storage_del)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ from django.conf import settings
|
||||||
from src.utils import search
|
from src.utils import search
|
||||||
from src.utils import utils
|
from src.utils import utils
|
||||||
|
|
||||||
PERMISSION_HIERARCHY = [p.lower() for p in settings.PERMISSION_HIERARCHY]
|
_PERMISSION_HIERARCHY = [p.lower() for p in settings.PERMISSION_HIERARCHY]
|
||||||
|
|
||||||
def _to_player(accessing_obj):
|
def _to_player(accessing_obj):
|
||||||
"Helper function. Makes sure an accessing object is a player object"
|
"Helper function. Makes sure an accessing object is a player object"
|
||||||
|
|
@ -117,7 +117,7 @@ def perm(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
|
|
||||||
where <permission> is the permission accessing_obj must
|
where <permission> is the permission accessing_obj must
|
||||||
have in order to pass the lock. If the given permission
|
have in order to pass the lock. If the given permission
|
||||||
is part of PERMISSION_HIERARCHY, permission is also granted
|
is part of _PERMISSION_HIERARCHY, permission is also granted
|
||||||
to all ranks higher up in the hierarchy.
|
to all ranks higher up in the hierarchy.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
|
@ -129,10 +129,10 @@ def perm(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
if perm in permissions:
|
if perm in permissions:
|
||||||
# simplest case - we have a direct match
|
# simplest case - we have a direct match
|
||||||
return True
|
return True
|
||||||
if perm in PERMISSION_HIERARCHY:
|
if perm in _PERMISSION_HIERARCHY:
|
||||||
# check if we have a higher hierarchy position
|
# check if we have a higher hierarchy position
|
||||||
ppos = PERMISSION_HIERARCHY.index(perm)
|
ppos = _PERMISSION_HIERARCHY.index(perm)
|
||||||
return any(1 for hpos, hperm in enumerate(PERMISSION_HIERARCHY)
|
return any(1 for hpos, hperm in enumerate(_PERMISSION_HIERARCHY)
|
||||||
if hperm in permissions and hpos > ppos)
|
if hperm in permissions and hpos > ppos)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -148,9 +148,9 @@ def perm_above(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if perm in PERMISSION_HIERARCHY:
|
if perm in _PERMISSION_HIERARCHY:
|
||||||
ppos = PERMISSION_HIERARCHY.index(perm)
|
ppos = _PERMISSION_HIERARCHY.index(perm)
|
||||||
return any(1 for hpos, hperm in enumerate(PERMISSION_HIERARCHY)
|
return any(1 for hpos, hperm in enumerate(_PERMISSION_HIERARCHY)
|
||||||
if hperm in [p.lower() for p in accessing_obj.permissions] and hpos > ppos)
|
if hperm in [p.lower() for p in accessing_obj.permissions] and hpos > ppos)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ def pperm(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
|
|
||||||
where <permission> is the permission accessing_obj must
|
where <permission> is the permission accessing_obj must
|
||||||
have in order to pass the lock. If the given permission
|
have in order to pass the lock. If the given permission
|
||||||
is part of PERMISSION_HIERARCHY, permission is also granted
|
is part of _PERMISSION_HIERARCHY, permission is also granted
|
||||||
to all ranks higher up in the hierarchy.
|
to all ranks higher up in the hierarchy.
|
||||||
"""
|
"""
|
||||||
return perm(_to_player(accessing_obj), accessed_obj, *args, **kwargs)
|
return perm(_to_player(accessing_obj), accessed_obj, *args, **kwargs)
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ to any other identifier you can use.
|
||||||
import re, inspect
|
import re, inspect
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from src.utils import logger, utils
|
from src.utils import logger, utils
|
||||||
|
__all__ = ("LockHandler", )
|
||||||
#
|
#
|
||||||
# Exception class
|
# Exception class
|
||||||
#
|
#
|
||||||
|
|
@ -120,17 +120,17 @@ class LockException(Exception):
|
||||||
# Cached lock functions
|
# Cached lock functions
|
||||||
#
|
#
|
||||||
|
|
||||||
LOCKFUNCS = {}
|
_LOCKFUNCS = {}
|
||||||
def cache_lockfuncs():
|
def _cache_lockfuncs():
|
||||||
"Updates the cache."
|
"Updates the cache."
|
||||||
global LOCKFUNCS
|
global _LOCKFUNCS
|
||||||
LOCKFUNCS = {}
|
_LOCKFUNCS = {}
|
||||||
for modulepath in settings.LOCK_FUNC_MODULES:
|
for modulepath in settings.LOCK_FUNC_MODULES:
|
||||||
modulepath = utils.pypath_to_realpath(modulepath)
|
modulepath = utils.pypath_to_realpath(modulepath)
|
||||||
mod = utils.mod_import(modulepath)
|
mod = utils.mod_import(modulepath)
|
||||||
if mod:
|
if mod:
|
||||||
for tup in (tup for tup in inspect.getmembers(mod) if callable(tup[1])):
|
for tup in (tup for tup in inspect.getmembers(mod) if callable(tup[1])):
|
||||||
LOCKFUNCS[tup[0]] = tup[1]
|
_LOCKFUNCS[tup[0]] = tup[1]
|
||||||
else:
|
else:
|
||||||
logger.log_errmsg("Couldn't load %s from PERMISSION_FUNC_MODULES." % modulepath)
|
logger.log_errmsg("Couldn't load %s from PERMISSION_FUNC_MODULES." % modulepath)
|
||||||
|
|
||||||
|
|
@ -138,9 +138,9 @@ def cache_lockfuncs():
|
||||||
# pre-compiled regular expressions
|
# pre-compiled regular expressions
|
||||||
#
|
#
|
||||||
|
|
||||||
RE_FUNCS = re.compile(r"\w+\([^)]*\)")
|
_RE_FUNCS = re.compile(r"\w+\([^)]*\)")
|
||||||
RE_SEPS = re.compile(r"(?<=[ )])AND(?=\s)|(?<=[ )])OR(?=\s)|(?<=[ )])NOT(?=\s)")
|
_RE_SEPS = re.compile(r"(?<=[ )])AND(?=\s)|(?<=[ )])OR(?=\s)|(?<=[ )])NOT(?=\s)")
|
||||||
RE_OK = re.compile(r"%s|and|or|not")
|
_RE_OK = re.compile(r"%s|and|or|not")
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -160,8 +160,8 @@ class LockHandler(object):
|
||||||
Loads and pre-caches all relevant locks and their
|
Loads and pre-caches all relevant locks and their
|
||||||
functions.
|
functions.
|
||||||
"""
|
"""
|
||||||
if not LOCKFUNCS:
|
if not _LOCKFUNCS:
|
||||||
cache_lockfuncs()
|
_cache_lockfuncs()
|
||||||
self.obj = obj
|
self.obj = obj
|
||||||
self.locks = {}
|
self.locks = {}
|
||||||
self.log_obj = None
|
self.log_obj = None
|
||||||
|
|
@ -206,12 +206,12 @@ class LockHandler(object):
|
||||||
return locks
|
return locks
|
||||||
|
|
||||||
# parse the lock functions and separators
|
# parse the lock functions and separators
|
||||||
funclist = RE_FUNCS.findall(rhs)
|
funclist = _RE_FUNCS.findall(rhs)
|
||||||
evalstring = rhs.replace('AND','and').replace('OR','or').replace('NOT','not')
|
evalstring = rhs.replace('AND','and').replace('OR','or').replace('NOT','not')
|
||||||
nfuncs = len(funclist)
|
nfuncs = len(funclist)
|
||||||
for funcstring in funclist:
|
for funcstring in funclist:
|
||||||
funcname, rest = (part.strip().strip(')') for part in funcstring.split('(', 1))
|
funcname, rest = (part.strip().strip(')') for part in funcstring.split('(', 1))
|
||||||
func = LOCKFUNCS.get(funcname, None)
|
func = _LOCKFUNCS.get(funcname, None)
|
||||||
if not callable(func):
|
if not callable(func):
|
||||||
elist.append("Lock: function '%s' is not available." % funcstring)
|
elist.append("Lock: function '%s' is not available." % funcstring)
|
||||||
continue
|
continue
|
||||||
|
|
@ -223,7 +223,7 @@ class LockHandler(object):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
# purge the eval string of any superfluos items, then test it
|
# purge the eval string of any superfluos items, then test it
|
||||||
evalstring = " ".join(RE_OK.findall(evalstring))
|
evalstring = " ".join(_RE_OK.findall(evalstring))
|
||||||
eval(evalstring % tuple(True for func in funclist))
|
eval(evalstring % tuple(True for func in funclist))
|
||||||
except Exception:
|
except Exception:
|
||||||
elist.append("Lock: definition '%s' has syntax errors." % raw_lockstring)
|
elist.append("Lock: definition '%s' has syntax errors." % raw_lockstring)
|
||||||
|
|
@ -273,7 +273,7 @@ class LockHandler(object):
|
||||||
if rhs.count('(') != rhs.count(')'):
|
if rhs.count('(') != rhs.count(')'):
|
||||||
self._log_error("Lock: '%s' has mismatched parentheses." % lockdef)
|
self._log_error("Lock: '%s' has mismatched parentheses." % lockdef)
|
||||||
return False
|
return False
|
||||||
if not RE_FUNCS.findall(rhs):
|
if not _RE_FUNCS.findall(rhs):
|
||||||
self._log_error("Lock: '%s' has no valid lock functions." % lockdef)
|
self._log_error("Lock: '%s' has no valid lock functions." % lockdef)
|
||||||
return False
|
return False
|
||||||
# get the lock string
|
# get the lock string
|
||||||
|
|
@ -381,7 +381,7 @@ class LockHandler(object):
|
||||||
true_false = tuple(tup[0](accessing_obj, self.obj, *tup[1], **tup[2]) for tup in func_tup)
|
true_false = tuple(tup[0](accessing_obj, self.obj, *tup[1], **tup[2]) for tup in func_tup)
|
||||||
return eval(evalstring % true_false)
|
return eval(evalstring % true_false)
|
||||||
|
|
||||||
def test():
|
def _test():
|
||||||
# testing
|
# testing
|
||||||
|
|
||||||
class TestObj(object):
|
class TestObj(object):
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,11 @@ from src.utils import utils
|
||||||
from src.utils.utils import to_unicode
|
from src.utils.utils import to_unicode
|
||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
|
|
||||||
|
__all__ = ("ObjectManager",)
|
||||||
|
|
||||||
# Try to use a custom way to parse id-tagged multimatches.
|
# Try to use a custom way to parse id-tagged multimatches.
|
||||||
|
|
||||||
AT_MULTIMATCH_INPUT = utils.mod_import(*settings.SEARCH_AT_MULTIMATCH_INPUT.rsplit('.', 1))
|
_AT_MULTIMATCH_INPUT = utils.mod_import(*settings.SEARCH_AT_MULTIMATCH_INPUT.rsplit('.', 1))
|
||||||
|
|
||||||
class ObjectManager(TypedObjectManager):
|
class ObjectManager(TypedObjectManager):
|
||||||
"""
|
"""
|
||||||
|
|
@ -288,7 +290,7 @@ class ObjectManager(TypedObjectManager):
|
||||||
matches = local_and_global_search(ostring, exact=True)
|
matches = local_and_global_search(ostring, exact=True)
|
||||||
if not matches:
|
if not matches:
|
||||||
# if we have no match, check if we are dealing with an "N-keyword" query - if so, strip it.
|
# if we have no match, check if we are dealing with an "N-keyword" query - if so, strip it.
|
||||||
match_number, ostring = AT_MULTIMATCH_INPUT(ostring)
|
match_number, ostring = _AT_MULTIMATCH_INPUT(ostring)
|
||||||
if match_number != None and ostring:
|
if match_number != None and ostring:
|
||||||
# Run search again, without match number:
|
# Run search again, without match number:
|
||||||
matches = local_and_global_search(ostring, exact=True)
|
matches = local_and_global_search(ostring, exact=True)
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ from src.scripts.scripthandler import ScriptHandler
|
||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
from src.utils.utils import make_iter, to_unicode, to_str, mod_import
|
from src.utils.utils import make_iter, to_unicode, to_str, mod_import
|
||||||
|
|
||||||
#PlayerDB = ContentType.objects.get(app_label="players", model="playerdb").model_class()
|
#__all__ = ("ObjAttribute", "Alias", "ObjectNick", "ObjectDB")
|
||||||
|
|
||||||
|
|
||||||
_AT_SEARCH_RESULT = mod_import(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
_AT_SEARCH_RESULT = mod_import(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
||||||
|
|
||||||
|
|
@ -211,7 +212,7 @@ class ObjectDB(TypedObject):
|
||||||
|
|
||||||
# aliases property (wraps (db_aliases)
|
# aliases property (wraps (db_aliases)
|
||||||
#@property
|
#@property
|
||||||
def aliases_get(self):
|
def __aliases_get(self):
|
||||||
"Getter. Allows for value = self.aliases"
|
"Getter. Allows for value = self.aliases"
|
||||||
try:
|
try:
|
||||||
return _GA(self, "_cached_aliases")
|
return _GA(self, "_cached_aliases")
|
||||||
|
|
@ -220,23 +221,23 @@ class ObjectDB(TypedObject):
|
||||||
_SA(self, "_cached_aliases", aliases)
|
_SA(self, "_cached_aliases", aliases)
|
||||||
return aliases
|
return aliases
|
||||||
#@aliases.setter
|
#@aliases.setter
|
||||||
def aliases_set(self, aliases):
|
def __aliases_set(self, aliases):
|
||||||
"Setter. Allows for self.aliases = value"
|
"Setter. Allows for self.aliases = value"
|
||||||
for alias in make_iter(aliases):
|
for alias in make_iter(aliases):
|
||||||
new_alias = Alias(db_key=alias, db_obj=self)
|
new_alias = Alias(db_key=alias, db_obj=self)
|
||||||
new_alias.save()
|
new_alias.save()
|
||||||
_SA(self, "_cached_aliases", aliases)
|
_SA(self, "_cached_aliases", aliases)
|
||||||
#@aliases.deleter
|
#@aliases.deleter
|
||||||
def aliases_del(self):
|
def __aliases_del(self):
|
||||||
"Deleter. Allows for del self.aliases"
|
"Deleter. Allows for del self.aliases"
|
||||||
for alias in Alias.objects.filter(db_obj=self):
|
for alias in Alias.objects.filter(db_obj=self):
|
||||||
alias.delete()
|
alias.delete()
|
||||||
_DA(self, "_cached_aliases")
|
_DA(self, "_cached_aliases")
|
||||||
aliases = property(aliases_get, aliases_set, aliases_del)
|
aliases = property(__aliases_get, __aliases_set, __aliases_del)
|
||||||
|
|
||||||
# player property (wraps db_player)
|
# player property (wraps db_player)
|
||||||
#@property
|
#@property
|
||||||
def player_get(self):
|
def __player_get(self):
|
||||||
"""
|
"""
|
||||||
Getter. Allows for value = self.player.
|
Getter. Allows for value = self.player.
|
||||||
We have to be careful here since Player is also
|
We have to be careful here since Player is also
|
||||||
|
|
@ -244,29 +245,29 @@ class ObjectDB(TypedObject):
|
||||||
"""
|
"""
|
||||||
return _get_cache(self, "player")
|
return _get_cache(self, "player")
|
||||||
#@player.setter
|
#@player.setter
|
||||||
def player_set(self, player):
|
def __player_set(self, player):
|
||||||
"Setter. Allows for self.player = value"
|
"Setter. Allows for self.player = value"
|
||||||
if isinstance(player, TypeClass):
|
if isinstance(player, TypeClass):
|
||||||
player = player.dbobj
|
player = player.dbobj
|
||||||
_set_cache(self, "player", player)
|
_set_cache(self, "player", player)
|
||||||
#@player.deleter
|
#@player.deleter
|
||||||
def player_del(self):
|
def __player_del(self):
|
||||||
"Deleter. Allows for del self.player"
|
"Deleter. Allows for del self.player"
|
||||||
self.db_player = None
|
self.db_player = None
|
||||||
self.save()
|
self.save()
|
||||||
_del_cache(self, "player")
|
_del_cache(self, "player")
|
||||||
player = property(player_get, player_set, player_del)
|
player = property(__player_get, __player_set, __player_del)
|
||||||
|
|
||||||
# location property (wraps db_location)
|
# location property (wraps db_location)
|
||||||
#@property
|
#@property
|
||||||
def location_get(self):
|
def __location_get(self):
|
||||||
"Getter. Allows for value = self.location."
|
"Getter. Allows for value = self.location."
|
||||||
loc = _get_cache(self, "location")
|
loc = _get_cache(self, "location")
|
||||||
if loc:
|
if loc:
|
||||||
return loc.typeclass
|
return loc.typeclass
|
||||||
return None
|
return None
|
||||||
#@location.setter
|
#@location.setter
|
||||||
def location_set(self, location):
|
def __location_set(self, location):
|
||||||
"Setter. Allows for self.location = location"
|
"Setter. Allows for self.location = location"
|
||||||
try:
|
try:
|
||||||
if location == None or type(location) == ObjectDB:
|
if location == None or type(location) == ObjectDB:
|
||||||
|
|
@ -289,23 +290,23 @@ class ObjectDB(TypedObject):
|
||||||
logger.log_trace(string)
|
logger.log_trace(string)
|
||||||
raise
|
raise
|
||||||
#@location.deleter
|
#@location.deleter
|
||||||
def location_del(self):
|
def __location_del(self):
|
||||||
"Deleter. Allows for del self.location"
|
"Deleter. Allows for del self.location"
|
||||||
self.db_location = None
|
self.db_location = None
|
||||||
self.save()
|
self.save()
|
||||||
_del_cache(self, "location")
|
_del_cache(self, "location")
|
||||||
location = property(location_get, location_set, location_del)
|
location = property(__location_get, __location_set, __location_del)
|
||||||
|
|
||||||
# home property (wraps db_home)
|
# home property (wraps db_home)
|
||||||
#@property
|
#@property
|
||||||
def home_get(self):
|
def __home_get(self):
|
||||||
"Getter. Allows for value = self.home"
|
"Getter. Allows for value = self.home"
|
||||||
home = _get_cache(self, "home")
|
home = _get_cache(self, "home")
|
||||||
if home:
|
if home:
|
||||||
return home.typeclass
|
return home.typeclass
|
||||||
return None
|
return None
|
||||||
#@home.setter
|
#@home.setter
|
||||||
def home_set(self, home):
|
def __home_set(self, home):
|
||||||
"Setter. Allows for self.home = value"
|
"Setter. Allows for self.home = value"
|
||||||
try:
|
try:
|
||||||
if home == None or type(home) == ObjectDB:
|
if home == None or type(home) == ObjectDB:
|
||||||
|
|
@ -326,23 +327,23 @@ class ObjectDB(TypedObject):
|
||||||
logger.log_trace(string)
|
logger.log_trace(string)
|
||||||
#raise
|
#raise
|
||||||
#@home.deleter
|
#@home.deleter
|
||||||
def home_del(self):
|
def __home_del(self):
|
||||||
"Deleter. Allows for del self.home."
|
"Deleter. Allows for del self.home."
|
||||||
self.db_home = None
|
self.db_home = None
|
||||||
self.save()
|
self.save()
|
||||||
_del_cache(self, "home")
|
_del_cache(self, "home")
|
||||||
home = property(home_get, home_set, home_del)
|
home = property(__home_get, __home_set, __home_del)
|
||||||
|
|
||||||
# destination property (wraps db_destination)
|
# destination property (wraps db_destination)
|
||||||
#@property
|
#@property
|
||||||
def destination_get(self):
|
def __destination_get(self):
|
||||||
"Getter. Allows for value = self.destination."
|
"Getter. Allows for value = self.destination."
|
||||||
dest = _get_cache(self, "destination")
|
dest = _get_cache(self, "destination")
|
||||||
if dest:
|
if dest:
|
||||||
return dest.typeclass
|
return dest.typeclass
|
||||||
return None
|
return None
|
||||||
#@destination.setter
|
#@destination.setter
|
||||||
def destination_set(self, destination):
|
def __destination_set(self, destination):
|
||||||
"Setter. Allows for self.destination = destination"
|
"Setter. Allows for self.destination = destination"
|
||||||
try:
|
try:
|
||||||
if destination == None or type(destination) == ObjectDB:
|
if destination == None or type(destination) == ObjectDB:
|
||||||
|
|
@ -365,33 +366,33 @@ class ObjectDB(TypedObject):
|
||||||
logger.log_trace(string)
|
logger.log_trace(string)
|
||||||
raise
|
raise
|
||||||
#@destination.deleter
|
#@destination.deleter
|
||||||
def destination_del(self):
|
def __destination_del(self):
|
||||||
"Deleter. Allows for del self.destination"
|
"Deleter. Allows for del self.destination"
|
||||||
self.db_destination = None
|
self.db_destination = None
|
||||||
self.save()
|
self.save()
|
||||||
_del_cache(self, "destination")
|
_del_cache(self, "destination")
|
||||||
destination = property(destination_get, destination_set, destination_del)
|
destination = property(__destination_get, __destination_set, __destination_del)
|
||||||
|
|
||||||
# cmdset_storage property.
|
# cmdset_storage property.
|
||||||
# This seems very sensitive to caching, so leaving it be for now. /Griatch
|
# This seems very sensitive to caching, so leaving it be for now. /Griatch
|
||||||
#@property
|
#@property
|
||||||
def cmdset_storage_get(self):
|
def __cmdset_storage_get(self):
|
||||||
"Getter. Allows for value = self.name. Returns a list of cmdset_storage."
|
"Getter. Allows for value = self.name. Returns a list of cmdset_storage."
|
||||||
if self.db_cmdset_storage:
|
if self.db_cmdset_storage:
|
||||||
return [path.strip() for path in self.db_cmdset_storage.split(',')]
|
return [path.strip() for path in self.db_cmdset_storage.split(',')]
|
||||||
return []
|
return []
|
||||||
#@cmdset_storage.setter
|
#@cmdset_storage.setter
|
||||||
def cmdset_storage_set(self, value):
|
def __cmdset_storage_set(self, value):
|
||||||
"Setter. Allows for self.name = value. Stores as a comma-separated string."
|
"Setter. Allows for self.name = value. Stores as a comma-separated string."
|
||||||
value = ",".join(str(val).strip() for val in make_iter(value))
|
value = ",".join(str(val).strip() for val in make_iter(value))
|
||||||
self.db_cmdset_storage = value
|
self.db_cmdset_storage = value
|
||||||
self.save()
|
self.save()
|
||||||
#@cmdset_storage.deleter
|
#@cmdset_storage.deleter
|
||||||
def cmdset_storage_del(self):
|
def __cmdset_storage_del(self):
|
||||||
"Deleter. Allows for del self.name"
|
"Deleter. Allows for del self.name"
|
||||||
self.db_cmdset_storage = ""
|
self.db_cmdset_storage = ""
|
||||||
self.save()
|
self.save()
|
||||||
cmdset_storage = property(cmdset_storage_get, cmdset_storage_set, cmdset_storage_del)
|
cmdset_storage = property(__cmdset_storage_get, __cmdset_storage_set, __cmdset_storage_del)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"Define Django meta options"
|
"Define Django meta options"
|
||||||
|
|
@ -409,7 +410,7 @@ class ObjectDB(TypedObject):
|
||||||
_default_typeclass_path = settings.BASE_OBJECT_TYPECLASS or "src.objects.objects.Object"
|
_default_typeclass_path = settings.BASE_OBJECT_TYPECLASS or "src.objects.objects.Object"
|
||||||
|
|
||||||
#@property
|
#@property
|
||||||
def sessions_get(self):
|
def __sessions_get(self):
|
||||||
"""
|
"""
|
||||||
Retrieve sessions connected to this object.
|
Retrieve sessions connected to this object.
|
||||||
"""
|
"""
|
||||||
|
|
@ -417,42 +418,43 @@ class ObjectDB(TypedObject):
|
||||||
if self.player:
|
if self.player:
|
||||||
return self.player.sessions
|
return self.player.sessions
|
||||||
return []
|
return []
|
||||||
sessions = property(sessions_get)
|
sessions = property(__sessions_get)
|
||||||
|
|
||||||
#@property
|
#@property
|
||||||
def has_player_get(self):
|
def __has_player_get(self):
|
||||||
"""
|
"""
|
||||||
Convenience function for checking if an active player is
|
Convenience function for checking if an active player is
|
||||||
currently connected to this object
|
currently connected to this object
|
||||||
"""
|
"""
|
||||||
return any(self.sessions)
|
return any(self.sessions)
|
||||||
has_player = property(has_player_get)
|
has_player = property(__has_player_get)
|
||||||
is_player = property(has_player_get)
|
is_player = property(__has_player_get)
|
||||||
|
|
||||||
#@property
|
#@property
|
||||||
def is_superuser_get(self):
|
def __is_superuser_get(self):
|
||||||
"Check if user has a player, and if so, if it is a superuser."
|
"Check if user has a player, and if so, if it is a superuser."
|
||||||
return any(self.sessions) and self.player.is_superuser
|
return any(self.sessions) and self.player.is_superuser
|
||||||
is_superuser = property(is_superuser_get)
|
is_superuser = property(__is_superuser_get)
|
||||||
|
|
||||||
#@property
|
#@property
|
||||||
def contents_get(self, exclude=None):
|
def contents_get(self, exclude=None):
|
||||||
"""
|
"""
|
||||||
Returns the contents of this object, i.e. all
|
Returns the contents of this object, i.e. all
|
||||||
objects that has this object set as its location.
|
objects that has this object set as its location.
|
||||||
|
This should be publically available.
|
||||||
"""
|
"""
|
||||||
return ObjectDB.objects.get_contents(self, excludeobj=exclude)
|
return ObjectDB.objects.get_contents(self, excludeobj=exclude)
|
||||||
contents = property(contents_get)
|
contents = property(contents_get)
|
||||||
|
|
||||||
#@property
|
#@property
|
||||||
def exits_get(self):
|
def __exits_get(self):
|
||||||
"""
|
"""
|
||||||
Returns all exits from this object, i.e. all objects
|
Returns all exits from this object, i.e. all objects
|
||||||
at this location having the property destination != None.
|
at this location having the property destination != None.
|
||||||
"""
|
"""
|
||||||
return [exi for exi in self.contents
|
return [exi for exi in self.contents
|
||||||
if exi.destination]
|
if exi.destination]
|
||||||
exits = property(exits_get)
|
exits = property(__exits_get)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ they control by simply linking to a new object's user property.
|
||||||
|
|
||||||
from src.typeclasses.typeclass import TypeClass
|
from src.typeclasses.typeclass import TypeClass
|
||||||
from src.commands import cmdset, command
|
from src.commands import cmdset, command
|
||||||
|
__all__ = ("Object", "Character", "Room", "Exit")
|
||||||
|
|
||||||
#
|
#
|
||||||
# Base class to inherit from.
|
# Base class to inherit from.
|
||||||
|
|
@ -24,11 +25,10 @@ from src.commands import cmdset, command
|
||||||
|
|
||||||
class Object(TypeClass):
|
class Object(TypeClass):
|
||||||
"""
|
"""
|
||||||
This is the base class for all in-game objects.
|
This is the base class for all in-game objects. Inherit from this
|
||||||
Inherit from this to create different types of
|
to create different types of objects in the game.
|
||||||
objects in the game.
|
|
||||||
"""
|
"""
|
||||||
|
# __init__ is only defined here in order to present docstring to API.
|
||||||
def __init__(self, dbobj):
|
def __init__(self, dbobj):
|
||||||
"""
|
"""
|
||||||
This is the root typeclass object, implementing an in-game Evennia
|
This is the root typeclass object, implementing an in-game Evennia
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from src.typeclasses.managers import returns_typeclass_list, returns_typeclass, TypedObjectManager
|
from src.typeclasses.managers import returns_typeclass_list, returns_typeclass, TypedObjectManager
|
||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
|
__all__ = ("PlayerManager",)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Player Manager
|
# Player Manager
|
||||||
|
|
@ -206,4 +207,3 @@ class PlayerManager(TypedObjectManager):
|
||||||
if delete_old_character:
|
if delete_old_character:
|
||||||
old_character.delete()
|
old_character.delete()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ from src.utils import logger, utils
|
||||||
from src.commands.cmdsethandler import CmdSetHandler
|
from src.commands.cmdsethandler import CmdSetHandler
|
||||||
from src.commands import cmdhandler
|
from src.commands import cmdhandler
|
||||||
|
|
||||||
|
__all__ = ("PlayerAttribute", "PlayerNick", "PlayerDB")
|
||||||
|
|
||||||
_AT_SEARCH_RESULT = utils.mod_import(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
_AT_SEARCH_RESULT = utils.mod_import(*settings.SEARCH_AT_RESULT.rsplit('.', 1))
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ instead for most things).
|
||||||
"""
|
"""
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from src.typeclasses.typeclass import TypeClass
|
from src.typeclasses.typeclass import TypeClass
|
||||||
|
__all__ = ("Player",)
|
||||||
CMDSET_OOC = settings.CMDSET_OOC
|
CMDSET_OOC = settings.CMDSET_OOC
|
||||||
|
|
||||||
class Player(TypeClass):
|
class Player(TypeClass):
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ The custom manager for Scripts.
|
||||||
|
|
||||||
from src.typeclasses.managers import TypedObjectManager
|
from src.typeclasses.managers import TypedObjectManager
|
||||||
from src.typeclasses.managers import returns_typeclass_list
|
from src.typeclasses.managers import returns_typeclass_list
|
||||||
|
__all__ = ("ScriptManager",)
|
||||||
|
|
||||||
VALIDATE_ITERATION = 0
|
VALIDATE_ITERATION = 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ from src.typeclasses.models import Attribute, TypedObject
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
from src.scripts.manager import ScriptManager
|
from src.scripts.manager import ScriptManager
|
||||||
|
|
||||||
|
__all__ = ("ScriptAttribute", "ScriptDB")
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# ScriptAttribute
|
# ScriptAttribute
|
||||||
|
|
@ -121,122 +123,122 @@ class ScriptDB(TypedObject):
|
||||||
|
|
||||||
# desc property (wraps db_desc)
|
# desc property (wraps db_desc)
|
||||||
#@property
|
#@property
|
||||||
def desc_get(self):
|
def __desc_get(self):
|
||||||
"Getter. Allows for value = self.desc"
|
"Getter. Allows for value = self.desc"
|
||||||
return self.db_desc
|
return self.db_desc
|
||||||
#@desc.setter
|
#@desc.setter
|
||||||
def desc_set(self, value):
|
def __desc_set(self, value):
|
||||||
"Setter. Allows for self.desc = value"
|
"Setter. Allows for self.desc = value"
|
||||||
self.db_desc = value
|
self.db_desc = value
|
||||||
self.save()
|
self.save()
|
||||||
#@desc.deleter
|
#@desc.deleter
|
||||||
def desc_del(self):
|
def __desc_del(self):
|
||||||
"Deleter. Allows for del self.desc"
|
"Deleter. Allows for del self.desc"
|
||||||
self.db_desc = ""
|
self.db_desc = ""
|
||||||
self.save()
|
self.save()
|
||||||
desc = property(desc_get, desc_set, desc_del)
|
desc = property(__desc_get, __desc_set, __desc_del)
|
||||||
|
|
||||||
# obj property (wraps db_obj)
|
# obj property (wraps db_obj)
|
||||||
#@property
|
#@property
|
||||||
def obj_get(self):
|
def __obj_get(self):
|
||||||
"Getter. Allows for value = self.obj"
|
"Getter. Allows for value = self.obj"
|
||||||
return self.db_obj
|
return self.db_obj
|
||||||
#@obj.setter
|
#@obj.setter
|
||||||
def obj_set(self, value):
|
def __obj_set(self, value):
|
||||||
"Setter. Allows for self.obj = value"
|
"Setter. Allows for self.obj = value"
|
||||||
self.db_obj = value
|
self.db_obj = value
|
||||||
self.save()
|
self.save()
|
||||||
#@obj.deleter
|
#@obj.deleter
|
||||||
def obj_del(self):
|
def __obj_del(self):
|
||||||
"Deleter. Allows for del self.obj"
|
"Deleter. Allows for del self.obj"
|
||||||
self.db_obj = None
|
self.db_obj = None
|
||||||
self.save()
|
self.save()
|
||||||
obj = property(obj_get, obj_set, obj_del)
|
obj = property(__obj_get, __obj_set, __obj_del)
|
||||||
|
|
||||||
# interval property (wraps db_interval)
|
# interval property (wraps db_interval)
|
||||||
#@property
|
#@property
|
||||||
def interval_get(self):
|
def __interval_get(self):
|
||||||
"Getter. Allows for value = self.interval"
|
"Getter. Allows for value = self.interval"
|
||||||
return self.db_interval
|
return self.db_interval
|
||||||
#@interval.setter
|
#@interval.setter
|
||||||
def interval_set(self, value):
|
def __interval_set(self, value):
|
||||||
"Setter. Allows for self.interval = value"
|
"Setter. Allows for self.interval = value"
|
||||||
self.db_interval = int(value)
|
self.db_interval = int(value)
|
||||||
self.save()
|
self.save()
|
||||||
#@interval.deleter
|
#@interval.deleter
|
||||||
def interval_del(self):
|
def __interval_del(self):
|
||||||
"Deleter. Allows for del self.interval"
|
"Deleter. Allows for del self.interval"
|
||||||
self.db_interval = 0
|
self.db_interval = 0
|
||||||
self.save()
|
self.save()
|
||||||
interval = property(interval_get, interval_set, interval_del)
|
interval = property(__interval_get, __interval_set, __interval_del)
|
||||||
|
|
||||||
# start_delay property (wraps db_start_delay)
|
# start_delay property (wraps db_start_delay)
|
||||||
#@property
|
#@property
|
||||||
def start_delay_get(self):
|
def __start_delay_get(self):
|
||||||
"Getter. Allows for value = self.start_delay"
|
"Getter. Allows for value = self.start_delay"
|
||||||
return self.db_start_delay
|
return self.db_start_delay
|
||||||
#@start_delay.setter
|
#@start_delay.setter
|
||||||
def start_delay_set(self, value):
|
def __start_delay_set(self, value):
|
||||||
"Setter. Allows for self.start_delay = value"
|
"Setter. Allows for self.start_delay = value"
|
||||||
self.db_start_delay = value
|
self.db_start_delay = value
|
||||||
self.save()
|
self.save()
|
||||||
#@start_delay.deleter
|
#@start_delay.deleter
|
||||||
def start_delay_del(self):
|
def __start_delay_del(self):
|
||||||
"Deleter. Allows for del self.start_delay"
|
"Deleter. Allows for del self.start_delay"
|
||||||
self.db_start_delay = False
|
self.db_start_delay = False
|
||||||
self.save()
|
self.save()
|
||||||
start_delay = property(start_delay_get, start_delay_set, start_delay_del)
|
start_delay = property(__start_delay_get, __start_delay_set, __start_delay_del)
|
||||||
|
|
||||||
# repeats property (wraps db_repeats)
|
# repeats property (wraps db_repeats)
|
||||||
#@property
|
#@property
|
||||||
def repeats_get(self):
|
def __repeats_get(self):
|
||||||
"Getter. Allows for value = self.repeats"
|
"Getter. Allows for value = self.repeats"
|
||||||
return self.db_repeats
|
return self.db_repeats
|
||||||
#@repeats.setter
|
#@repeats.setter
|
||||||
def repeats_set(self, value):
|
def __repeats_set(self, value):
|
||||||
"Setter. Allows for self.repeats = value"
|
"Setter. Allows for self.repeats = value"
|
||||||
self.db_repeats = int(value)
|
self.db_repeats = int(value)
|
||||||
self.save()
|
self.save()
|
||||||
#@repeats.deleter
|
#@repeats.deleter
|
||||||
def repeats_del(self):
|
def __repeats_del(self):
|
||||||
"Deleter. Allows for del self.repeats"
|
"Deleter. Allows for del self.repeats"
|
||||||
self.db_repeats = 0
|
self.db_repeats = 0
|
||||||
self.save()
|
self.save()
|
||||||
repeats = property(repeats_get, repeats_set, repeats_del)
|
repeats = property(__repeats_get, __repeats_set, __repeats_del)
|
||||||
|
|
||||||
# persistent property (wraps db_persistent)
|
# persistent property (wraps db_persistent)
|
||||||
#@property
|
#@property
|
||||||
def persistent_get(self):
|
def __persistent_get(self):
|
||||||
"Getter. Allows for value = self.persistent"
|
"Getter. Allows for value = self.persistent"
|
||||||
return self.db_persistent
|
return self.db_persistent
|
||||||
#@persistent.setter
|
#@persistent.setter
|
||||||
def persistent_set(self, value):
|
def __persistent_set(self, value):
|
||||||
"Setter. Allows for self.persistent = value"
|
"Setter. Allows for self.persistent = value"
|
||||||
self.db_persistent = value
|
self.db_persistent = value
|
||||||
self.save()
|
self.save()
|
||||||
#@persistent.deleter
|
#@persistent.deleter
|
||||||
def persistent_del(self):
|
def __persistent_del(self):
|
||||||
"Deleter. Allows for del self.persistent"
|
"Deleter. Allows for del self.persistent"
|
||||||
self.db_persistent = False
|
self.db_persistent = False
|
||||||
self.save()
|
self.save()
|
||||||
persistent = property(persistent_get, persistent_set, persistent_del)
|
persistent = property(__persistent_get, __persistent_set, __persistent_del)
|
||||||
|
|
||||||
# is_active property (wraps db_is_active)
|
# is_active property (wraps db_is_active)
|
||||||
#@property
|
#@property
|
||||||
def is_active_get(self):
|
def __is_active_get(self):
|
||||||
"Getter. Allows for value = self.is_active"
|
"Getter. Allows for value = self.is_active"
|
||||||
return self.db_is_active
|
return self.db_is_active
|
||||||
#@is_active.setter
|
#@is_active.setter
|
||||||
def is_active_set(self, value):
|
def __is_active_set(self, value):
|
||||||
"Setter. Allows for self.is_active = value"
|
"Setter. Allows for self.is_active = value"
|
||||||
self.db_is_active = value
|
self.db_is_active = value
|
||||||
self.save()
|
self.save()
|
||||||
#@is_active.deleter
|
#@is_active.deleter
|
||||||
def is_active_del(self):
|
def __is_active_del(self):
|
||||||
"Deleter. Allows for del self.is_active"
|
"Deleter. Allows for del self.is_active"
|
||||||
self.db_is_active = False
|
self.db_is_active = False
|
||||||
self.save()
|
self.save()
|
||||||
is_active = property(is_active_get, is_active_set, is_active_del)
|
is_active = property(__is_active_get, __is_active_set, __is_active_del)
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ from src.scripts.models import ScriptDB
|
||||||
from src.comms import channelhandler
|
from src.comms import channelhandler
|
||||||
from src.utils import logger
|
from src.utils import logger
|
||||||
|
|
||||||
|
__all__ = ("Script", "DoNothing", "CheckSessions", "ValidateScripts", "ValidateChannelHandler", "AddCmdSet")
|
||||||
|
|
||||||
#
|
#
|
||||||
# Base script, inherit from Script below instead.
|
# Base script, inherit from Script below instead.
|
||||||
#
|
#
|
||||||
|
|
@ -272,9 +274,9 @@ class Script(ScriptClass):
|
||||||
|
|
||||||
desc (string) - optional description of script, shown in listings
|
desc (string) - optional description of script, shown in listings
|
||||||
obj (Object) - optional object that this script is connected to and acts on (set automatically by obj.scripts.add())
|
obj (Object) - optional object that this script is connected to and acts on (set automatically by obj.scripts.add())
|
||||||
interval (int) - how often script should run, in seconds. <0 turns off ticker
|
interval (int) - how often script should run, in seconds. <=0 turns off ticker
|
||||||
start_delay (bool) - if the script should start repeating right away or wait self.interval seconds
|
start_delay (bool) - if the script should start repeating right away or wait self.interval seconds
|
||||||
repeats (int) - how many times the script should repeat before stopping. 0 means infinite repeats
|
repeats (int) - how many times the script should repeat before stopping. <=0 means infinite repeats
|
||||||
persistent (bool) - if script should survive a server shutdown or not
|
persistent (bool) - if script should survive a server shutdown or not
|
||||||
is_active (bool) - if script is currently running
|
is_active (bool) - if script is currently running
|
||||||
|
|
||||||
|
|
@ -309,7 +311,7 @@ class Script(ScriptClass):
|
||||||
at_repeat() - Called every self.interval seconds. It will be called immediately
|
at_repeat() - Called every self.interval seconds. It will be called immediately
|
||||||
upon launch unless self.delay_start is True, which will delay
|
upon launch unless self.delay_start is True, which will delay
|
||||||
the first call of this method by self.interval seconds. If
|
the first call of this method by self.interval seconds. If
|
||||||
self.interval==0, this method will never be called.
|
self.interval<=0, this method will never be called.
|
||||||
at_stop() - Called as the script object is stopped and is about to be removed from
|
at_stop() - Called as the script object is stopped and is about to be removed from
|
||||||
the game, e.g. because is_valid() returned False.
|
the game, e.g. because is_valid() returned False.
|
||||||
at_server_reload() - Called when server reloads. Can be used to save temporary
|
at_server_reload() - Called when server reloads. Can be used to save temporary
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from functools import update_wrapper
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from src.utils import idmapper
|
from src.utils import idmapper
|
||||||
from src.utils.utils import make_iter
|
from src.utils.utils import make_iter
|
||||||
#from src.typeclasses import idmap
|
__all__ = ("AttributeManager", "TypedObjectManager")
|
||||||
|
|
||||||
# Managers
|
# Managers
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ from src.locks.lockhandler import LockHandler
|
||||||
from src.utils import logger, utils
|
from src.utils import logger, utils
|
||||||
from src.utils.utils import make_iter, is_iter, has_parent, to_unicode, to_str
|
from src.utils.utils import make_iter, is_iter, has_parent, to_unicode, to_str
|
||||||
|
|
||||||
|
__all__ = ("Attribute", "TypeNick", "TypedObject")
|
||||||
|
|
||||||
_PERMISSION_HIERARCHY = [p.lower() for p in settings.PERMISSION_HIERARCHY]
|
_PERMISSION_HIERARCHY = [p.lower() for p in settings.PERMISSION_HIERARCHY]
|
||||||
|
|
||||||
_CTYPEGET = ContentType.objects.get
|
_CTYPEGET = ContentType.objects.get
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ used by the typesystem or django itself.
|
||||||
from src.utils.logger import log_trace, log_errmsg
|
from src.utils.logger import log_trace, log_errmsg
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
__all__ = ("TypeClass",)
|
||||||
|
|
||||||
# these are called so many times it's worth to avoid lookup calls
|
# these are called so many times it's worth to avoid lookup calls
|
||||||
_GA = object.__getattribute__
|
_GA = object.__getattribute__
|
||||||
_SA = object.__setattr__
|
_SA = object.__setattr__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue