On Oct 30, 3:27 pm, [EMAIL PROTECTED] wrote:
> I have a model like so...
>
> class Employee(SQLObject):
>     email = UnicodeCol(length=255, alternateID=True)
>     fname = UnicodeCol(length=50)
>     lname = UnicodeCol(length=50)
>     supervisor = ForeignKey('User')
>     incidents = MultipleJoin('Incidents')
>
> class Incidents(SQLObject):
>     employee = ForeignKey('Employee')
>     subject = UnicodeCol(length=50)
>     itype = UnicodeCol(length=1)
>     comments = StringCol()
>
> I want to display the total number of incidents for an employee.
>
> I thought I could just do this.
>
> emp = Employee.get(1)
> print emp.incidents.count
>
> But this just returns this ...
> <built-in method count of list object at 0x02727F80>

Looks like count is a method, not a property. (I think count is a
property in several other languages, like Javascript). Try:

print emp.incidents.count()

See how that goes? If that doesn't work, what about:

print len(emp.incidents)

I expect the latter is at least as efficient as the former, if they
both exist.

--
Ben Sizer


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to