I've got a pair of classes that look like this:
-- ledger.py --
import sqlobject, sqlobject.inheritance
import config
=66rom account import account
class ledger(sqlobject.inheritance.InheritableSQLObject):
"""class representing line in the ledger"""
_connection =3D config.config()['dbconnection']
creditor =3D sqlobject.ForeignKey('account')
debtor =3D sqlobject.ForeignKey('account')
amount =3D sqlobject.CurrencyCol(default=3D0)
date =3D sqlobject.DateTimeCol()
-- payment.py --
import sqlobject
import config
=66rom ledger import ledger
class payment(ledger):
"""class representing a payment made by a housemate"""
=20
_connection =3D config.config()['dbconnection']
bill =3D sqlobject.ForeignKey('bill',default=3DNone)
receipt =3D sqlobject.StringCol(default=3D"")
which is doing the right thing when I instantiate a payment object, and it
correctly demands that I specify the creditorID and debtorID on object
creation.
However, if I try to print out the creditorID from the object, or try to set
it, either the hasattr builtin says that payment has no creditorID
attribute, or I get this error message:
>>> p.creditorID
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 1, in <lambda>
File "sqlobject/sqlobject/main.py", line 854, in _SO_loadValue
result =3D getattr(self, attrName)
AttributeError: 'payment' object has no attribute '_SO_val_creditorID'
But the dir of the object does show both 'creditor' and 'creditorID' in the
object's dictionary. Interestingly, if I print out p.creditor, that works.
(But I'm using a form which sets the payment's creditor based on the
creditor's ID, from a select box, so I'd really like to be able to do it
this way).
Any ideas? I'm using a SVN checkout from a few weeks ago, svn info suggests
it's June 1st.
|