Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
CMFQuickInstallerTool.InstalledProduct.InstalledProduct Class Reference
Inheritance diagram for CMFQuickInstallerTool.InstalledProduct.InstalledProduct:
Inheritance graph
[legend]
Collaboration diagram for CMFQuickInstallerTool.InstalledProduct.InstalledProduct:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def update
def log
def hasError
def isLocked
def isHidden
def isVisible
def isInstalled
def getStatus
def getTypes
def getSkins
def getActions
def getPortalObjects
def getWorkflows
def getLeftSlots
def getRightSlots
def getSlots
def getValue
def getRegistryPredicates
def getAfterId
def getBeforeId
def getTranscriptAsText
def getInstallMethod
def getUninstallMethod
def getAfterInstallMethod
def getBeforeUninstallMethod
def uninstall
def getInstalledVersion

Public Attributes

 id
 transcript
 leftslots
 rightslots
 locked
 hidden
 installedversion
 status
 error
 afterid
 beforeid

Static Public Attributes

string meta_type = "Installed Product"
tuple manage_options
tuple security = ClassSecurityInfo()
tuple manage_installationInfo
list default_cascade

Private Member Functions

def _getMethod
def _cascadeRemove

Detailed Description

Class storing information about an installed product

  Let's make sure that this implementation actually fulfills the
  'IInstalledProduct' API.

  >>> from zope.interface.verify import verifyClass
  >>> verifyClass(IInstalledProduct, InstalledProduct)
  True

Definition at line 38 of file InstalledProduct.py.


Constructor & Destructor Documentation

Definition at line 67 of file InstalledProduct.py.

00067 
00068     def __init__(self, id):
00069         self.id=id
00070         self.transcript=[]
00071         self.leftslots=[]
00072         self.rightslots=[]
00073         self.locked=None
00074         self.hidden=None
00075         self.installedversion=None
00076         self.status='new'
00077         self.error=False
00078         self.afterid = None
00079         self.beforeid = None
00080         for key in DEFAULT_CASCADE:
00081             setattr(self, key, [])


Member Function Documentation

Cascaded removal of objects

Definition at line 306 of file InstalledProduct.py.

00306 
00307     def _cascadeRemove(self, cascade):
00308         """Cascaded removal of objects
00309         """
00310         portal = getToolByName(self, 'portal_url').getPortalObject() 
00311         
00312         if 'types' in cascade:
00313             portal_types=getToolByName(self,'portal_types')
00314             delObjects(portal_types, getattr(aq_base(self), 'types', []))
00315 
00316         if 'skins' in cascade:
00317             portal_skins=getToolByName(self,'portal_skins')
00318             delObjects(portal_skins, getattr(aq_base(self), 'skins', []))
00319 
00320         if 'actions' in cascade and len(getattr(aq_base(self), 'actions', [])) > 0:
00321             portal_actions=getToolByName(self,'portal_actions')
00322             if CMF21:
00323                 for info in self.actions:
00324                     if isinstance(info, basestring):
00325                         action = info
00326                         # Product was installed before CMF 2.1
00327                         # Try to remove the action from all categories
00328                         for category in portal_actions.objectIds():
00329                             cat = portal_actions[category]
00330                             if action in cat.objectIds():
00331                                 cat._delObject(action)
00332                     else:
00333                         category, action = info
00334                         if category in portal_actions.objectIds():
00335                             cat = portal_actions[category]
00336                             if action in cat.objectIds():
00337                                 cat._delObject(action)
00338                             if len(cat.objectIds()) == 0:
00339                                 del cat
00340                                 portal_actions._delObject(category)
00341             else:
00342                 actids = [o.id.lower() for o in portal_actions._actions]
00343                 delactions = [actids.index(id) for id in
00344                               getattr(aq_base(self), 'actions', ()) if id in actids]
00345                 if delactions:
00346                     portal_actions.deleteActions(delactions)
00347 
00348         if 'portalobjects' in cascade:
00349             delObjects(portal, getattr(aq_base(self), 'portalobjects', []))
00350 
00351         if 'workflows' in cascade:
00352             portal_workflow=getToolByName(self, 'portal_workflow')
00353             delObjects(portal_workflow, getattr(aq_base(self), 'workflows', []))
00354 
00355         if 'slots' in cascade:
00356             if self.getLeftSlots():
00357                 portal.left_slots=[s for s in portal.left_slots
00358                                    if s not in self.getLeftSlots()]
00359             if self.getRightSlots():
00360                 portal.right_slots=[s for s in portal.right_slots
00361                                     if s not in self.getRightSlots()]
00362 
00363         if 'registrypredicates' in cascade:
00364             ctr = getToolByName(self,'content_type_registry')
00365             ids = [id for id, predicate in ctr.listPredicates()]
00366             predicates=getattr(aq_base(self),'registrypredicates',[])
00367             for p in predicates:
00368                 if p in ids:
00369                     ctr.removePredicate(p)
00370                 else:
00371                     logger.log("Failed to delete '%s' from content type " \
00372                                "registry" % p, severity=logging.WARNING)
00373 
00374         if 'adapters' in cascade:
00375             adapters = getattr(aq_base(self), 'adapters', [])
00376             if adapters:
00377                 sm = getSiteManager()
00378                 # TODO: expand this to actually cover adapter registrations
00379 
00380         if 'utilities' in cascade:
00381             utilities = getattr(aq_base(self), 'utilities', [])
00382             if utilities:
00383                 sm = getSiteManager()
00384                 for registration in utilities:
00385                     provided = _resolveDottedName(registration[0])
00386                     name = registration[1]
00387                     if queryUtility(provided, name=name) is not None:
00388                         sm.unregisterUtility(provided=provided, name=name)
00389 
00390         rr_js = getToolByName(self, 'portal_javascripts', None)
00391         rr_css = getToolByName(self, 'portal_css', None)
00392 
00393         if rr_js is not None:
00394             for js in getattr(aq_base(self),'resources_js',[]):
00395                 rr_js.unregisterResource(js)
00396         if rr_css is not None:
00397             for css in getattr(aq_base(self),'resources_css',[]):
00398                 rr_css.unregisterResource(css)

