[Zope-CMF] Problem adding CMF Topics with quickinstaller
matt.bartolome at uniontrib.com
matt.bartolome at uniontrib.com
Wed Sep 24 14:12:39 EDT 2003
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()
More information about the Zope-CMF
mailing list