[PEAK] No attribute 'register' error when calling setParentComponent()

jdutreve at free.fr jdutreve at free.fr
Sat Oct 30 14:39:15 EDT 2004


Hi all,

I'm developping a domain model with accounts and I have an error
when I've added element.setParentComponent(parent, element.name) :

class Account(model.Element):

    mdl_isAbstract = True

    class name(model.Attribute):
        referencedType = model.String

    class parent(model.Attribute):
        referencedType = 'SummaryAccount'
        referencedEnd = 'subAccounts'
        defaultValue = None

        def set(feature, element, parent):
            super(Account.parent, feature).set(element, parent)
            element.setParentComponent(parent, element.name)

class SummaryAccount(Account):

    class subAccounts(model.Collection):
        referencedType = Account
        referencedEnd = 'parent'
        singularName = 'subAccount'

>>> root = SummaryAccount(name='Accounts')
>>> asset = SummaryAccount(parent=root, name='Asset')
>>> cash = SummaryAccount(parent=asset, name='Cash')
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/peak/model/elements.py", line 265, in
__init__
    f._setup(self,__kw[f.attrName])
  File "/usr/lib/python2.3/site-packages/peak/model/features.py", line 619, in
_setup
    return feature.set(element,value)
  File "/home/jdu/projects/openfinance/trunk/src/py/transaction.py", line 26, in
set
    super(Account.parent, feature).set(element, parent)
  File "/usr/lib/python2.3/site-packages/peak/model/features.py", line 348, in
set
    feature._notifyLink(element,val)
  File "/usr/lib/python2.3/site-packages/peak/model/features.py", line 465, in
_notifyLink
    otherEnd._link(item,element)
  File "/usr/lib/python2.3/site-packages/peak/model/features.py", line 552, in
_link
    feature._doSet(element,d)
  File "/usr/lib/python2.3/site-packages/peak/model/elements.py", line 552, in
_doSet
    ob._p_changed = True
AttributeError: 'SummaryAccount' object has no attribute 'register'


I wonder too what is the use of giving to an Element with a ParentComponent ?

Thanks,
Jean-Philippe



More information about the PEAK mailing list