title: Zope 2: Using manage_addProduct with own products (AttributeError)
body: <p>I'm a newbie to the Zope 2 programming world.  So please bear with me if I'm asking something obvious.</p>
  
  <p>I created a sample product.  All is fine in ZMI: I can easily add/remove the product and change its attributes.  However I can't add the product in code or using the Zope debug mode.  I have read OFS.Folder code (as a reference) over and over again to find any differences to no avail.</p>
  
  <p>I'd really appreciate if anyone could give me a hint/clue.  TIA,</p>
  
  <p>The product code:</p>
  
  <pre class="lang-py prettyprint-override"><code>##
  ## bahmanm.devistan.implementation.Devistan
  ##
  from bahmanm.devistan.interfaces import IDevistan
  from zope.interface import implements
  from OFS.Folder import Folder
  from Products.PageTemplates.PageTemplateFile import PageTemplateFile
  from Acquisition import Implicit
  from Globals import Persistent, InitializeClass
  from AccessControl.Role import RoleManager
  from OFS.ObjectManager import ObjectManager
  from OFS.PropertyManager import PropertyManager
  from OFS.FindSupport import FindSupport
  
  
  class Devistan(Implicit, Persistent, RoleManager, Folder):
      """Devistan product implementation.
      """
      implements(IDevistan)
      meta_type = 'Devistan Site'
      _properties = ({'id': 'title', 'type': 'string', 'mode': 'wd'},)
      manage_options = (
          ObjectManager.manage_options +
          ({'label': 'View', 'action': ''}, ) +
          PropertyManager.manage_options +
          RoleManager.manage_options +
          Folder.manage_options +
          FindSupport.manage_options
          )
      index_html = PageTemplateFile(
          '../template/devistan/index.pt', globals())
  
      def __init__(self, id=None):
          if id is not None:
              self.id = str(id)
  
  InitializeClass(Devistan)
  
  
  manage_addDevistanForm = PageTemplateFile(
      '../template/devistan/manage_addDevistanForm.pt', globals())
  
  
  def manage_addDevistan(self, id, title='', REQUEST=None):
      """Adds a new Devistan instance.
      """
      obj = Devistan(id)
      obj.title = title
      self._setObject(id, obj)
      if REQUEST is not None:
          return self.manage_main(self, REQUEST, update_menu=1)
      return "&lt;p&gt;Devistan instance successfully installed: &lt;tt&gt;%s&lt;/tt&gt;" % id
  
  
  def initialize(self):
      self.registerClass(
          Devistan,
          constructors=(manage_addDevistanForm,
                        manage_addDevistan))
  </code></pre>
  
  <p><code>__init__.py</code> code:</p>
  
  <pre class="lang-py prettyprint-override"><code>##
  ## bahman.devistan.__init__.py
  ##
  from bahmanm.devistan.implementation import Devistan
  
  
  def initialize(self):
      """Registers Devistan product.
      """
      Devistan.initialize(self)
  </code></pre>
  
  <p>The stacktrace when calling <code>manage_addDevistan</code> from a sample page:</p>
  
  <pre><code>2013-01-07 15:43:11 ERROR Zope.SiteErrorLog 1357560791.840.323411816939 http://localhost:8080/devistan/addSampleSite
  Traceback (innermost last):
    Module ZPublisher.Publish, line 126, in publish
    Module ZPublisher.mapply, line 77, in mapply
    Module ZPublisher.Publish, line 46, in call_object
    Module bahmanm.devistan.implementation.Devistan, line 37, in addSampleSite
  </code></pre>
  
  <p>The output in Zope's debug mode:</p>
  
  <pre><code>&gt;&gt;&gt; app.manage_addProduct['Devistan'].manage_addDevistan
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  AttributeError: manage_addDevistan
  </code></pre>
  
  <p>buildout.cfg:</p>
  
  <pre><code>[buildout]
  parts = zope2
          instance
  extends = http://download.zope.org/Zope2/index/2.13.19/versions.cfg
  develop = /home/bahman/Work/devistan/bahmanm.devistan
  
  [zope2]
  recipe = zc.recipe.egg
  eggs = Zope2
         bahmanm.devistan
  interpreter = zopepy
  debug-mode = on
  
  [instance]
  debug-mode = on
  recipe = plone.recipe.zope2instance
  user = admin:admin
  http-address = 8080
  eggs = ${zope2:eggs}
  zcml = bahmanm.devistan
  </code></pre>