Removed deprecated Attribute methods from evennia distro. Removed MUX help files.

This commit is contained in:
Griatch 2013-08-25 16:41:18 +02:00
parent 9620867031
commit 8bd431b385
13 changed files with 47 additions and 65 deletions

View file

@ -97,7 +97,7 @@ _LOGGER = None
#------------------------------------------------------------
# specifically forbidden symbols
_EV_UNALLOWED_SYMBOLS = ["attr", "set_attribute", "delete"]
_EV_UNALLOWED_SYMBOLS = ["attr", "attributes", "delete"]
try: _EV_UNALLOWED_SYMBOLS.expand(settings.EVLANG_UNALLOWED_SYMBOLS)
except AttributeError: pass
@ -285,7 +285,7 @@ class Evlang(object):
if scripts:
self.evlang_scripts.update(scripts)
if self.obj:
self.evlang_scripts.update(obj.attr(storage_attr))
self.evlang_scripts.update(obj.attributes.get(storage_attr))
self.safe_context = _EV_SAFE_CONTEXT # set by default + settings
if safe_context:
self.safe_context.update(safe_context)
@ -401,7 +401,7 @@ class Evlang(object):
self.evlang_scripts[scriptname] = (codestring, scripter)
if self.obj:
# save to database
self.obj.attr(self.evlang_storage_attr, self.evlang_scripts)
self.obj.attributes.add(self.evlang_storage_attr, self.evlang_scripts)
def delete(self, scriptname):
"""
@ -411,7 +411,7 @@ class Evlang(object):
del self.evlang_scripts[scriptname]
if self.obj:
# update change to database
self.obj.attr(self.evlang_storage_attr, self.evlang_scripts)
self.obj.attributes.add(self.evlang_storage_attr, self.evlang_scripts)
#----------------------------------------------------------------------

View file

@ -642,7 +642,7 @@ class CmdEditor(Command):
return target and str(target) or ""
def save_attr():
"Save line buffer to given attribute name. This should return True if successful and also report its status."
self.obj.set_attribute(self.attrname, self.editor.buffer)
self.obj.attributes.add(self.attrname, self.editor.buffer)
self.caller.msg("Saved.")
return True
def quit_hook():

View file

@ -808,7 +808,7 @@ class CmdGetWeapon(Command):
"Implement the command"
rack_id = self.obj.db.rack_id
if self.caller.get_attribute(rack_id):
if self.caller.attributes.get(rack_id):
# we don't allow a player to take more than one weapon from rack.
self.caller.msg("%s has no more to offer you." % self.obj.name)
else:
@ -826,7 +826,7 @@ class CmdGetWeapon(Command):
else:
self.caller.msg(ostring)
# tag the caller so they cannot keep taking objects from the rack.
self.caller.set_attribute(rack_id, True)
self.caller.attributes.add(rack_id, True)
class CmdSetWeaponRack(CmdSet):

View file

@ -281,10 +281,10 @@ class CmdCpAttr(ObjManipCommand):
if not from_obj or not to_objs:
caller.msg("You have to supply both source object and target(s).")
return
if not from_obj.has_attribute(from_obj_attrs[0]):
if not from_obj.attributes.has(from_obj_attrs[0]):
caller.msg("%s doesn't have an attribute %s." % (from_obj_name, from_obj_attrs[0]))
return
srcvalue = from_obj.get_attribute(from_obj_attrs[0])
srcvalue = from_obj.attributes.get(from_obj_attrs[0])
#copy to all to_obj:ects
if "move" in self.switches:
@ -307,7 +307,7 @@ class CmdCpAttr(ObjManipCommand):
# if there are too few attributes given
# on the to_obj, we copy the original name instead.
to_attr = from_attr
to_obj.set_attribute(to_attr, srcvalue)
to_obj.attributes.add(to_attr, srcvalue)
if "move" in self.switches and not (from_obj == to_obj and from_attr == to_attr):
from_obj.del_attribute(from_attr)
string += "\nMoved %s.%s -> %s.%s." % (from_obj.name, from_attr,
@ -1228,8 +1228,8 @@ class CmdSetAttribute(ObjManipCommand):
if not attrs:
attrs = [attr.key for attr in obj.get_all_attributes()]
for attr in attrs:
if obj.has_attribute(attr):
string += "\nAttribute %s/%s = %s" % (obj.name, attr, obj.get_attribute(attr))
if obj.attributes.has(attr):
string += "\nAttribute %s/%s = %s" % (obj.name, attr, obj.attributes.get(attr))
else:
string += "\n%s has no attribute '%s'." % (obj.name, attr)
# we view it without parsing markup.
@ -1238,9 +1238,9 @@ class CmdSetAttribute(ObjManipCommand):
else:
# deleting the attribute(s)
for attr in attrs:
if obj.has_attribute(attr):
val = obj.get_attribute(attr)
obj.del_attribute(attr)
if obj.attributes.has(attr):
val = obj.attributes.has(attr)
obj.attributes.remove(attr)
string += "\nDeleted attribute '%s' (= %s) from %s." % (attr, val, obj.name)
else:
string += "\n%s has no attribute '%s'." % (obj.name, attr)
@ -1248,7 +1248,7 @@ class CmdSetAttribute(ObjManipCommand):
# setting attribute(s). Make sure to convert to real Python type before saving.
for attr in attrs:
try:
obj.set_attribute(attr, self.convert_from_string(value))
obj.attributes.add(attr, self.convert_from_string(value))
string += "\nCreated attribute %s/%s = %s" % (obj.name, attr, value)
except SyntaxError:
# this means literal_eval tried to parse a faulty string
@ -1406,7 +1406,7 @@ class CmdWipe(ObjManipCommand):
string = "Wiped all attributes on %s." % obj.name
else:
for attrname in attrs:
obj.attr(attrname, delete=True )
obj.attributes.remove(attrname)
string = "Wiped attributes %s on %s."
string = string % (",".join(attrs), obj.name)
caller.msg(string)
@ -1538,7 +1538,7 @@ class CmdExamine(ObjManipCommand):
"""
if attrname:
db_attr = [(attrname, obj.attr(attrname))]
db_attr = [(attrname, obj.attributes.get(attrname))]
try:
ndb_attr = [(attrname, object.__getattribute__(obj.ndb, attrname))]
except Exception:

View file

@ -622,16 +622,16 @@ class CmdQuell(MuxPlayerCommand):
player = self.caller
permstr = player.is_superuser and " (superuser)" or " (%s)" % (", ".join(player.permissions.all()))
if self.cmdstring == '@unquell':
if not player.get_attribute('_quell'):
if not player.attributes.get('_quell'):
self.msg("Already using normal Player permissions%s." % permstr)
else:
player.del_attribute('_quell')
player.attributes.remove('_quell')
self.msg("Player permissions%s restored." % permstr)
else:
if player.get_attribute('_quell'):
if player.get('_quell'):
self.msg("Already quelling Player%s permissions." % permstr)
return
player.set_attribute('_quell', True)
player.add('_quell', True)
self.msg("Quelling Player permissions%s. Use @unquell to get them back." % permstr)
self._recache_locks(player)

File diff suppressed because one or more lines are too long

View file

@ -153,7 +153,7 @@ def perm(accessing_obj, accessed_obj, *args, **kwargs):
if utils.inherits_from(accessing_obj, "src.objects.objects.Object") and accessing_obj.player:
player = accessing_obj.player
perms_player = [p.lower() for p in player.permissions.all()]
is_quell = player.get_attribute("_quell")
is_quell = player.attributes.get("_quell")
if perm in _PERMISSION_HIERARCHY:
# check hierarchy without allowing escalation obj->player
@ -306,11 +306,11 @@ def attr(accessing_obj, accessed_obj, *args, **kwargs):
return valcompare(str(getattr(accessing_obj, attrname)), value, compare)
return bool(getattr(accessing_obj, attrname)) # will return Fail on False value etc
# check attributes, if they exist
if (hasattr(accessing_obj, 'has_attribute') and accessing_obj.has_attribute(attrname)):
if (hasattr(accessing_obj, 'attributes') and accessing_obj.attributes.has(attrname)):
if value:
return (hasattr(accessing_obj, 'get_attribute')
and valcompare(accessing_obj.get_attribute(attrname), value, compare))
return bool(accessing_obj.get_attribute(attrname)) # fails on False/None values
return (hasattr(accessing_obj, 'attributes')
and valcompare(accessing_obj.attributes.get(attrname), value, compare))
return bool(accessing_obj.attributes.get(attrname)) # fails on False/None values
return False
def objattr(accessing_obj, accessed_obj, *args, **kwargs):
@ -435,7 +435,7 @@ def holds(accessing_obj, accessed_obj, *args, **kwargs):
elif len(args = 2):
# command is holds(attrname, value) check if any held object has the given attribute and value
for obj in contents:
if obj.attr(args[0]) == args[1]:
if obj.attributes.get(args[0]) == args[1]:
return True

View file

@ -366,7 +366,7 @@ class ObjectManager(TypedObjectManager):
# copy over all attributes from old to new.
for attr in original_object.get_all_attributes():
new_object.set_attribute(attr.key, attr.value)
new_object.attributes.add(attr.key, attr.value)
# copy over all cmdsets, if any
for icmdset, cmdset in enumerate(original_object.cmdset.all()):

View file

