[Zope-CMF] Re: Add file inside CMF product during install

Raphael Ritz r.ritz at biologie.hu-berlin.de
Mon Mar 1 03:32:01 EST 2004



Steinar Eriksen wrote:
> I would like to add a file during my CMF product installation; specifically
> I would like to have a JavaScript being added via Install.py to the product
> folder after installing my product to a Plone site.
> 
> 
> I can manually add the script (as an external file) inside the ZMI after
> setting up my product but I would like to have it added automatically as
> part of the product install.
> 
> Can I accomplish this somehow?
> 

Quoting from
http://www.neuroinf.de/LabTools/ScriptingCMF-0_1.tgz/view
you can see an example in the following:

def addCMFSin(self, site_id):
     """ install the CMFSin product """

     # The installation works the same way as before:

     # Get the site ...

     site = getSite(self, site_id)

     # ... create the install method ...

     site.manage_addProduct['ExternalMethod'].manage_addExternalMethod(
         'install_cmfsin',
         'from http://sourceforge.net/projects/collective',
         'CMFSin.Install',
         'install')

     # ... and invoke it to install CMFSin.

     site.install_cmfsin()


     # Now we want to configure the tool a bit:

     # Again, we need the content of a file.
     # This time it is again located in a subdirectory
     # of the 'Extensions' folder.

     instance_home = self.Control_Panel.getINSTANCE_HOME()
     filepath = path.join(instance_home,
                          "Extensions",
                          "ScriptingResources",
                          "sin_demo.cfg")

     cfg_content = open(filepath,'r').read()

     # Set the configuration as specified in the file:

     site.sin_tool.manage_configSin(config=cfg_content,
                                    submit='Set Config')

     # 'manage_configSin' is a method of the 'SinTool' class
     # defined in Products.CMFSin.SinTool.py
     # 'submit' can be set to 'Import', 'Export', or 'Set Config'
     # to trigger different actions.
     # In the web interface this is reflected by different
     # buttons with the respective labels.


     # Finally, add the 'zope_news' slot to the right-hand side
     # of the portal's homepage by setting the value of 'right_slots'
     # completely anew here. This will only affect Plone 1 sites since
     # CMFDefault sites don't provide this property and Plone 2 has
     # a different syntax here.

     site.manage_changeProperties(
         {'right_slots':['here/workflow_review_slot/macros/review_box',
                         'here/calendar_slot/macros/calendarBox',
                         'here/events_slot/macros/eventsBox',
                         'here/sin_tool/macros/zope_news'
                         ]
          })

     # 'manage_changeProperties' is another method of the
     # 'PropertyManager' mentioned above.
     [...]

Raphael

> Regards
> 
> Steinar Eriksen
> 
> 
> 
> 
> 
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> 
> 
> 
> 
> _______________________________________________
> 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