Here is the call graph for this function:

Here is the caller graph for this function:

Returns a method

Definition at line 210 of file InstalledProduct.py.

00210 
00211     def _getMethod(self, modfunc):
00212         """Returns a method
00213         """
00214         try:
00215             productInCP = self.Control_Panel.Products[self.id]
00216         except KeyError:
00217             return None
00218 
00219         for mod, func in modfunc:
00220             if mod in productInCP.objectIds():
00221                 modFolder = productInCP[mod]
00222                 if func in modFolder.objectIds():
00223                     return modFolder[func]
00224 
00225             try:
00226                 return ExternalMethod('temp','temp',self.id+'.'+mod, func)
00227             except:
00228                 pass
00229 
00230         return None

Here is the caller graph for this function:

Definition at line 156 of file InstalledProduct.py.

00156 
00157     def getActions(self):
00158         return self.actions

Here is the call graph for this function:

Definition at line 194 of file InstalledProduct.py.

00194 
00195     def getAfterId(self):
00196         return self.afterid

returns the after installer method 

Definition at line 255 of file InstalledProduct.py.

00255 
00256     def getAfterInstallMethod(self):
00257         """ returns the after installer method """
00258         return self._getMethod((('Install','afterInstall'),
00259                                 ('install','afterInstall'),
00260                                ))

Here is the call graph for this function:

Definition at line 198 of file InstalledProduct.py.

00198 
00199     def getBeforeId(self):
00200         return self.beforeid

returns the before uninstaller method 

Definition at line 262 of file InstalledProduct.py.

00262 
00263     def getBeforeUninstallMethod(self):
00264         """ returns the before uninstaller method """
00265         return self._getMethod((('Install','beforeUninstall'),
00266                                 ('install','beforeUninstall'),
00267                                ))

Here is the call graph for this function:

Here is the caller graph for this function:

Return the version of the product in the moment of installation

Definition at line 400 of file InstalledProduct.py.

00400 
00401     def getInstalledVersion(self):
00402         """Return the version of the product in the moment of installation
00403         """
00404         return getattr(self, 'installedversion', None)
00405 
00406 InitializeClass(InstalledProduct)
returns the installer method 

Definition at line 232 of file InstalledProduct.py.