@ -447,7 +447,7 @@ class ObjectDB(TypedObject):
def __is_superuser_get(self):
"Check if user has a player, and if so, if it is a superuser."
return (_GA(self, "db_player") and _GA(_GA(self, "db_player"), "is_superuser")
and not _GA(_GA(self, "db_player"), "get_attribute")("_quell"))
and not _GA(_GA(self, "db_player"), "attributes").get("_quell"))
is_superuser = property(__is_superuser_get)
# contents

View file

@ -255,7 +255,7 @@ class Player(TypeClass):
"""
# set an (empty) attribute holding the characters this player has
lockstring = "attrread:perm(Admins);attredit:perm(Admins);attrcreate:perm(Admins)"
self.set_attribute("_playable_characters", [], lockstring=lockstring)
self.attributes.add("_playable_characters", [], lockstring=lockstring)
def at_init(self):
"""

View file

@ -193,7 +193,7 @@ def post_attr_update(sender, **kwargs):
# access methods
def get_attr_cache(obj, attrname):
"Called by get_attribute"
"Called by getting attribute"
hid = hashid(obj, "-%s" % attrname)
return hid and _ATTR_CACHE.get(hid, None) or None

View file

@ -72,8 +72,8 @@ def create_objects():
god_character.permissions.add("Immortals")
god_character.save()
god_player.set_attribute("_first_login", True)
god_player.set_attribute("_last_puppet", god_character)
god_player.attributes.add("_first_login", True)
god_player.attributes.add("_last_puppet", god_character)
god_player.db._playable_characters.append(god_character)
# Limbo is the default "nowhere" starting room
@ -138,17 +138,6 @@ def create_channels():
PlayerChannelConnection.objects.create_connection(goduser, ichan)
PlayerChannelConnection.objects.create_connection(goduser, cchan)
def import_MUX_help_files():
"""
Imports the MUX help files.
"""
print " Importing MUX help database (devel reference only) ..."
management.call_command('loaddata', '../src/help/mux_help_db.json', verbosity=0)
# categorize the MUX help files into its own category.
default_category = "MUX"
print " Moving imported help db to help category '%(default)s'." % {'default': default_category}
HelpEntry.objects.all_to_category(default_category)
def create_system_scripts():
"""
Setup the system repeat scripts. They are automatically started
@ -266,16 +255,10 @@ def handle_setup(last_step):
create_system_scripts,
start_game_time,
create_admin_media_links,
import_MUX_help_files,
at_initial_setup,
reset_server
]
if not settings.IMPORT_MUX_HELP:
# skip importing of the MUX helpfiles, they are
# not interesting except for developers.
del setup_queue[-3]
#print " Initial setup: %s steps." % (len(setup_queue))
# step through queue, from last completed function

View file

@ -54,28 +54,28 @@ class GameTime(Script):
self.interval = REAL_MIN # update every minute
self.persistent = True
self.start_delay = True
self.attr("game_time", 0.0) #IC time
self.attr("run_time", 0.0) #OOC time
self.attr("up_time", 0.0) #OOC time
self.attributes.add("game_time", 0.0) #IC time
self.attributes.add("run_time", 0.0) #OOC time
self.attributes.add("up_time", 0.0) #OOC time
def at_repeat(self):
"""
Called every minute to update the timers.
"""
# We store values as floats to avoid drift over time
game_time = float(self.attr("game_time"))
run_time = float(self.attr("run_time"))
up_time = float(self.attr("up_time"))
self.attr("game_time", game_time + MIN)
self.attr("run_time", run_time + REAL_MIN)
self.attr("up_time", up_time + REAL_MIN)
game_time = float(self.attributes.get("game_time"))
run_time = float(self.attributes.get("run_time"))
up_time = float(self.attributes.get("up_time"))
self.attributes.add("game_time", game_time + MIN)
self.attributes.add("run_time", run_time + REAL_MIN)
self.attributes.add("up_time", up_time + REAL_MIN)
def at_start(self):
"""
This is called once every server restart.
We reset the up time.
"""
self.attr("up_time", 0.0)
self.attributes.add("up_time", 0.0)
# Access routines
@ -131,7 +131,7 @@ def gametime(format=False):
logger.log_trace("GameTime script not found.")
return
# we return this as an integer (second-precision is good enough)
game_time = int(script.attr("game_time"))
game_time = int(script.attributes.get("game_time"))
if format:
return gametime_format(game_time)
return game_time
@ -146,7 +146,7 @@ def runtime(format=False):
logger.log_trace("GameTime script not found.")
return
# we return this as an integer (second-precision is good enough)
run_time = int(script.attr("run_time"))
run_time = int(script.attributes.get("run_time"))
if format:
return realtime_format(run_time)
return run_time
@ -161,7 +161,7 @@ def uptime(format=False):
logger.log_trace("GameTime script not found.")
return
# we return this as an integer (second-precision is good enough)
up_time = int(script.attr("up_time"))
up_time = int(script.attributes.get("up_time"))
if format:
return realtime_format(up_time)
return up_time