mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 12:56:30 +01:00
Fix Component contrib issue with corrected AttributeProperty
This commit is contained in:
parent
b8e37f9cf2
commit
e3ddbf08cf
3 changed files with 19 additions and 2 deletions
|
|
@ -155,6 +155,22 @@ class Component(metaclass=BaseComponent):
|
|||
"""
|
||||
return self.host.attributes
|
||||
|
||||
@property
|
||||
def pk(self):
|
||||
"""
|
||||
Shortcut property returning the host's primary key.
|
||||
|
||||
Returns:
|
||||
int: The Host's primary key.
|
||||
|
||||
Notes:
|
||||
This is requried to allow AttributeProperties to correctly update `_SaverMutable` data
|
||||
(like lists) in-place (since the DBField sits on the Component which doesn't itself
|
||||
have a primary key, this save operation would otherwise fail).
|
||||
|
||||
"""
|
||||
return self.host.pk
|
||||
|
||||
@property
|
||||
def nattributes(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ This file contains the Descriptors used to set Fields in Components
|
|||
|
||||
import typing
|
||||
|
||||
from evennia.typeclasses.attributes import AttributeProperty, NAttributeProperty
|
||||
from evennia.typeclasses.attributes import (AttributeProperty,
|
||||
NAttributeProperty)
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from .components import Component
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ class TestComponents(EvenniaTest):
|
|||
|
||||
def test_mutables_are_not_shared_when_autocreate(self):
|
||||
self.char1.test_a.my_list.append(1)
|
||||
self.assertNotEqual(self.char1.test_a.my_list, self.char2.test_a.my_list)
|
||||
self.assertNotEqual(id(self.char1.test_a.my_list), id(self.char2.test_a.my_list))
|
||||
|
||||
def test_replacing_class_component_slot_with_runtime_component(self):
|
||||
self.char1.components.add_default("replacement_inherited_test_a")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue