Hey John, Shouldn't your class also inherit from Globals.Persistent and Aquisition.Implicit? BTW the Zope Bible has does good job describing the zope product developement. David ----- Original Message ----- From: "John Hunter" <jdhunter@ace.bsd.uchicago.edu> To: <zope@zope.org> Sent: Monday, June 14, 2004 3:06 PM Subject: [Zope] zope product, object manager problem
I have a zope interface Person with a PersonImplementation that inherits from OFS.ObjectManager. When I try to add some product (eg a Folder) instance to an instance of a Person, everything appears to work, but nothing shows up in the listing of the person.
Eg if I go to
http://my.server:8080/sandbox/jdh/manage_main
where jdh is a Person instance, I see
There are currently no items in jdh
I am posting my code below in hopes someone can point out my mistake. I am trying to follow the code example from the ZDG.
Thanks, John Hunter
(Zope 2.5.1b1 (source release, python 2.1, linux2), python 2.1.3, linux2)
from Person import Person import Products from AccessControl import ClassSecurityInfo from Globals import DTMLFile, InitializeClass from OFS.SimpleItem import SimpleItem from OFS.PropertyManager import PropertyManager from OFS.ObjectManager import ObjectManager
class PersonImplementation(SimpleItem, PropertyManager, ObjectManager): """ Person product class, implements Person interface. """
__implements__=Person
meta_type='Person' security=ClassSecurityInfo()
_properties=({'id':'first', 'type': 'string', 'mode': 'w'}, {'id':'last', 'type': 'string', 'mode': 'w'}, )
#_allowed_meta_types = ('Address', )
manage_options = ( ObjectManager.manage_options + PropertyManager.manage_options + SimpleItem.manage_options + ( { 'label' : 'View', 'action' : 'index_html', }, ) )
security.declarePublic('index_html') #security.declareProtected('View management screens', 'index_html') index_html=DTMLFile('www/person/index_html', globals())
def __init__(self, id, first, last): self.id=id self.first = first self.last = last
security.declarePublic('getFullName') def getFullName(self): "Return full name" return '%s %s' % (self.first, self.last)
def getAge(self): "Return age" return 12
def all_meta_types(self): """ Returns what meta_types can be added to the objectmanager """ if hasattr(self, '_allowed_meta_types'): result = [] for metaType in Products.meta_types: if metaType['name'] in self._allowed_meta_types: result.append(metaType) return result else: return Products.meta_types
def addPersonForm(dispatcher): """ Returns an HTML form. """ return """<html> <head><title>Add Person</title></head> <body> <form action="addPersonFunction"> id <input type="type" name="id"><br> first <input type="type" name="first"><br> last <input type="type" name="last"><br> <input type="submit" value="Add"> </form> </body> </html>"""
def addPersonFunction(dispatcher, id, first, last, REQUEST=None): """ Create a new person and add it to myself """ n=PersonImplementation(id, first, last) dispatcher.Destination()._setObject(id, n)
if REQUEST is not None: return dispatcher.manage_main(dispatcher, REQUEST)
InitializeClass(PersonImplementation)
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )