OBS: You need to resync your database! Moved cmdsets into the database rather than being dependent on scripts. Moved the creation of the cmdset- and cmdset-handlers into ObjectDB.__init__ rather than bootstrapping it from the typeclass. Added some more script functionality for testing, includong the @script command for assigning a script to an object.

This commit is contained in:
Griatch 2011-03-20 19:45:56 +00:00
parent e965830735
commit 126e2ea61f
17 changed files with 370 additions and 216 deletions

View file

@ -170,13 +170,13 @@ def create_script(typeclass, key=None, obj=None, locks=None, autostart=True):
new_script = typeclass(new_db_object)
# store variables on the typeclass (which means
# it's actually transparently stored on the db object)
if key:
new_db_object.name = key
else:
if not key:
if typeclass and hasattr(typeclass, '__name__'):
new_db_object.name = "%s" % typeclass.__name__
new_script.key = "%s" % typeclass.__name__
else:
new_db_object.name = "#%i" % new_db_object.id
new_script.key = "#%i" % new_db_object.id
# call the hook method. This is where all at_creation
# customization happens as the typeclass stores custom
@ -184,6 +184,9 @@ def create_script(typeclass, key=None, obj=None, locks=None, autostart=True):
new_script.at_script_creation()
# custom-given variables override the hook
if key:
new_script.key = key
if locks:
new_script.locks.add(locks)
@ -191,12 +194,9 @@ def create_script(typeclass, key=None, obj=None, locks=None, autostart=True):
try:
new_script.obj = obj
except ValueError:
new_script.obj = obj.dbobj
new_script.save()
new_script.obj = obj.dbobj
# a new created script should always be started, so
# we do this now.
# a new created script should usually be started.
if autostart:
new_script.start()