[Zope3-Users] design question

Ruslan Spivak rspivak at nuxeo.com
Mon Feb 7 15:21:15 EST 2005


Hello.

I'm wondering how better in Z3 implement following case(i'm newbie, so
please don't beat me too much if question seems too simplistic):
BlogEntry component need to store Trackback objects representing
incoming trackbacks.
In Z2 i would create attribute of type IOBTree on BlogEntry like
trackbacks = IOBTree()
and add couple of methods like addTrackback, getTrackback,
getSortedTrackbacks... that operates on 'trackbacks' attribute.
But how would be better to implement that in Z3?
Should i create ITrackback adapter on BlogEntry that stores
trackbacks in annotation attribute on BlogEntry, something like this:

class Trackback:
  implements(ITrackback)
  adapts(IBlogEntry)

  def __init__(self, context):
    self.context = context
    self._annotations = IAnnotations(context)
    if not self._annotations:
        self._annotations['trackback_key'] = IOBTree()
  
  def addTrackback(self, ...):
     ...

In the above all Trackback instances will be stored under one key in
IOBTree.

Or should Trackbacks be stored as subobjects of BlogEntry?

Also BlogEntry object should have comments - here it's litle bit clearer
for me as i looked at zwiki and bugtracker source: comments there
implemented as components that are stored as subobjects of corresponding
containers...
TIA

Ruslan





More information about the Zope3-users mailing list