EduploneLearningSequence/Extensions Install.py,1.5,1.6

Jens Klein <[email protected]>
Newsgroups gmane.comp.web.zope.eduplone.cvs
Message-ID <[email protected]>
Update of /cvsroot/eduplone/EduploneLearningSequence/Extensions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29158/Extensions

Modified Files:
	Install.py 
Log Message:
a more modern installation method


Index: Install.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneLearningSequence/Extensions/Install.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Install.py	18 Mar 2004 13:02:51 -0000	1.5
--- Install.py	14 Jun 2004 16:05:25 -0000	1.6
***************
*** 15,19 ****
  
  
! from Products.Archetypes.Extensions.utils import installTypes
  from Products.Archetypes import listTypes
  from Products.EduploneLearningSequence import PROJECTNAME,GLOBALS
--- 15,19 ----
  
  
! from Products.Archetypes.Extensions.utils import installTypes, install_subskin
  from Products.Archetypes import listTypes
  from Products.EduploneLearningSequence import PROJECTNAME,GLOBALS
***************
*** 23,151 ****
  from StringIO import StringIO
  
- class PloneSkinRegistrar:
-     """
-     Controls (un)registering of a layer in the skins tool:
-      - the layer in the content of the skin tool
-      - the layer in the path of all skins
-     @author: U{Gilles Lenfant <[email protected]>}
-     @version: 0.1.0
-     @ivar _layer: Name of the Product's subdirectory that contains
-         the various layers for the Product.
-     @type _layer: string
-     @ivar _prodglobals: Globals from this Product.
-     @type _propglobals: mapping object
-     """
- 
-     def __init__(self, skinsdir, prodglobals):
-         """Constructor
-         @param skinsdir: Name of the Product's subdirectory that
-             contains the various layers for the Product.
-         @type skinsdir: string
-         @param prodglobals: Globals from this Product.
- 
-             should be provided by Product's C{__init__.py} like this:
- 
-             C{product_globals = globals()}
- 
-         @type propglobals: mapping object
-         @return: None
-         """
- 
-         self._skinsdir = skinsdir
-         self._prodglobals = prodglobals
-         return
- 
-     def install(self, aq_obj):
-         """Installs and registers the skin resources
-         @param aq_obj: object from which cmf site object is acquired
-         @type aq_obj: any Zope object in the CMF
-         @return: Installation log
-         @rtype: string
-         """
- 
-         rpt = '=> Installing and registering layers from '+\
-               'directory %s\n' % self._skinsdir
-         skinstool = getToolByName(aq_obj, 'portal_skins')
- 
-         # Create the layer in portal_skins
- 
-         if self._skinsdir not in skinstool.objectIds():
-             addDirectoryViews(skinstool, self._skinsdir, self._prodglobals)
-             rpt += 'Added "%s" directory view to portal_skins\n' % self._skinsdir
-         else:
-             rpt += 'Warning: directory view "%s" already added to portal_skins\n' % self._skinsdir
- 
-         # Insert the layer in all skins
-         # XXX FIXME: Actually assumes only one layer directory with the name 
-         # of the Product (should be replaced by a smarter solution that finds 
-         # individual Product's layers)
- 
-         layerName = 'EduploneLearningSequence' #self._prodglobals['__name__'].split('.')[-1]
-         skins = skinstool.getSkinSelections()
-         for skin in skins:
-             layers = skinstool.getSkinPath(skin)
-             layers = [layer.strip() for layer in layers.split(',')]
-             if layerName not in layers:
-                 try:
-                     layers.insert(layers.index('content'), layerName)
-                 except ValueError:
-                     layers.append(layerName)
-                 layers = ','.join(layers)
-                 skinstool.addSkinSelection(skin, layers)
-                 rpt += 'Added "%s" to "%s" skin\n' % (layerName, skin)
-             else:
-                 rpt += '! Warning: skipping "%s" skin, "%s" is already set up\n' % (skin, type)
-         return rpt
- 
-     def uninstall(self, aq_obj):
-         """Uninstalls and unregisters the skin resources
-         @param aq_obj: object from which cmf site object is acquired
-         @type aq_obj: any Zope object in the CMF
-         @return: Uninstallation log
-         @rtype: string
-         """
- 
-         rpt = '=> Uninstalling and unregistering %s layer\n' % self._skinsdir
-         skinstool = getToolByName(aq_obj, 'portal_skins')
- 
-         # Removing layer from portal_skins
-         # XXX FIXME: Actually assumes only one layer directory with the name of the Product
-         # (should be replaced by a smarter solution that finds individual Product's layers)
- 
-         layerName = self._prodglobals['__name__'].split('.')[-1]
-         if layerName in skinstool.objectIds():
-             skinstool.manage_delObjects([layerName])
-             rpt += 'Removed "%s" directory view from portal_skins\n' % layerName
-         else:
-             rpt += '! Warning: directory view "%s" already removed from portal_skins\n' % layerName
- 
-         # Removing from skins selection
- 
-         skins = skinstool.getSkinSelections()
-         for skin in skins:
-             layers = skinstool.getSkinPath(skin)
-             layers = [layer.strip() for layer in layers.split(',')]
-             if layerName in layers:
-                 layers.remove(layerName)
-                 layers = ','.join(layers)
-                 skinstool.addSkinSelection(skin, layers)
-                 rpt += 'Removed "%s" to "%s" skin\n' % (layerName, skin)
-             else:
-                 rpt += 'Skipping "%s" skin, "%s" is already removed\n' % (skin, layerName)
-         return rpt
- # /class PloneSkinRegistrar
- 
- 
  def install(self):
      out = StringIO()
  
