Le samedi 12 mai 2007 à 14:47 +0000, TiNo a écrit :
> Hi, I have the following model (only relevant parts copied):
> 
> ----------------------------------------------------
> class Photo(SQLObject):
>       filename = StringCol(length=30,alternateID=True)
>       keywords = RelatedJoin('Keyword')
>         [etc...]
> 
> class Keyword(SQLObject):
>       keyword = StringCol(alternateID=True)
>       photo = RelatedJoin('Photo')
> ------------------------------------------------------
> 
> Now I want to try the following. I want Photo to accept a string of
> keywords, and then add these keywords to the foto. I tried adding the
> following method to Photo, but it gives me an error:
> 
> ------------------------------------------------------
>       def _set_keywords(self,value):
>               # accepts value as a string. Multiple keywords should be comma-
> seperated
>               keywords = value.split(',')
>               for keyword in keywords:
>                       keyword = keyword.strip()
>                       try:
>                               ref = Keyword.byKeyword(keyword)
>                       except SQLObjectNotFound:
>                               ref = Keyword(keyword=keyword)
>                       self.addKeyword(ref)

and if you just try to replace the last line above by:

self.keywords.append(ref)

How does it work ?

Regards,
Florent.


--~--~---------~--~----~------------~-------~--~----~
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