From: Todd B. <it...@it...> - 2004-10-11 03:25:52
|
In the following class definition, I would expect organization.phone_numbers to contain the phone numbers associated with the organization. However, they are defined in organizaiton.phoneNumbers instead. I explicitly stated I wanted them in organization.phone_numbers. Why bother assigning RelatedJoins in the examples if the member the coder assigns is irrelevant? P.S. Thanks for a terrific piece of code! I absolutely can't live without SQLObject now that I've taken a short amount of time to learn it. --- 8< --- class Organization(SQLObject): _table = "organizations" url = StringCol(length=128) name = StringCol(length=64) shipping_address = ForeignKey("Address") billing_address = ForeignKey("Address") addresses = RelatedJoin('Address', joinColumn='organization_id', otherColumn='address_book_id', intermediateTable='organizations_pivot_address_book') phone_numbers = RelatedJoin('PhoneNumber', joinColumn='organization_id', otherColumn='phone_book_id', intermediateTable='organizations_pivot_phone_book') --- 8< --- >>> organization = Organization.get(1) >>> organization.phone_numbers Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'Organization' object has no attribute 'phone_numbers' >>> organization.phoneNumbers [<PhoneNumber 1 phone_number='(508) 555-2885' name='Phone'>, <PhoneNumber 2 phone_number='(978) 555-0058' name='Facsimile'>] -- Todd Boland Charged Software (508) 887-2885 Facsimile: (978) 264-0058 -- Statement of Confidentiality: The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify Todd Boland, at (508) 887-2885 immediately, and destroy all copies of this message and any attachments. |