[Zope-CMF] Abusing GenericSetup during traditional installs

Martin Aspeli optilude at gmx.net
Mon Jul 31 07:35:42 EDT 2006



yuppie-2 wrote:
> 
> def install(self):
>      wftool = getToolByName(self, 'portal_workflow')
> 
>      # create empty workflow
>      obj_id = 'myWorkflow'
>      wftool._setObject(obj_id, DCWorkflowDefinition(obj_id))
>      obj = getattr(wftool, obj_id)
> 
>      # create import context
>      environ = SetupEnviron()
> 
>      # get XML body
>      product_path = os.path.split(MyProduct.__file__)[0]
>      f_name = os.path.join(product_path, 'Extensions', 'definition.xml')
>      f = file(f_name)
>      body = f.read()
>      f.close()
> 
>      # apply XML body to adapted workflow and environ
>      adapted = queryMultiAdapter((obj, environ), IBody)
>      adapted.body = body
> 

So, assigning the contents of a file to the body attribute of an IBody has
the side-effect of initialising the context of the multi adapter from obj,
environ -> IBody with the XML contents of that file?

I'm guessing I can bundle some of this functionality into a more general
interface (e.g. "addWorkflowFromXMLDefinition()") and use it in my setup
methods. At least for workflows and FTIs, this'd be great.

Martin
-- 
View this message in context: http://www.nabble.com/Abusing-GenericSetup-during-traditional-installs-tf2014550.html#a5574150
Sent from the Zope - CMF list2 forum at Nabble.com.



More information about the Zope-CMF mailing list