!     # install dependencies
! ##    qi=getToolByName(self, 'portal_quickinstaller')
! ##    if not qi.isProductInstalled('EduploneTypes'):
! ##        print "Install dependend 'EduploneTypes'."
! ##        qi.installProduct('EduploneTypes')
! ##    if not qi.isProductInstalled('CMFOpenflow'):
! ##        print "Install dependend 'CMFOpenflow'."
! ##        qi.installProduct('CMFOpenflow',)
      
      classes=listTypes(PROJECTNAME)
--- 23,30 ----
  from StringIO import StringIO
  
  def install(self):
      out = StringIO()
  
!     install_dependencies(self,out)
      
      classes=listTypes(PROJECTNAME)
***************
*** 153,160 ****
                   classes,
                   PROJECTNAME)
! 
!     print >> out, "Successfully installed %s." % PROJECTNAME
!     sr = PloneSkinRegistrar('skins', product_globals)
!     print >> out,sr.install(self)
  
      #register folderish classes in use_folder_contents
--- 32,36 ----
                   classes,
                   PROJECTNAME)
!     install_subskin(self, out, GLOBALS)
  
      #register folderish classes in use_folder_contents
***************
*** 282,285 ****
--- 158,163 ----
  ##    portal.manage_permission('Use external editor',       ['eduploneAuthor',],1)    
      portal.manage_permission('Use OpenFlow',              ['eduploneLearner','eduploneTutor',],1)    
+ 
+     print >> out, "Successfully installed %s." % PROJECTNAME
          
      return out.getvalue()
***************
*** 330,335 ****
      portal.__ac_roles__=tuple(data)
      
- 
      return out.getvalue()
  
  
--- 208,218 ----
      portal.__ac_roles__=tuple(data)
      
      return out.getvalue()
  
+ def install_dependencies(self, out):
+     deps = ['EduploneTypes','CMFOpenflow']
+     print >> out, '%s depends on %s, try to auto-install.' % (PROJECTNAME,','.join(deps))
+     qi = getToolByName(self,'portal_quickinstaller')
+     qi.installProducts(deps, stoponerror=1)
+ 
  



-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.