On Fri, 2007-09-07 at 14:07 -0700, badfrog wrote:
> class State(SQLObject):
> ABBREVIATION_LENGTH = 2
> NAME_LENGTH = name_field_length
>
> abbreviation = StringCol(length=ABBREVIATION_LENGTH,
> alternateID=True)
> name = StringCol(length=NAME_LENGTH)
>
> # class methods
> def optionList():
I think you need:
@classmethod
def optionList(class_):
> list = []
> for state in State.select(orderBy=State.q.abbreviation):
for state in
class_.select(orderBy=State.q.abbreviation):
> list.append((state.id, state.abbreviation))
> return list
Some people prefer klass to class_
>
> >>> State.optionList()
> Traceback (most recent call last):
> File "<console>", line 1, in ?
> TypeError: unbound method optionList() must be called with State
> instance as fir
> st argument (got nothing instead)
>
> Don't get this one. Why is python treating this like an instance
> method? And yes, the indents line up in the original source.
>
>
>
--
Lloyd Kvam
Venix Corp
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---