[PEAK] More trouble with my relation

R. David Murray rdmurray at bitdance.com
Thu Oct 21 12:25:15 EDT 2004


I must be doing something more that's stupid here, but I've
stared at it and I can't see it.  The following code:

        storage.beginTransaction(self)
        for n in self.Accounts.acctnums():
            if '-' not in n: continue
            master, sub = n.split('-')
            m = self.Accounts.get(master)
            if m: self.Accounts[n].masteraccount = m
            else:
                print >>self.stderr, "No master account for %s" % n
        storage.commitTransaction(self)

is supposed to build the initial master/subaccount association.
But when I run it, I get the following error:

-------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/bin/peak", line 4, in ?
    commands.runMain( commands.Bootstrap )
  File "/usr/local/lib/python2.4/site-packages/peak/running/commands.py", line 70, in runMain
    result = factory().run()
  File "/usr/local/lib/python2.4/site-packages/peak/running/commands.py", line 211, in run
    return self._run() or 0
  File "/home/rdmurray/proj/fcgbilling/commands.py", line 117, in _run
    if m: self.Accounts[n].masteraccount = m
  File "/usr/local/lib/python2.4/site-packages/peak/model/features.py", line 79, in __set__
    self.set(ob,val)
  File "/usr/local/lib/python2.4/site-packages/peak/model/features.py", line 347, in set
    feature.unset(element)
  File "/usr/local/lib/python2.4/site-packages/peak/model/features.py", line 403, in unset
    feature._notifyUnlink(element,item)
  File "/usr/local/lib/python2.4/site-packages/peak/model/features.py", line 505, in _notifyUnlink
    otherEnd = getattr(item.__class__, refEnd)
AttributeError: type object 'NoneType' has no attribute 'subaccounts'
-------------------------------------------------

None is what I return as the state for the masteraccount attribute
in my DM if the account has no master account.  Is there something
besides None I should be returning as the "not set" state?  I know
it's the masteraccount field involved because I tried using ''
instead of None as the "not set" value and got the same error for
trying to access subaccounts on a string.  But I don't know why
it's even accessing the masteraccount field, which is why I think
I must be doing something stupid.

Also, what "not set" value should I use for the Collection field?

--David



More information about the PEAK mailing list