[Zope-CMF] Problem adding CMF Topics with quickinstaller

Raphael Ritz ritz at itb.biologie.hu-berlin.de
Mon Sep 29 07:01:39 EDT 2003


Did you solve this in the meantime?

If not, you might want to look at
http://www.neuroinf.de/LabTools/ScriptingCMF-0_1.tgz/view
and there in particular at the source of 'ScriptSite.py'.
It generates and configures (among other things) a topic
from the script which works right away. Maybe you can
find out where it differs from your approach?

Raphael

matt.bartolome at uniontrib.com wrote:

>I have an Install.py script in an archetypes product that adds CMF Topics
>(using portal_quickinstaller). Everything appears to install correctly
>except that the criteria is not being recognized in the topics when viewing
>them through the web. The criteria are shown in the topic interface, they
>just don't work. When I click "save" in the criteria tab in plone the
>criteria are suddenly recognized. Weird.
>
>from Products.Archetypes.public import listTypes
>from Products.Archetypes.Extensions.utils import installTypes,
>install_subskin
>from Products.CMFCore.utils import getToolByName 
>from Products.Classifieds.config import *
>
>from StringIO import StringIO
>
>def install(self):
>    out = StringIO()
>    portalroot = getToolByName(self, 'portal_url').getPortalObject()
>
>    for topicid in TOPIC_MAPPINGS.keys():
>        id = str(topicid[0]) + '-' + str(topicid[1])
>        try:
>            portalroot.invokeFactory(id=id,type_name='Topic')
>        except:
>            pass
>        topic_o = portalroot._getOb(id)
>
>        topic_o.edit(acquireCriteria=None
>                , title=TOPIC_MAPPINGS[topicid]
>                , description=None )
>        
>        field = 'Section'
>        criterion_type = 'Integer Criterion'
>        
>        topic_o.addCriterion(field=field, criterion_type=criterion_type)
>        criteria_o = topic_o.getCriterion(field)
>        range = str(topicid[0] - 1) + ' ' + str(topicid[1] + 1)
>        criteria_o.edit(range,direction='min:max')
>                       
>        for rec in topic_o.listCriteria():
>            crit = topic_o.getCriterion(rec.id)
>            command = {}
>            for attr in crit.editableAttributes():
>                tmp = getattr(rec, attr, None)
>        
>                if tmp is None:
>                    tmp = getattr(rec, '%s__%s' % (attr, rec.id), None)
>                command[attr] = tmp
>            crit.apply(command)
>
>    installTypes(self, out,
>                 listTypes(PROJECTNAME),
>                 PROJECTNAME)
>
>    install_subskin(self, out, GLOBALS)
>
>    print >> out, "Successfully installed %s." % PROJECTNAME
>    return out.getvalue()
>
>_______________________________________________
>Zope-CMF maillist  -  Zope-CMF at zope.org
>http://mail.zope.org/mailman/listinfo/zope-cmf
>
>See http://collector.zope.org/CMF for bug reports and feature requests
>  
>





More information about the Zope-CMF mailing list