[Checkins] SVN: z3ext.product/tags/1.1.0/ tag for release
Nikolay Kim
fafhrd at datacom.kz
Tue Aug 5 10:39:14 EDT 2008
Log message for revision 89395:
tag for release
Changed:
A z3ext.product/tags/1.1.0/
D z3ext.product/tags/1.1.0/buildout.cfg
A z3ext.product/tags/1.1.0/buildout.cfg
U z3ext.product/tags/1.1.0/setup.py
D z3ext.product/tags/1.1.0/src/z3ext/product/product.py
A z3ext.product/tags/1.1.0/src/z3ext/product/product.py
D z3ext.product/tags/1.1.0/src/z3ext/product/view.pt
A z3ext.product/tags/1.1.0/src/z3ext/product/view.pt
D z3ext.product/tags/1.1.0/src/z3ext/product/view.py
A z3ext.product/tags/1.1.0/src/z3ext/product/view.py
-=-
Copied: z3ext.product/tags/1.1.0 (from rev 89391, z3ext.product/trunk)
Deleted: z3ext.product/tags/1.1.0/buildout.cfg
===================================================================
--- z3ext.product/trunk/buildout.cfg 2008-08-05 14:02:55 UTC (rev 89391)
+++ z3ext.product/tags/1.1.0/buildout.cfg 2008-08-05 14:39:14 UTC (rev 89395)
@@ -1,18 +0,0 @@
-[buildout]
-develop = .
-parts = test coverage-test coverage-report
-
-[test]
-recipe = zc.recipe.testrunner
-eggs = z3ext.product [test]
-
-[coverage-test]
-recipe = zc.recipe.testrunner
-eggs = z3ext.product [test]
-defaults = ['--coverage', '../../coverage']
-
-[coverage-report]
-recipe = zc.recipe.egg
-eggs = z3c.coverage
-scripts = coverage=coverage-report
-arguments = ('coverage', 'coverage/report')
Copied: z3ext.product/tags/1.1.0/buildout.cfg (from rev 89394, z3ext.product/trunk/buildout.cfg)
===================================================================
--- z3ext.product/tags/1.1.0/buildout.cfg (rev 0)
+++ z3ext.product/tags/1.1.0/buildout.cfg 2008-08-05 14:39:14 UTC (rev 89395)
@@ -0,0 +1,20 @@
+[buildout]
+develop = .
+parts = test coverage-test coverage-report
+versions = versions
+extends = http://download.zope.org/zope3.4/versions.cfg
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3ext.product [test]
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3ext.product [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
Modified: z3ext.product/tags/1.1.0/setup.py
===================================================================
--- z3ext.product/trunk/setup.py 2008-08-05 14:02:55 UTC (rev 89391)
+++ z3ext.product/tags/1.1.0/setup.py 2008-08-05 14:39:14 UTC (rev 89395)
@@ -21,7 +21,7 @@
def read(*rnames):
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-version = '1.0.3dev'
+version = '1.1.0'
setup(name='z3ext.product',
Deleted: z3ext.product/tags/1.1.0/src/z3ext/product/product.py
===================================================================
--- z3ext.product/trunk/src/z3ext/product/product.py 2008-08-05 14:02:55 UTC (rev 89391)
+++ z3ext.product/tags/1.1.0/src/z3ext/product/product.py 2008-08-05 14:39:14 UTC (rev 89395)
@@ -1,147 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-
-$Id: product.py 1843 2008-03-25 18:39:00Z fafhrd91 $
-"""
-from BTrees.OOBTree import OOBTree
-
-from zope import interface, event
-from zope.component import getSiteManager
-from zope.component import getUtility, queryUtility, getUtilitiesFor
-
-from z3c.configurator import configure
-
-import z3ext.product
-from z3ext.controlpanel.configlettype import ConfigletProperty
-
-from z3ext.product.i18n import _
-from z3ext.product import interfaces
-from z3ext.product.interfaces import IProduct, IProductExtension
-
-
-class Product(object):
- """ base product class """
- interface.implements(IProduct)
-
- __installed__ = ConfigletProperty(IProduct['__installed__'])
-
- def install(self):
- if self.__installed__:
- raise interfaces.ProductAlreadyInstalledError(
- _('Product already installed.'))
-
- self.__installed__ = True
-
- sm = getSiteManager()
-
- registry = getattr(z3ext.product, self.__product_name__)
- if registry not in sm.__bases__:
- sm.__bases__ = (registry,) + sm.__bases__
-
- event.notify(interfaces.ProductInstalledEvent(self.__product_name__, self))
-
- self.update()
-
- def update(self):
- if not self.__installed__:
- raise interfaces.ProductNotInstalledError(
- _('Product not installed.'))
-
- configure(self, {})
-
- sm = getSiteManager()
- registry = getattr(z3ext.product, self.__product_name__)
- if registry not in sm.__bases__:
- sm.__bases__ = (registry,) + sm.__bases__
-
- event.notify(
- interfaces.ProductUpdatedEvent(self.__product_name__, self))
-
- def uninstall(self):
- for name, ext in self.items():
- if IProductExtension.providedBy(ext) and ext.__installed__:
- ext.uninstall()
-
- if not self.__installed__:
- raise interfaces.ProductNotInstalledError(
- _('Product not installed.'))
-
- self.__installed__ = False
-
- sm = getSiteManager()
- registry = getattr(z3ext.product, self.__product_name__)
-
- if registry in sm.__bases__:
- bases = list(sm.__bases__)
- bases.remove(registry)
- sm.__bases__ = tuple(bases)
-
- event.notify(
- interfaces.ProductUninstalledEvent(self.__product_name__, self))
-
- def _checkInstalled(self, sm, registry, seen):
- if sm in seen:
- return False
- seen.insert(sm)
-
- if registry in sm.__bases__:
- return True
-
- for reg in sm.__bases__:
- if self._checkInstalled(reg, registry, seen):
- return True
-
- return False
-
- def isInstalled(self):
- sm = getSiteManager()
- registry = getattr(z3ext.product, self.__product_name__)
- seen = set()
- return self._checkInstalled(sm, registry, seen)
-
- def listExtensions(self):
- exts = []
- for name, ext in self.items():
- if IProductExtension.providedBy(ext):
- exts.append(name)
-
- return exts
-
- def isUninstallable(self):
- sm = getSiteManager()
- registry = getattr(z3ext.product, self.__product_name__)
- return registry in sm.__bases__
-
-
-class ProductExtension(Product):
- interface.implements(IProductExtension)
-
- def install(self):
- if not self.__parent__.__installed__:
- raise interfaces.ProductNotInstalledError(
- self.__parent__.__product_name__)
- super(ProductExtension, self).install()
-
- def update(self):
- if not self.__parent__.__installed__:
- raise interfaces.ProductNotInstalledError(
- self.__parent__.__product_name__)
- super(ProductExtension, self).update()
-
- def isInstalled(self):
- if self.__parent__.__installed__:
- return self.__installed__
- else:
- return False
Copied: z3ext.product/tags/1.1.0/src/z3ext/product/product.py (from rev 89394, z3ext.product/trunk/src/z3ext/product/product.py)
===================================================================
--- z3ext.product/tags/1.1.0/src/z3ext/product/product.py (rev 0)
+++ z3ext.product/tags/1.1.0/src/z3ext/product/product.py 2008-08-05 14:39:14 UTC (rev 89395)
@@ -0,0 +1,147 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id: product.py 1843 2008-03-25 18:39:00Z fafhrd91 $
+"""
+from BTrees.OOBTree import OOBTree
+
+from zope import interface, event
+from zope.component import getSiteManager
+from zope.component import getUtility, queryUtility, getUtilitiesFor
+
+from z3c.configurator import configure
+
+import z3ext.product
+from z3ext.controlpanel.configlettype import ConfigletProperty
+
+from z3ext.product.i18n import _
+from z3ext.product import interfaces
+from z3ext.product.interfaces import IProduct, IProductExtension
+
+
+class Product(object):
+ """ base product class """
+ interface.implements(IProduct)
+
+ __installed__ = ConfigletProperty(IProduct['__installed__'])
+
+ def install(self):
+ if self.__installed__:
+ raise interfaces.ProductAlreadyInstalledError(
+ _('Product already installed.'))
+
+ self.__installed__ = True
+
+ sm = getSiteManager()
+
+ registry = getattr(z3ext.product, self.__product_name__)
+ if registry not in sm.__bases__:
+ sm.__bases__ = (registry,) + sm.__bases__
+
+ event.notify(interfaces.ProductInstalledEvent(self.__product_name__, self))
+
+ self.update()
+
+ def update(self):
+ if not self.__installed__:
+ raise interfaces.ProductNotInstalledError(
+ _('Product not installed.'))
+
+ configure(self, {})
+
+ sm = getSiteManager()
+ registry = getattr(z3ext.product, self.__product_name__)
+ if registry not in sm.__bases__:
+ sm.__bases__ = (registry,) + sm.__bases__
+
+ event.notify(
+ interfaces.ProductUpdatedEvent(self.__product_name__, self))
+
+ def uninstall(self):
+ for name, ext in self.items():
+ if IProductExtension.providedBy(ext) and ext.__installed__:
+ ext.uninstall()
+
+ if not self.__installed__:
+ raise interfaces.ProductNotInstalledError(
+ _('Product not installed.'))
+
+ self.__installed__ = False
+
+ sm = getSiteManager()
+ registry = getattr(z3ext.product, self.__product_name__)
+
+ if registry in sm.__bases__:
+ bases = list(sm.__bases__)
+ bases.remove(registry)
+ sm.__bases__ = tuple(bases)
+
+ event.notify(
+ interfaces.ProductUninstalledEvent(self.__product_name__, self))
+
+ def _checkInstalled(self, sm, registry, seen):
+ if sm in seen:
+ return False
+ seen.add(sm)
+
+ if registry in sm.__bases__:
+ return True
+
+ for reg in sm.__bases__:
+ if self._checkInstalled(reg, registry, seen):
+ return True
+
+ return False
+
+ def isInstalled(self):
+ sm = getSiteManager()
+ registry = getattr(z3ext.product, self.__product_name__)
+ seen = set()
+ return self._checkInstalled(sm, registry, seen)
+
+ def listExtensions(self):
+ exts = []
+ for name, ext in self.items():
+ if IProductExtension.providedBy(ext):
+ exts.append(name)
+
+ return exts
+
+ def isUninstallable(self):
+ sm = getSiteManager()
+ registry = getattr(z3ext.product, self.__product_name__)
+ return registry in sm.__bases__
+
+
+class ProductExtension(Product):
+ interface.implements(IProductExtension)
+
+ def install(self):
+ if not self.__parent__.__installed__:
+ raise interfaces.ProductNotInstalledError(
+ self.__parent__.__product_name__)
+ super(ProductExtension, self).install()
+
+ def update(self):
+ if not self.__parent__.__installed__:
+ raise interfaces.ProductNotInstalledError(
+ self.__parent__.__product_name__)
+ super(ProductExtension, self).update()
+
+ def isInstalled(self):
+ if self.__parent__.__installed__:
+ return self.__installed__
+ else:
+ return False
Deleted: z3ext.product/tags/1.1.0/src/z3ext/product/view.pt
===================================================================
--- z3ext.product/trunk/src/z3ext/product/view.pt 2008-08-05 14:02:55 UTC (rev 89391)
+++ z3ext.product/tags/1.1.0/src/z3ext/product/view.pt 2008-08-05 14:39:14 UTC (rev 89395)
@@ -1,86 +0,0 @@
-<div i18n:domain="z3ext.product" tal:define="data view/getProducts">
- <div class="topframe" tal:condition="data/installed">
- <h1>Installed Products</h1>
-
- <form tal:attributes="action request/URL" method="post">
- <ul class="listing">
- <li tal:repeat="product data/installed">
- <div class="icon">
- <input class="noborder" type="checkbox"
- name="products:list" tal:attributes="value product/name" />
- <img tal:replace="structure product/product/@@zmi_icon" />
- </div>
- <div class="details">
- <a tal:omit-tag="not:product/configlet"
- tal:attributes="href string:${product/name}/">
- <span tal:content="product/title"></span>
- </a>
- <div tal:content="product/description"></div>
- </div>
- <div class="small"
- tal:define="name product/name;
- extensions python:view.getExtensions(product['product'])"
- tal:condition="extensions">
- <ul class="listing">
- <li tal:repeat="product extensions">
- <div class="icon">
- <img tal:replace="structure product/@@zmi_icon" />
- </div>
- <div class="details">
- <span>
- <a tal:omit-tag="not:product/isAvailable"
- tal:attributes="href string:${product/__parent__/__name__}/${product/__name__}/">
- <span tal:content="product/__title__"></span>
- </a>
- <a tal:attributes="href
- string:${context/@@absolute_url}/?extension=${product/__id__}"
- tal:condition="product/__installed__">
- (Installed)
- </a>
- <a tal:attributes="href
- string:${context/@@absolute_url}/?extension=${product/__id__}"
- tal:condition="not:product/__installed__">
- (Not installed)
- </a>
- </span>
- <div tal:content="product/__description__"></div>
- </div>
- </li>
- </ul>
- </div>
- </li>
- </ul>
-
- <div class="formControls">
- <input type="submit" class="z-form-button" name="update" value="Update" />
- <input type="submit" class="z-form-removebutton" name="uninstall" value="Uninstall" />
- </div>
- </form>
- </div>
-
- <div class="frame" tal:condition="data/notinstalled"
- tal:attributes="class python:not data['installed'] and 'topframe' or 'frame'">
- <h1>Products available for install</h1>
- <p>This is the Add-on Products install section, you can add products in the lists below.</p>
-
- <form tal:attributes="action request/URL" method="post">
- <ul class="listing">
- <li tal:repeat="product data/notinstalled">
- <div class="icon">
- <input class="noborder" type="checkbox"
- name="products:list" tal:attributes="value product/name" />
- <img tal:replace="structure product/product/@@zmi_icon" />
- </div>
- <div class="details">
- <span tal:content="product/title"></span>
- <div tal:content="product/description"></div>
- </div>
- </li>
- </ul>
-
- <div class="formControls">
- <input type="submit" class="context" name="install" value="Install" />
- </div>
- </form>
- </div>
-</div>
Copied: z3ext.product/tags/1.1.0/src/z3ext/product/view.pt (from rev 89394, z3ext.product/trunk/src/z3ext/product/view.pt)
===================================================================
--- z3ext.product/tags/1.1.0/src/z3ext/product/view.pt (rev 0)
+++ z3ext.product/tags/1.1.0/src/z3ext/product/view.pt 2008-08-05 14:39:14 UTC (rev 89395)
@@ -0,0 +1,89 @@
+<div i18n:domain="z3ext.product" tal:define="data view/getProducts">
+ <div class="topframe" tal:condition="data/installed">
+ <h1>Installed Products</h1>
+
+ <form tal:attributes="action request/URL" method="post">
+ <ul class="listing">
+ <li tal:repeat="product data/installed">
+ <div class="icon">
+ <input class="noborder" type="checkbox" name="products:list"
+ tal:attributes="value product/name"
+ tal:condition="product/uninstallable" />
+ <tal:block tal:condition="not:product/uninstallable">
+ </tal:block>
+ <img tal:replace="structure product/product/@@zmi_icon" />
+ </div>
+ <div class="details">
+ <a tal:omit-tag="not:product/configlet"
+ tal:attributes="href string:${product/name}/">
+ <span tal:content="product/title"></span>
+ </a>
+ <div tal:content="product/description"></div>
+ </div>
+ <div class="small"
+ tal:define="name product/name;
+ extensions python:view.getExtensions(product['product'])"
+ tal:condition="extensions">
+ <ul class="listing">
+ <li tal:repeat="product extensions">
+ <div class="icon">
+ <img tal:replace="structure product/@@zmi_icon" />
+ </div>
+ <div class="details">
+ <span>
+ <a tal:omit-tag="not:product/isAvailable"
+ tal:attributes="href string:${product/__parent__/__name__}/${product/__name__}/">
+ <span tal:content="product/__title__"></span>
+ </a>
+ <a tal:attributes="href
+ string:${context/@@absolute_url}/?extension=${product/__id__}"
+ tal:condition="product/__installed__">
+ (Installed)
+ </a>
+ <a tal:attributes="href
+ string:${context/@@absolute_url}/?extension=${product/__id__}"
+ tal:condition="not:product/__installed__">
+ (Not installed)
+ </a>
+ </span>
+ <div tal:content="product/__description__"></div>
+ </div>
+ </li>
+ </ul>
+ </div>
+ </li>
+ </ul>
+
+ <div class="formControls" tal:condition="data/hasUninstallable">
+ <input type="submit" class="z-form-button" name="update" value="Update" />
+ <input type="submit" class="z-form-removebutton" name="uninstall" value="Uninstall" />
+ </div>
+ </form>
+ </div>
+
+ <div class="frame" tal:condition="data/notinstalled"
+ tal:attributes="class python:not data['installed'] and 'topframe' or 'frame'">
+ <h1>Products available for install</h1>
+ <p>This is the Add-on Products install section, you can add products in the lists below.</p>
+
+ <form tal:attributes="action request/URL" method="post">
+ <ul class="listing">
+ <li tal:repeat="product data/notinstalled">
+ <div class="icon">
+ <input class="noborder" type="checkbox"
+ name="products:list" tal:attributes="value product/name" />
+ <img tal:replace="structure product/product/@@zmi_icon" />
+ </div>
+ <div class="details">
+ <span tal:content="product/title"></span>
+ <div tal:content="product/description"></div>
+ </div>
+ </li>
+ </ul>
+
+ <div class="formControls">
+ <input type="submit" class="context" name="install" value="Install" />
+ </div>
+ </form>
+ </div>
+</div>
Deleted: z3ext.product/tags/1.1.0/src/z3ext/product/view.py
===================================================================
--- z3ext.product/trunk/src/z3ext/product/view.py 2008-08-05 14:02:55 UTC (rev 89391)
+++ z3ext.product/tags/1.1.0/src/z3ext/product/view.py 2008-08-05 14:39:14 UTC (rev 89395)
@@ -1,150 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" z3ext.product interfaces
-
-$Id: view.py 1839 2008-03-25 13:28:26Z fafhrd91 $
-"""
-import logging, sys
-from transaction import abort
-from zope.component import getUtility, queryUtility, getUtilitiesFor
-
-from z3ext.layout.pagelet import BrowserPagelet
-from z3ext.statusmessage.interfaces import IStatusMessage
-
-from z3ext.product.i18n import _
-from z3ext.product.interfaces import IProductExtension
-from z3ext.product.interfaces import ProductWarningError
-
-def log_exc(msg=''):
- log = logging.getLogger(u'z3ext.product')
- log.log(logging.ERROR, msg, exc_info=sys.exc_info())
-
-
-class InstallerView(BrowserPagelet):
-
- def getProducts(self):
- context = self.context
-
- installed = []
- notinstalled = []
-
- for name, product in context.items():
- info = {'name': name,
- 'product': product,
- 'title': product.__title__,
- 'description': product.__description__}
-
- if product.isInstalled():
- info['configlet'] = product.isAvailable()
- installed.append((product.__title__, info))
- else:
- notinstalled.append((product.__title__, info))
-
- installed.sort()
- installed = [info for t, info in installed]
-
- notinstalled.sort()
- notinstalled = [info for t, info in notinstalled]
-
- return {'installed': installed, 'notinstalled': notinstalled}
-
- def getExtensions(self, product):
- extensions = []
-
- for name in product.listExtensions():
- ext = product.get(name)
- extensions.append((ext.__title__, ext))
- extensions.sort()
- return [ext for t, ext in extensions]
-
- def update(self, *args, **kw):
- request = self.request
- context = self.context
-
- service = IStatusMessage(request)
- products = request.get('products', ())
-
- if request.has_key('install'):
- if not products:
- service.add(_('Select one or more products to install.'), 'warning')
- else:
- try:
- for product_id in products:
- product = context.get(product_id)
- product.install()
-
- service.add(_('Selected products has been installed.'))
- except ProductWarningError, e:
- abort()
- service.add(unicode(e), 'warning')
- except Exception, e:
- abort()
- log_exc(str(e))
- service.add(e, 'error')
-
- elif request.has_key('update'):
- if not products:
- service.add(_('Select one or more products to update.'), 'warning')
- else:
- try:
- for product_id in products:
- product = context.get(product_id)
- product.update()
-
- service.add('Selected products has been updated.')
- except Exception, e:
- abort()
- log_exc(str(e))
- service.add(e, 'error')
-
- elif request.has_key('uninstall'):
- if not products:
- service.add(_('Select one or more products to uninstall.'), 'warning')
- else:
- try:
- for product_id in products:
- product = context.get(product_id)
- product.uninstall()
-
- service.add(_('Selected products has been uninstalled.'))
- except Exception, e:
- abort()
- log_exc(str(e))
- service.add(e, 'error')
-
- elif request.has_key('extension'):
- try:
- product = ''
- extension = request.get('extension', '')
- if '.' in extension:
- c, product, extension = extension.split('.', 2)
-
- product = context.get(product)
- if product is not None:
- extension = product.get(extension)
-
- if not IProductExtension.providedBy(extension):
- extension = None
-
- if extension is None:
- service.add("Can't fine extension.", 'error')
- else:
- if extension.__installed__:
- extension.uninstall()
- else:
- extension.install()
- except Exception, e:
- abort()
- log_exc(str(e))
- service.add(e, 'error')
Copied: z3ext.product/tags/1.1.0/src/z3ext/product/view.py (from rev 89394, z3ext.product/trunk/src/z3ext/product/view.py)
===================================================================
--- z3ext.product/tags/1.1.0/src/z3ext/product/view.py (rev 0)
+++ z3ext.product/tags/1.1.0/src/z3ext/product/view.py 2008-08-05 14:39:14 UTC (rev 89395)
@@ -0,0 +1,155 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+""" z3ext.product interfaces
+
+$Id: view.py 1839 2008-03-25 13:28:26Z fafhrd91 $
+"""
+import logging, sys
+from transaction import abort
+from zope.component import getUtility, queryUtility, getUtilitiesFor
+
+from z3ext.layout.pagelet import BrowserPagelet
+from z3ext.statusmessage.interfaces import IStatusMessage
+
+from z3ext.product.i18n import _
+from z3ext.product.interfaces import IProductExtension
+from z3ext.product.interfaces import ProductWarningError
+
+def log_exc(msg=''):
+ log = logging.getLogger(u'z3ext.product')
+ log.log(logging.ERROR, msg, exc_info=sys.exc_info())
+
+
+class InstallerView(BrowserPagelet):
+
+ def getProducts(self):
+ context = self.context
+
+ installed = []
+ notinstalled = []
+ hasUninstallable = False
+
+ for name, product in context.items():
+ info = {'name': name,
+ 'product': product,
+ 'title': product.__title__,
+ 'description': product.__description__,
+ 'uninstallable': product.isUninstallable()}
+
+ if product.isInstalled():
+ info['configlet'] = product.isAvailable()
+ installed.append((product.__title__, info))
+ if info['uninstallable']:
+ hasUninstallable = True
+ else:
+ notinstalled.append((product.__title__, info))
+
+ installed.sort()
+ installed = [info for t, info in installed]
+
+ notinstalled.sort()
+ notinstalled = [info for t, info in notinstalled]
+
+ return {'installed': installed, 'notinstalled': notinstalled,
+ 'hasUninstallable': hasUninstallable}
+
+ def getExtensions(self, product):
+ extensions = []
+
+ for name in product.listExtensions():
+ ext = product.get(name)
+ extensions.append((ext.__title__, ext))
+ extensions.sort()
+ return [ext for t, ext in extensions]
+
+ def update(self, *args, **kw):
+ request = self.request
+ context = self.context
+
+ service = IStatusMessage(request)
+ products = request.get('products', ())
+
+ if request.has_key('install'):
+ if not products:
+ service.add(_('Select one or more products to install.'), 'warning')
+ else:
+ try:
+ for product_id in products:
+ product = context.get(product_id)
+ product.install()
+
+ service.add(_('Selected products has been installed.'))
+ except ProductWarningError, e:
+ abort()
+ service.add(unicode(e), 'warning')
+ except Exception, e:
+ abort()
+ log_exc(str(e))
+ service.add(e, 'error')
+
+ elif request.has_key('update'):
+ if not products:
+ service.add(_('Select one or more products to update.'), 'warning')
+ else:
+ try:
+ for product_id in products:
+ product = context.get(product_id)
+ product.update()
+
+ service.add('Selected products has been updated.')
+ except Exception, e:
+ abort()
+ log_exc(str(e))
+ service.add(e, 'error')
+
+ elif request.has_key('uninstall'):
+ if not products:
+ service.add(_('Select one or more products to uninstall.'), 'warning')
+ else:
+ try:
+ for product_id in products:
+ product = context.get(product_id)
+ product.uninstall()
+
+ service.add(_('Selected products has been uninstalled.'))
+ except Exception, e:
+ abort()
+ log_exc(str(e))
+ service.add(e, 'error')
+
+ elif request.has_key('extension'):
+ try:
+ product = ''
+ extension = request.get('extension', '')
+ if '.' in extension:
+ c, product, extension = extension.split('.', 2)
+
+ product = context.get(product)
+ if product is not None:
+ extension = product.get(extension)
+
+ if not IProductExtension.providedBy(extension):
+ extension = None
+
+ if extension is None:
+ service.add("Can't fine extension.", 'error')
+ else:
+ if extension.__installed__:
+ extension.uninstall()
+ else:
+ extension.install()
+ except Exception, e:
+ abort()
+ log_exc(str(e))
+ service.add(e, 'error')
More information about the Checkins
mailing list