Hi!
Opening up a new thread since the old one is using some old ideas, but still thanks to Douglas for replying :) What I'm really trying to do is probably analogous to the buzzword "tagging". In other words a component can have a list of keywords that describe it. I saw Jeff's sketchy solution in another thread but he basically used dublincore..
I want to implement it with my own annotations. Here's my idea:


------------

class ITaggable(IAnnotatable):
    """Marker interface for components that can be tagged"""

class ITagging(Interface):
    tags = List(Word())

-------------
KEY = "foo.bar"

class Tagging(object):
    implements(ITagging)
    adapts(ITaggable)

     def __init__(self, context):
         self.context = self.__parent__ = context
         tags = IAnnotations(context).get(KEY)
         if tags is None:
             tags = annotations[KEY] = PersistentList()
         self.tags = tags
--------------

  <adapter
      factory=".tagging.Tagging"
      trusted="true"
      locate="true"
      />

  <class class=".tagging.Tagging">
    <require
        permission="zope.View"
        interface=".interfaces.ITagging"
        />
  </class>
-----------


Any class that wants to be taggable needs to have ITaggable in its <implements interface="..."/>. And then i simply add Fields(ITagging) to the form_fields of the Add and Edit form. This doesn't work, tags doesn't get written and I think something is missing in the Tagging implementation because how would the add/edit-forms know how
to write to the tags attribute?

btw, here's my implementation of the Word schema field i wrote:

class Word(TextLine):
     """A word cannot contain spaces"""
     def constraint(self, value):
return super(Word, self).constraint(value) and ' ' not in value


Thanks!
Setava
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to