Finally, let us consider how to use forms in a generic viewlet. In Chapter 2, we presented the requirement to allow users to rate films. To manage film ratings, we have added an
IRatings interface to
class IRatings(Interface): """An object which can be rated """ score = schema.Int(title=_(u"A score from 1-100"), readonly=True) def available(user_token): """Whether or not rating is available for the given user """ def rate(user_token, positive): """Give a positive (True) or negative (False) vote. """
ratings.py, there is an adapter from
IRatings, which stores ratings in annotations on a Film object. We will not reproduce that code here, but take a look at the class and its doctest ...