diff --git a/evennia/prototypes/prototypes.py b/evennia/prototypes/prototypes.py index 0843a67105..7b60770ccb 100644 --- a/evennia/prototypes/prototypes.py +++ b/evennia/prototypes/prototypes.py @@ -66,7 +66,8 @@ def homogenize_prototype(prototype, custom_keys=None): homogenized[key] = val else: attrs.append((key, val, None, '')) - homogenized['attrs'] = attrs + if attrs: + homogenized['attrs'] = attrs return homogenized diff --git a/evennia/prototypes/tests.py b/evennia/prototypes/tests.py index 9f782f991b..7e1b5a93f0 100644 --- a/evennia/prototypes/tests.py +++ b/evennia/prototypes/tests.py @@ -349,6 +349,7 @@ class TestPrototypeStorage(EvenniaTest): def test_prototype_storage(self): + # from evennia import set_trace;set_trace(term_size=(180, 50)) prot1 = protlib.create_prototype(**self.prot1) self.assertTrue(bool(prot1)) @@ -587,4 +588,39 @@ class TestOLCMenu(TestEvMenu): "node_index": "|c --- Prototype wizard --- |n" } - expected_tree = ['node_index', ['node_prototype_key', ['node_index', 'node_index', 'node_validate_prototype', ['node_index', 'node_index'], 'node_index'], 'node_prototype_parent', ['node_prototype_parent', 'node_prototype_key', 'node_prototype_parent', 'node_index', 'node_validate_prototype', 'node_index'], 'node_typeclass', ['node_typeclass', 'node_prototype_parent', 'node_typeclass', 'node_index', 'node_validate_prototype', 'node_index'], 'node_key', ['node_typeclass', 'node_key', 'node_index', 'node_validate_prototype', 'node_index'], 'node_aliases', ['node_key', 'node_aliases', 'node_index', 'node_validate_prototype', 'node_index'], 'node_attrs', ['node_aliases', 'node_attrs', 'node_index', 'node_validate_prototype', 'node_index'], 'node_tags', ['node_attrs', 'node_tags', 'node_index', 'node_validate_prototype', 'node_index'], 'node_locks', ['node_tags', 'node_locks', 'node_index', 'node_validate_prototype', 'node_index'], 'node_permissions', ['node_locks', 'node_permissions', 'node_index', 'node_validate_prototype', 'node_index'], 'node_location', ['node_permissions', 'node_location', 'node_index', 'node_validate_prototype', 'node_index', 'node_index'], 'node_home', ['node_location', 'node_home', 'node_index', 'node_validate_prototype', 'node_index', 'node_index'], 'node_destination', ['node_home', 'node_destination', 'node_index', 'node_validate_prototype', 'node_index', 'node_index'], 'node_prototype_desc', ['node_prototype_key', 'node_prototype_parent', 'node_index', 'node_validate_prototype', 'node_index'], 'node_prototype_tags', ['node_prototype_desc', 'node_prototype_tags', 'node_index', 'node_validate_prototype', 'node_index'], 'node_prototype_locks', ['node_examine_entity', ['node_prototype_locks', 'node_prototype_locks', 'node_prototype_locks'], 'node_examine_entity', 'node_prototype_locks', 'node_index', 'node_validate_prototype', 'node_index'], 'node_validate_prototype', 'node_index', 'node_prototype_spawn', ['node_index', 'node_validate_prototype'], 'node_index', 'node_search_object', ['node_index', 'node_index']]] + expected_tree = [ + 'node_index', + ['node_prototype_key', + ['node_index', 'node_index', 'node_validate_prototype', + ['node_index', 'node_index'], 'node_index'], + 'node_prototype_parent', + ['node_prototype_parent', 'node_prototype_key', 'node_prototype_parent', 'node_index', + 'node_validate_prototype', 'node_index'], + 'node_typeclass', ['node_typeclass', 'node_prototype_parent', 'node_typeclass', + 'node_index', 'node_validate_prototype', 'node_index'], + 'node_key', ['node_typeclass', 'node_key', 'node_index', 'node_validate_prototype', + 'node_index'], + 'node_aliases', ['node_key', 'node_aliases', 'node_index', 'node_validate_prototype', + 'node_index'], + 'node_attrs', ['node_aliases', 'node_attrs', 'node_index', 'node_validate_prototype', + 'node_index'], + 'node_tags', ['node_attrs', 'node_tags', 'node_index', 'node_validate_prototype', + 'node_index'], + 'node_locks', ['node_tags', 'node_locks', 'node_index', 'node_validate_prototype', + 'node_index'], + 'node_permissions', ['node_locks', 'node_permissions', 'node_index', + 'node_validate_prototype', 'node_index'], + 'node_location', ['node_permissions', 'node_location', 'node_index', + 'node_validate_prototype', 'node_index', 'node_index'], + 'node_home', ['node_location', 'node_home', 'node_index', 'node_validate_prototype', + 'node_index', 'node_index'], + 'node_destination', ['node_home', 'node_destination', 'node_index', + 'node_validate_prototype', 'node_index', 'node_index'], + 'node_prototype_desc', ['node_prototype_key', 'node_prototype_parent', 'node_index', + 'node_validate_prototype', 'node_index'], + 'node_prototype_tags', ['node_prototype_desc', 'node_prototype_tags', 'node_index', + 'node_validate_prototype', 'node_index'], + 'node_prototype_locks', ['node_prototype_tags', 'node_prototype_locks', + 'node_validate_prototype', 'node_prototype_locks'], + 'node_validate_prototype', 'node_prototype_locks', 'node_prototype_locks', + 'node_prototype_locks', 'node_prototype_locks']] diff --git a/evennia/typeclasses/attributes.py b/evennia/typeclasses/attributes.py index 7c7280c448..863628172a 100644 --- a/evennia/typeclasses/attributes.py +++ b/evennia/typeclasses/attributes.py @@ -573,7 +573,7 @@ class AttributeHandler(object): attr_obj = attr_objs[0] # update an existing attribute object attr_obj.db_category = category - attr_obj.db_lock_storage = lockstring + attr_obj.db_lock_storage = lockstring or '' attr_obj.save(update_fields=["db_category", "db_lock_storage"]) if strattr: # store as a simple string (will not notify OOB handlers) @@ -590,7 +590,7 @@ class AttributeHandler(object): "db_attrtype": self._attrtype, "db_value": None if strattr else to_pickle(new_value), "db_strvalue": new_value if strattr else None, - "db_lock_storage": lockstring} + "db_lock_storage": lockstring or ''} new_attr = Attribute(**kwargs) new_attr.save() new_attrobjs.append(new_attr)