00232 
00233     def getInstallMethod(self):
00234         """ returns the installer method """
00235         res = self._getMethod((('Install','install'),
00236                                 ('Install','Install'),
00237                                 ('install','install'),
00238                                 ('install','Install'),
00239                                ))
00240         if res is None:
00241             raise AttributeError, ('No Install method found for '
00242                                    'product %s' % self.id)
00243         else:
00244             return res

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 168 of file InstalledProduct.py.

00168 
00169     def getLeftSlots(self):
00170         if getattr(self, 'leftslots', None) is None:
00171             self.leftslots = []
00172         return self.leftslots

Here is the caller graph for this function:

Definition at line 160 of file InstalledProduct.py.

00160 
00161     def getPortalObjects(self):
00162         return self.portalobjects

Return the custom entries in the content_type_registry

Definition at line 188 of file InstalledProduct.py.

00188 
00189     def getRegistryPredicates(self):
00190         """Return the custom entries in the content_type_registry
00191         """
00192         return getattr(self, 'registrypredicates', [])

Definition at line 174 of file InstalledProduct.py.

00174 
00175     def getRightSlots(self):
00176         if getattr(self, 'rightslots', None) is None:
00177             self.rightslots = []
00178         return self.rightslots

Here is the caller graph for this function:

Definition at line 152 of file InstalledProduct.py.

00152 
00153     def getSkins(self):
00154         return self.skins

Definition at line 180 of file InstalledProduct.py.

00180 
00181     def getSlots(self):
00182         return self.getLeftSlots()+self.getRightSlots()

Here is the call graph for this function:

Definition at line 144 of file InstalledProduct.py.

00144 
00145     def getStatus(self):
00146         return self.status

Definition at line 202 of file InstalledProduct.py.

00202 
00203     def getTranscriptAsText(self):
00204         if getattr(self,'transcript',None):
00205             msgs = [t['timestamp'].ISO()+'\n'+str(t['msg'])
00206                     for t in self.transcript]
00207             return '\n=============\n'.join(msgs)
00208         else:
00209             return 'no messages'

Definition at line 148 of file InstalledProduct.py.

00148 
00149     def getTypes(self):
00150         return self.types

Here is the call graph for this function:

returns the uninstaller method 

Definition at line 246 of file InstalledProduct.py.

00246 
00247     def getUninstallMethod(self):
00248         """ returns the uninstaller method """
00249         return self._getMethod((('Install','uninstall'),
00250                                 ('Install','Uninstall'),
00251                                 ('install','uninstall'),
00252                                 ('install','Uninstall'),
00253                                ))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 184 of file InstalledProduct.py.

00184 
00185     def getValue(self,name):
00186         return getattr(self,name,[])
    

Definition at line 164 of file InstalledProduct.py.

00164 
00165     def getWorkflows(self):
00166         return self.workflows

Returns if the prod is in error state

Definition at line 118 of file InstalledProduct.py.

00118 
00119     def hasError(self):
00120         """Returns if the prod is in error state
00121         """
00122         return getattr(self, 'error', False)

Is the product hidden

Definition at line 130 of file InstalledProduct.py.

00130 
00131     def isHidden(self):
00132         """Is the product hidden
00133         """
00134         return getattr(self, 'hidden', False)

Here is the caller graph for this function:

Definition at line 140 of file InstalledProduct.py.

00140 
00141     def isInstalled(self):
00142         return self.status=='installed'

Is the product locked for uninstall

Definition at line 124 of file InstalledProduct.py.

00124 
00125     def isLocked(self):
00126         """Is the product locked for uninstall
00127         """
00128         return getattr(self, 'locked', False)

Here is the caller graph for this function:

Definition at line 136 of file InstalledProduct.py.

00136 
00137     def isVisible(self):
00138         return not self.isHidden()

Here is the call graph for this function:

Adds a log to the transcript

Definition at line 112 of file InstalledProduct.py.

00112 
00113     def log(self, logmsg):
00114         """Adds a log to the transcript
00115         """
00116         self.transcript.insert(0, {'timestamp':DateTime(), 'msg':logmsg})

Here is the caller graph for this function:

