def __init__(cls, name, bases, new_attrs): cls._meta_init_attrs(new_attrs) cls._combine_base_fields(bases) cls._update_dbo_fields(new_attrs) if getattr(cls, 'template_id', None): cls._template_init() cls._update_actions(new_attrs) if 'class_id' in new_attrs: # Override any existing class id reference with this child class set_dbo_class(cls.class_id, cls) elif 'dbo_key_type' in new_attrs: # Override or set the class_id to the database key if present cls.class_id = cls.dbo_key_type set_dbo_class(cls.class_id, cls) if 'mixin_id' in new_attrs: set_mixin(cls.mixin_id, cls)
return load_object(self.parent_id, self.dbo_parent_type) @property def dbo_set_key(self): return "{}_{}s:{}".format(self.dbo_parent_type, self.dbo_key_type, self.parent_id) @property def edit_dto(self): return self.metafields(self.dto_value, ['dbo_id', 'dbo_key', 'class_id', 'dbo_key_type', 'dbo_parent_type']) @property def imm_level(self): return self.parent_dbo.imm_level def can_read(self, immortal): return self.parent_dbo.can_read(immortal) def can_write(self, immortal): return self.parent_dbo.can_write(immortal) # This class is here to catch possible errors in 'untyped' collections class Untyped(): def hydrate(self, dto_repr): # This should never get called, as 'untyped' fields should always hold # templates or actual dbo_references with saved class_ids. warn("Attempting to hydrate invalid dto {}", dto_repr) set_dbo_class('untyped', Untyped)