Moving script_parent to a field on the object model. This is critical enough to warrant it being there instead of in an attribute. Minor changes here and there.

NOTE: This update adds a field, delete your evennia.db3 or manually add a NOT NULL 'script_link' charfield(255).
This commit is contained in:
Greg Taylor 2008-12-16 04:28:57 +00:00
parent bd3d195d5b
commit 9a166ba024
5 changed files with 24 additions and 11 deletions

View file

@ -106,6 +106,7 @@ class Object(models.Model):
ansi_name = models.CharField(max_length=255)
owner = models.ForeignKey('self', related_name="obj_owner", blank=True, null=True)
zone = models.ForeignKey('self', related_name="obj_zone", blank=True, null=True)
script_parent = models.CharField(max_length=255, blank=True, null=True)
home = models.ForeignKey('self', related_name="obj_home", blank=True, null=True)
type = models.SmallIntegerField(choices=defines_global.OBJECT_TYPES)
# TODO: Move description to an attribute.
@ -653,12 +654,19 @@ class Object(models.Model):
Returns an object's script parent.
"""
if not self.scriptlink_cached:
if self.is_player():
script_to_load = settings.SCRIPT_DEFAULT_PLAYER
script_to_load = None
if not self.script_parent or self.script_parent.strip() == '':
# No parent value, assume the defaults based on type.
if self.is_player():
script_to_load = settings.SCRIPT_DEFAULT_PLAYER
else:
script_to_load = settings.SCRIPT_DEFAULT_OBJECT
else:
script_to_load = settings.SCRIPT_DEFAULT_OBJECT
# A parent has been set, load it from the field's value.
script_to_load = self.script_parent
# Load the script reference into the object's attribute.
self.scriptlink_cached = scripthandler.scriptlink(self,
self.get_attribute_value('__parent', script_to_load))
script_to_load)
if self.scriptlink_cached:
# If the scriptlink variable can't be populated, this will fail

View file

@ -1,5 +1,5 @@
INSERT INTO objects_object VALUES(1,'Wizard','Wizard',1,0,2,1,'',2,'','CONNECTED','2007-04-25');
INSERT INTO objects_object VALUES(2,'Limbo','Limbo',1,NULL,NULL,2,'Welcome to your new Evennia-based game. From here you are ready to begin development. If you should need help or would like to participate in community discussions, visit http://evennia.com.',NULL,'','','2007-04-25');
INSERT INTO objects_object VALUES(1,'Wizard','Wizard',1,0,'',2,1,'',2,'','CONNECTED','2007-04-25');
INSERT INTO objects_object VALUES(2,'Limbo','Limbo',1,NULL,'',NULL,2,'Welcome to your new Evennia-based game. From here you are ready to begin development. If you should need help or would like to participate in community discussions, visit http://evennia.com.',NULL,'','','2007-04-25');
INSERT INTO objects_commchannel VALUES(1,'Public','Public',1,'Public Discussion');
INSERT INTO objects_commchannel VALUES(2,'Errors','Errors',1,'Error Log');
INSERT INTO objects_commchannel VALUES(3,'Info','Info',1,'Info Log');