def CMFQuickInstallerTool.InstalledProduct.InstalledProduct.uninstall (   self,
  cascade = default_cascade,
  reinstall = False,
  REQUEST = None 
)
Uninstalls the product and removes its dependencies

Definition at line 269 of file InstalledProduct.py.

00269 
00270     def uninstall(self, cascade=default_cascade, reinstall=False, REQUEST=None):
00271         """Uninstalls the product and removes its dependencies
00272         """
00273         portal = getToolByName(self, 'portal_url').getPortalObject() 
00274 
00275         # TODO eventually we will land Event system and could remove
00276         # this 'removal_inprogress' hack
00277         if self.isLocked() and getattr(portal, 'removal_inprogress', False):
00278             raise ValueError, 'The product is locked and cannot be uninstalled!'
00279 
00280         res=''
00281         afterRes=''
00282 
00283         uninstaller = self.getUninstallMethod()
00284         beforeUninstall = self.getBeforeUninstallMethod()
00285 
00286         if uninstaller:
00287             uninstaller = uninstaller.__of__(portal)
00288             try:
00289                 res=uninstaller(portal, reinstall=reinstall)
00290                 # XXX log it
00291             except TypeError:
00292                 res=uninstaller(portal)
00293 
00294         if beforeUninstall:
00295             beforeUninstall = beforeUninstall.__of__(portal)
00296             beforeRes, cascade = beforeUninstall(portal, reinstall=reinstall,
00297                                                 product=self, cascade=cascade)
00298         
00299         self._cascadeRemove(cascade)
00300 
00301         self.status='uninstalled'
00302         self.log('uninstalled\n'+str(res)+str(afterRes))
00303 
00304         if REQUEST and REQUEST.get('nextUrl',None):
00305             return REQUEST.RESPONSE.redirect(REQUEST['nextUrl'])

Here is the call graph for this function:

def CMFQuickInstallerTool.InstalledProduct.InstalledProduct.update (   self,
  settings,
  installedversion = '',
  logmsg = '',
  status = 'installed',
  error = False,
  locked = False,
  hidden = False,
  afterid = None,
  beforeid = None 
)

Definition at line 85 of file InstalledProduct.py.

00085 
00086                afterid=None, beforeid=None):
00087 
00088         # check for the availability of attributes before assigning
00089         for att in settings.keys():
00090             if not hasattr(self.aq_base, att):
00091                 setattr(self, att, [])
00092 
00093         qi = getToolByName(self, 'portal_quickinstaller')
00094         reg = qi.getAlreadyRegistered()
00095 
00096         for k in settings.keys():
00097             old = k in reg.keys() and reg[k] or []
00098             updatelist(getattr(self,k), settings[k], old)
00099 
00100         self.transcript.insert(0, {'timestamp':DateTime(), 'msg':logmsg})
00101         self.locked=locked
00102         self.hidden=hidden
00103         self.installedversion=installedversion
00104         self.afterid = afterid
00105         self.beforeid = beforeid
00106 
00107         if status:
00108             self.status=status
00109 
00110         self.error=error

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 77 of file InstalledProduct.py.

Definition at line 78 of file InstalledProduct.py.

Initial value:
['types', 'skins', 'actions', 'portalobjects',
                     'workflows', 'slots', 'registrypredicates',
                     'adapters', 'utilities']

Definition at line 63 of file InstalledProduct.py.

Definition at line 76 of file InstalledProduct.py.

Definition at line 73 of file InstalledProduct.py.

Definition at line 68 of file InstalledProduct.py.

Definition at line 74 of file InstalledProduct.py.

Definition at line 70 of file InstalledProduct.py.

Definition at line 72 of file InstalledProduct.py.

Initial value:
PageTemplateFile(
        'forms/installed_product_overview', globals(),
        __name__='manage_installationInfo')

Definition at line 59 of file InstalledProduct.py.

Initial value:
(
        {'label':'View','action':'manage_installationInfo'},
        )

Definition at line 52 of file InstalledProduct.py.

Definition at line 50 of file InstalledProduct.py.

Definition at line 71 of file InstalledProduct.py.

Definition at line 56 of file InstalledProduct.py.

Definition at line 75 of file InstalledProduct.py.

Definition at line 69 of file InstalledProduct.py.


The documentation for this class was generated from the following file: