[Zope] Adding instance of ZDiscussions programmatically

Dennis Allison allison@sumeru.stanford.EDU
Fri, 26 Jul 2002 12:00:27 -0700


Chris pointed out my initial question was pretty vague and my response to him was 
not much better.  Here's a more specific statement--

I want to add instances of ZDTopics (that is ZDiscussion Topics) programmatically.

I've constructed a DTML Method per the How-To:

<dtml-var standard_html_header>
<dtml-call expr="REQUEST.set('id', 'newDiscussion')">
<dtml-call expr="REQUEST.set('title', 'The neDiscussion Title')">
<dtml-call expr="REQUEST.set('add_default_methods','yes')">
<dtml-with "manage_addProduct['ZDTopic']">
   <dtml_call "ZDTopic_add(_.None, _, NoRedir=1)">
</dtml-with>
<dtml-var standard_html_footer>

and modified the ZDTopic_add method for the product to accept NoRedir as a flag
to not redirect to manage_workspace.

Running this generates a Zope error:

| Zope Error
| Zope has encountered an error while publishing this resource.
| Error Type: AttributeError
| Error Value: ZDTopic
| 
| Traceback (innermost last):
|   File /var/zope/lib/python/ZPublisher/Publish.py, line 150, in publish_module
|   File /var/zope/lib/python/ZPublisher/Publish.py, line 114, in publish
|   File /var/zope/lib/python/Zope/__init__.py, line 159, in zpublisher_exception_hook
|     (Object: dashboard_for_groups)
|   File /var/zope/lib/python/ZPublisher/Publish.py, line 98, in publish
|   File /var/zope/lib/python/ZPublisher/mapply.py, line 88, in mapply
|     (Object: createGroupDiscussion)
|   File /var/zope/lib/python/ZPublisher/Publish.py, line 39, in call_object
|     (Object: createGroupDiscussion)
|   File /var/zope/lib/python/OFS/DTMLMethod.py, line 127, in __call__
|     (Object: createGroupDiscussion)
|   File /var/zope/lib/python/DocumentTemplate/DT_String.py, line 473, in __call__
|     (Object: createGroupDiscussion)
|   File /var/zope/lib/python/DocumentTemplate/DT_With.py, line 61, in render
|     (Object: manage_addProduct['ZDTopic'])
|   File /var/zope/lib/python/DocumentTemplate/DT_Util.py, line 159, in eval
|     (Object: manage_addProduct['ZDTopic'])
|     (Info: manage_addProduct)
|   File <string>, line 2, in f
|   File /var/zope/lib/python/AccessControl/DTML.py, line 32, in guarded_getitem
|     (Object: createGroupDiscussion)
|   File /var/zope/lib/python/AccessControl/ZopeGuards.py, line 90, in guarded_getitem
|   File /var/zope/lib/python/App/FactoryDispatcher.py, line 27, in __getitem__
|   File /var/zope/lib/python/App/FactoryDispatcher.py, line 30, in __bobo_traverse__
|   File /var/zope/lib/python/App/Product.py, line 66, in _product
|     (Object: Products)
| AttributeError: (see above)

The ZDiscussion ZClass is pretty much out of the box in terms of structure although 
the compents have been significantly customized.

Clearly ZDTopic is not being found by manage_addProduct.  What I've not been able to 
track down is why.  ZDtopic inherits from ZObject and _ZClass_for_ZDTopic (that's
the Python base class, I believe) but apparently not from ObjectManager.  Is that
the source of the problem.  Or is it permissions?  How should the permissions be 
set?