[Checkins] SVN: z3c.configurator/tags/1.2.0/ release 1.2.0
Nikolay Kim
fafhrd91 at gmail.com
Sat Dec 19 22:54:58 EST 2009
Log message for revision 106794:
release 1.2.0
Changed:
A z3c.configurator/tags/1.2.0/
D z3c.configurator/tags/1.2.0/CHANGES.txt
A z3c.configurator/tags/1.2.0/CHANGES.txt
D z3c.configurator/tags/1.2.0/bootstrap.py
A z3c.configurator/tags/1.2.0/bootstrap.py
D z3c.configurator/tags/1.2.0/importchecker.py
A z3c.configurator/tags/1.2.0/importchecker.py
D z3c.configurator/tags/1.2.0/setup.py
A z3c.configurator/tags/1.2.0/setup.py
D z3c.configurator/tags/1.2.0/src/z3c/configurator/SETUP.cfg
D z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/configure.zcml
A z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/configure.zcml
D z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/ftesting.zcml
A z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/ftesting.zcml
D z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/testing.py
A z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/testing.py
D z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/views.py
A z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/views.py
D z3c.configurator/tags/1.2.0/src/z3c/configurator/configurator.py
A z3c.configurator/tags/1.2.0/src/z3c/configurator/configurator.py
D z3c.configurator/tags/1.2.0/src/z3c/configurator/configure.zcml
A z3c.configurator/tags/1.2.0/src/z3c/configurator/configure.zcml
D z3c.configurator/tags/1.2.0/src/z3c/configurator/i18n.py
A z3c.configurator/tags/1.2.0/src/z3c/configurator/i18n.py
D z3c.configurator/tags/1.2.0/src/z3c/configurator/interfaces.py
A z3c.configurator/tags/1.2.0/src/z3c/configurator/interfaces.py
D z3c.configurator/tags/1.2.0/src/z3c/configurator/tests.py
A z3c.configurator/tags/1.2.0/src/z3c/configurator/tests.py
D z3c.configurator/tags/1.2.0/src/z3c/configurator/vocabulary.py
A z3c.configurator/tags/1.2.0/src/z3c/configurator/vocabulary.py
-=-
Deleted: z3c.configurator/tags/1.2.0/CHANGES.txt
===================================================================
--- z3c.configurator/trunk/CHANGES.txt 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/CHANGES.txt 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,34 +0,0 @@
-=======
-CHANGES
-=======
-
-Version 1.1.3 (unreleased)
---------------------------
-
--
-
-
-Version 1.1.2 (2009-01-04)
---------------------------
-
-- Added possibility to apply only specific named plugins in configure.
-
-- New option to configure allows to have namespaced data to resolve
- naming conflicts.
-
-- Added a page to call configurators TTW. This is the first step
- towards mergin z3c.configurator and z3c.sampledata into one package.
-
-- Added documentation to Pypi home page.
-
-- bugfix: Defining recursive dependent names in IConfigurationPlugin
- dependencies, ends in recursive plugin lookup.
-
-- bugfix: SchemaConfigurationPluginBase now implements
- ISchemaConfigurationPluginBase.
-
-
-Version 1.1.1 (unknown)
------------------------
-
-- Initial Release
Copied: z3c.configurator/tags/1.2.0/CHANGES.txt (from rev 106793, z3c.configurator/trunk/CHANGES.txt)
===================================================================
--- z3c.configurator/tags/1.2.0/CHANGES.txt (rev 0)
+++ z3c.configurator/tags/1.2.0/CHANGES.txt 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,40 @@
+=======
+CHANGES
+=======
+
+Version 1.2.0 (2009-12-19)
+--------------------------
+
+- Made registration of browser views conditional
+
+- Move packages required for testing to 'test' extras
+
+- Remove old zpkg-related SETUP.cfg file.
+
+- Copyright "Zope Foundation and Contributors"
+
+
+Version 1.1.2 (2009-01-04)
+--------------------------
+
+- Added possibility to apply only specific named plugins in configure.
+
+- New option to configure allows to have namespaced data to resolve
+ naming conflicts.
+
+- Added a page to call configurators TTW. This is the first step
+ towards mergin z3c.configurator and z3c.sampledata into one package.
+
+- Added documentation to Pypi home page.
+
+- bugfix: Defining recursive dependent names in IConfigurationPlugin
+ dependencies, ends in recursive plugin lookup.
+
+- bugfix: SchemaConfigurationPluginBase now implements
+ ISchemaConfigurationPluginBase.
+
+
+Version 1.1.1 (unknown)
+-----------------------
+
+- Initial Release
Deleted: z3c.configurator/tags/1.2.0/bootstrap.py
===================================================================
--- z3c.configurator/trunk/bootstrap.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/bootstrap.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,52 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 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.
-#
-##############################################################################
-"""Bootstrap a buildout-based project
-
-Simply run this script in a directory containing a buildout.cfg.
-The script accepts buildout command-line options, so you can
-use the -c option to specify an alternate configuration file.
-
-$Id$
-"""
-
-import os, shutil, sys, tempfile, urllib2
-
-tmpeggs = tempfile.mkdtemp()
-
-ez = {}
-exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
- ).read() in ez
-ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
-
-import pkg_resources
-
-cmd = 'from setuptools.command.easy_install import main; main()'
-if sys.platform == 'win32':
- cmd = '"%s"' % cmd # work around spawn lamosity on windows
-
-ws = pkg_resources.working_set
-assert os.spawnle(
- os.P_WAIT, sys.executable, sys.executable,
- '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
- dict(os.environ,
- PYTHONPATH=
- ws.find(pkg_resources.Requirement.parse('setuptools')).location
- ),
- ) == 0
-
-ws.add_entry(tmpeggs)
-ws.require('zc.buildout')
-import zc.buildout.buildout
-zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
-shutil.rmtree(tmpeggs)
Copied: z3c.configurator/tags/1.2.0/bootstrap.py (from rev 106790, z3c.configurator/trunk/bootstrap.py)
===================================================================
--- z3c.configurator/tags/1.2.0/bootstrap.py (rev 0)
+++ z3c.configurator/tags/1.2.0/bootstrap.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Foundation 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Deleted: z3c.configurator/tags/1.2.0/importchecker.py
===================================================================
--- z3c.configurator/trunk/importchecker.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/importchecker.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,354 +0,0 @@
-#!/usr/bin/env python2.4
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Import checker
-
-This utility finds is based on the zope importchecker script, prints
-out unused imports, imports that are only for tests packages and
-runtime imports.
-
-$Id$
-"""
-import compiler
-import os, os.path
-import sys
-
-def _findDottedNamesHelper(node, result):
- more_node = node
- name = node.__class__.__name__
- if name == 'Getattr':
- dotted = []
- while name == 'Getattr':
- dotted.append(node.attrname)
- node = node.expr
- name = node.__class__.__name__
- if name == 'Name':
- dotted.append(node.name)
- dotted.reverse()
- for i in range(1, len(dotted)):
- result.append('.'.join(dotted[:i]))
- result.append('.'.join(dotted))
- return
- elif name == 'Name':
- result.append(node.name)
- return
- elif name == 'AssAttr':
- return
- for child in more_node.getChildNodes():
- _findDottedNamesHelper(child, result)
-
-def findDottedNames(node):
- """Find dotted names in an AST tree node
- """
- result = []
- _findDottedNamesHelper(node, result)
- return result
-
-class ImportFinder:
- """An instance of this class will be used to walk over a compiler AST
- tree (a module). During that operation, the appropriate methods of
- this visitor will be called
- """
-
- def __init__(self):
- self._map = {}
-
- def visitFrom(self, stmt):
- """Will be called for 'from foo import bar' statements
- """
- module_name, names = stmt.asList()
- if module_name == '__future__':
- # we don't care what's imported from the future
- return
- names_dict = {}
- for orig_name, as_name in names:
- # we don't care about from import *
- if orig_name == '*':
- continue
- if as_name is None:
- name = orig_name
- else:
- name = as_name
- names_dict[name] = orig_name
- self._map.setdefault(module_name, {'names': names_dict,
- 'lineno': stmt.lineno})
-
- def visitImport(self, stmt):
- """Will be called for 'import foo.bar' statements
- """
- for orig_name, as_name in stmt.names:
- if as_name is None:
- name = orig_name
- else:
- name = as_name
- self._map.setdefault(orig_name, {'names': {name: orig_name},
- 'lineno': stmt.lineno})
-
- def getMap(self):
- return self._map
-
-def findImports(mod):
- """Find import statements in module and put the result in a mapping.
- """
- visitor = ImportFinder()
- compiler.walk(mod, visitor)
- return visitor.getMap()
-
-class Module:
- """This represents a python module.
- """
-
- def __init__(self, path):
- mod = compiler.parseFile(path)
- self._path = path
- self._map = findImports(mod)
- dottednames = {}
- self._dottednames = findDottedNames(mod)
-
- def getPath(self):
- """Return the path to this module's file.
- """
- return self._path
-
- def getImportedModuleNames(self):
- """Return the names of imported modules.
- """
- return self._map.keys()
-
- def getImportNames(self):
- """Return the names of imports; add dottednames as well.
- """
- result = []
- map = self._map
- for module_name in map.keys():
- for usedname, originalname in map[module_name]['names'].items():
- result.append((originalname, module_name))
- # add any other name that we could be using
- for dottedname in self._dottednames:
- usednamedot = usedname + '.'
- if dottedname.startswith(usednamedot):
- attrname = dottedname[len(usednamedot):].split('.')[0]
- result.append((attrname, module_name))
-
- return result
-
- def getUnusedImports(self):
- """Get unused imports of this module (the whole import info).
- """
- result = []
- for value in self._map.values():
- for usedname, originalname in value['names'].items():
- if usedname not in self._dottednames:
- result.append((originalname, value['lineno']))
- return result
-
-class ModuleFinder:
-
- def __init__(self):
- self._files = []
-
- def visit(self, arg, dirname, names):
- """This method will be called when we walk the filesystem
- tree. It looks for python modules and stored their filenames.
- """
- for name in names:
- # get all .py files that aren't weirdo emacs droppings
- if name.endswith('.py') and not name.startswith('.#'):
- self._files.append(os.path.join(dirname, name))
-
- def getModuleFilenames(self):
- return self._files
-
-def findModules(path):
- """Find python modules in the given path and return their absolute
- filenames in a sequence.
- """
- finder = ModuleFinder()
- os.path.walk(path, finder.visit, ())
- return finder.getModuleFilenames()
-
-class ImportDatabase:
- """This database keeps tracks of imports.
-
- It allows to NOT report cases where a module imports something
- just so that another module can import it (import dependencies).
- """
-
- def __init__(self, root_path):
- self._root_path = root_path
- self._modules = {}
- self._names = {}
-
- def resolveDottedModuleName(self, dotted_name, module):
- """Return path to file representing module, or None if no such
- thing. Can do this relative from module.
- """
- dotted_path = dotted_name.replace('.', '/')
- # try relative import first
- path = os.path.join(os.path.dirname(module.getPath()), dotted_path)
- path = self._resolveHelper(path)
- if path is not None:
- return path
- # absolute import (assumed to be from this tree)
- if os.path.isfile(os.path.join(self._root_path, '__init__.py')):
- startpath, dummy = os.path.split(self._root_path)
- else:
- startpath = self._root_path
- return self._resolveHelper(os.path.join(startpath, dotted_path))
-
- def _resolveHelper(self, path):
- if os.path.isfile(path + '.py'):
- return path + '.py'
- if os.path.isdir(path):
- path = os.path.join(path, '__init__.py')
- if os.path.isfile(path):
- return path
- return None
-
- def findModules(self):
- """Find modules in the given path.
- """
- for modulepath in findModules(self._root_path):
- module = Module(modulepath)
- self.addModule(module)
-
- def addModule(self, module):
- """Add information about a module to the database. A module in
- this case is not a python module object, but an instance of
- the above defined Module class.w
- """
- self_path = module.getPath()
- # do nothing if we already know about it
- if self._modules.has_key(self_path):
- return
-
- self._modules[self_path] = module
-
- # add imported names to internal names mapping; this will
- # allow us identify dependent imports later
- names = self._names
- for name, from_module_name in module.getImportNames():
- path = self.resolveDottedModuleName(from_module_name, module)
- t = (path, name)
- modulepaths = names.get(t, {})
- if not modulepaths.has_key(self_path):
- modulepaths[self_path] = 1
- names[t] = modulepaths
-
- def getUnusedImports(self):
- """Get unused imports of all known modules.
- """
- result = {}
- for path, module in self._modules.items():
- result[path] = self.getUnusedImportsInModule(module)
- return result
-
- def getImportedModuleNames(self, tests=False):
- """returns all names imported by modules"""
- result = set()
- import os
- for path, module in self._modules.items():
- # remove .py
- parts = path[:-3].split(os.path.sep)
- isTest = 'tests' in parts or 'testing' in parts \
- or 'ftests' in parts
- if (tests and isTest) or (not tests and not isTest):
- result.update(module.getImportedModuleNames())
- return sorted(result)
-
- def getUnusedImportsInModule(self, module):
- """Get all unused imports in a module.
- """
- result = []
- for name, lineno in module.getUnusedImports():
- if not self.isNameImportedFrom(name, module):
- result.append((name, lineno))
- return result
-
- def isNameImportedFrom(self, name, module):
- """Return true if name is imported from module by another module.
- """
- return self._names.has_key((module.getPath(), name))
-
- def getModulesImportingNameFrom(self, name, module):
- """Return list of known modules that import name from module.
- """
- result = []
- for path in self._names.get((module.getPath(), name), {}).keys():
- result.append(self._modules[path])
- return result
-
-def main():
- try:
- path = os.path.abspath(sys.argv[1])
- except IndexError:
- path = os.path.abspath(os.getcwd())
- path = os.path.join(path, 'src')
-
- if not os.path.exists(path):
- print "Please provide a valid path %r" % path
- sys.exit(1)
- print "-"*79
- print "Path: %r" % path
- print "-"*79
- print
-
- path = os.path.abspath(path)
- if not os.path.isdir(path):
- print "Unknown path:", path
- sys.exit(1)
-
- db = ImportDatabase(path)
- db.findModules()
- unused_imports = db.getUnusedImports()
- module_paths = unused_imports.keys()
- module_paths.sort()
- print "-"*79
- print "Unused Imports:"
- print "-"*79
- for path in module_paths:
- info = unused_imports[path]
- if not info:
- continue
- line2names = {}
- for name, line in info:
- names = line2names.get(line, [])
- names.append(name)
- line2names[line] = names
- lines = line2names.keys()
- lines.sort()
- for line in lines:
- names = ', '.join(line2names[line])
- print "%s:%s: %s" % (path, line, names)
- testImports = db.getImportedModuleNames(tests=True)
- installImports = db.getImportedModuleNames(tests=False)
- print "-"*79
- print
- print "-"*79
- print "Imports for 'tests' and 'testing' packages"
- print "-"*79
- for name in [name for name in testImports if name not in installImports]:
- print name
- print "-"*79
- print
- print "-"*79
- print "Install imports"
- print "-"*79
- for name in installImports:
- print name
- print "-"*79
-
-if __name__ == '__main__':
- main()
-
Copied: z3c.configurator/tags/1.2.0/importchecker.py (from rev 106790, z3c.configurator/trunk/importchecker.py)
===================================================================
--- z3c.configurator/tags/1.2.0/importchecker.py (rev 0)
+++ z3c.configurator/tags/1.2.0/importchecker.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,353 @@
+#!/usr/bin/env python2.4
+##############################################################################
+#
+# Copyright (c) 2003 Zope Foundation 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.
+#
+##############################################################################
+"""Import checker
+
+This utility finds is based on the zope importchecker script, prints
+out unused imports, imports that are only for tests packages and
+runtime imports.
+
+$Id$
+"""
+import compiler
+import os, os.path
+import sys
+
+def _findDottedNamesHelper(node, result):
+ more_node = node
+ name = node.__class__.__name__
+ if name == 'Getattr':
+ dotted = []
+ while name == 'Getattr':
+ dotted.append(node.attrname)
+ node = node.expr
+ name = node.__class__.__name__
+ if name == 'Name':
+ dotted.append(node.name)
+ dotted.reverse()
+ for i in range(1, len(dotted)):
+ result.append('.'.join(dotted[:i]))
+ result.append('.'.join(dotted))
+ return
+ elif name == 'Name':
+ result.append(node.name)
+ return
+ elif name == 'AssAttr':
+ return
+ for child in more_node.getChildNodes():
+ _findDottedNamesHelper(child, result)
+
+def findDottedNames(node):
+ """Find dotted names in an AST tree node
+ """
+ result = []
+ _findDottedNamesHelper(node, result)
+ return result
+
+class ImportFinder:
+ """An instance of this class will be used to walk over a compiler AST
+ tree (a module). During that operation, the appropriate methods of
+ this visitor will be called
+ """
+
+ def __init__(self):
+ self._map = {}
+
+ def visitFrom(self, stmt):
+ """Will be called for 'from foo import bar' statements
+ """
+ module_name, names = stmt.asList()
+ if module_name == '__future__':
+ # we don't care what's imported from the future
+ return
+ names_dict = {}
+ for orig_name, as_name in names:
+ # we don't care about from import *
+ if orig_name == '*':
+ continue
+ if as_name is None:
+ name = orig_name
+ else:
+ name = as_name
+ names_dict[name] = orig_name
+ self._map.setdefault(module_name, {'names': names_dict,
+ 'lineno': stmt.lineno})
+
+ def visitImport(self, stmt):
+ """Will be called for 'import foo.bar' statements
+ """
+ for orig_name, as_name in stmt.names:
+ if as_name is None:
+ name = orig_name
+ else:
+ name = as_name
+ self._map.setdefault(orig_name, {'names': {name: orig_name},
+ 'lineno': stmt.lineno})
+
+ def getMap(self):
+ return self._map
+
+def findImports(mod):
+ """Find import statements in module and put the result in a mapping.
+ """
+ visitor = ImportFinder()
+ compiler.walk(mod, visitor)
+ return visitor.getMap()
+
+class Module:
+ """This represents a python module.
+ """
+
+ def __init__(self, path):
+ mod = compiler.parseFile(path)
+ self._path = path
+ self._map = findImports(mod)
+ dottednames = {}
+ self._dottednames = findDottedNames(mod)
+
+ def getPath(self):
+ """Return the path to this module's file.
+ """
+ return self._path
+
+ def getImportedModuleNames(self):
+ """Return the names of imported modules.
+ """
+ return self._map.keys()
+
+ def getImportNames(self):
+ """Return the names of imports; add dottednames as well.
+ """
+ result = []
+ map = self._map
+ for module_name in map.keys():
+ for usedname, originalname in map[module_name]['names'].items():
+ result.append((originalname, module_name))
+ # add any other name that we could be using
+ for dottedname in self._dottednames:
+ usednamedot = usedname + '.'
+ if dottedname.startswith(usednamedot):
+ attrname = dottedname[len(usednamedot):].split('.')[0]
+ result.append((attrname, module_name))
+
+ return result
+
+ def getUnusedImports(self):
+ """Get unused imports of this module (the whole import info).
+ """
+ result = []
+ for value in self._map.values():
+ for usedname, originalname in value['names'].items():
+ if usedname not in self._dottednames:
+ result.append((originalname, value['lineno']))
+ return result
+
+class ModuleFinder:
+
+ def __init__(self):
+ self._files = []
+
+ def visit(self, arg, dirname, names):
+ """This method will be called when we walk the filesystem
+ tree. It looks for python modules and stored their filenames.
+ """
+ for name in names:
+ # get all .py files that aren't weirdo emacs droppings
+ if name.endswith('.py') and not name.startswith('.#'):
+ self._files.append(os.path.join(dirname, name))
+
+ def getModuleFilenames(self):
+ return self._files
+
+def findModules(path):
+ """Find python modules in the given path and return their absolute
+ filenames in a sequence.
+ """
+ finder = ModuleFinder()
+ os.path.walk(path, finder.visit, ())
+ return finder.getModuleFilenames()
+
+class ImportDatabase:
+ """This database keeps tracks of imports.
+
+ It allows to NOT report cases where a module imports something
+ just so that another module can import it (import dependencies).
+ """
+
+ def __init__(self, root_path):
+ self._root_path = root_path
+ self._modules = {}
+ self._names = {}
+
+ def resolveDottedModuleName(self, dotted_name, module):
+ """Return path to file representing module, or None if no such
+ thing. Can do this relative from module.
+ """
+ dotted_path = dotted_name.replace('.', '/')
+ # try relative import first
+ path = os.path.join(os.path.dirname(module.getPath()), dotted_path)
+ path = self._resolveHelper(path)
+ if path is not None:
+ return path
+ # absolute import (assumed to be from this tree)
+ if os.path.isfile(os.path.join(self._root_path, '__init__.py')):
+ startpath, dummy = os.path.split(self._root_path)
+ else:
+ startpath = self._root_path
+ return self._resolveHelper(os.path.join(startpath, dotted_path))
+
+ def _resolveHelper(self, path):
+ if os.path.isfile(path + '.py'):
+ return path + '.py'
+ if os.path.isdir(path):
+ path = os.path.join(path, '__init__.py')
+ if os.path.isfile(path):
+ return path
+ return None
+
+ def findModules(self):
+ """Find modules in the given path.
+ """
+ for modulepath in findModules(self._root_path):
+ module = Module(modulepath)
+ self.addModule(module)
+
+ def addModule(self, module):
+ """Add information about a module to the database. A module in
+ this case is not a python module object, but an instance of
+ the above defined Module class.w
+ """
+ self_path = module.getPath()
+ # do nothing if we already know about it
+ if self._modules.has_key(self_path):
+ return
+
+ self._modules[self_path] = module
+
+ # add imported names to internal names mapping; this will
+ # allow us identify dependent imports later
+ names = self._names
+ for name, from_module_name in module.getImportNames():
+ path = self.resolveDottedModuleName(from_module_name, module)
+ t = (path, name)
+ modulepaths = names.get(t, {})
+ if not modulepaths.has_key(self_path):
+ modulepaths[self_path] = 1
+ names[t] = modulepaths
+
+ def getUnusedImports(self):
+ """Get unused imports of all known modules.
+ """
+ result = {}
+ for path, module in self._modules.items():
+ result[path] = self.getUnusedImportsInModule(module)
+ return result
+
+ def getImportedModuleNames(self, tests=False):
+ """returns all names imported by modules"""
+ result = set()
+ import os
+ for path, module in self._modules.items():
+ # remove .py
+ parts = path[:-3].split(os.path.sep)
+ isTest = 'tests' in parts or 'testing' in parts \
+ or 'ftests' in parts
+ if (tests and isTest) or (not tests and not isTest):
+ result.update(module.getImportedModuleNames())
+ return sorted(result)
+
+ def getUnusedImportsInModule(self, module):
+ """Get all unused imports in a module.
+ """
+ result = []
+ for name, lineno in module.getUnusedImports():
+ if not self.isNameImportedFrom(name, module):
+ result.append((name, lineno))
+ return result
+
+ def isNameImportedFrom(self, name, module):
+ """Return true if name is imported from module by another module.
+ """
+ return self._names.has_key((module.getPath(), name))
+
+ def getModulesImportingNameFrom(self, name, module):
+ """Return list of known modules that import name from module.
+ """
+ result = []
+ for path in self._names.get((module.getPath(), name), {}).keys():
+ result.append(self._modules[path])
+ return result
+
+def main():
+ try:
+ path = os.path.abspath(sys.argv[1])
+ except IndexError:
+ path = os.path.abspath(os.getcwd())
+ path = os.path.join(path, 'src')
+
+ if not os.path.exists(path):
+ print "Please provide a valid path %r" % path
+ sys.exit(1)
+ print "-"*79
+ print "Path: %r" % path
+ print "-"*79
+ print
+
+ path = os.path.abspath(path)
+ if not os.path.isdir(path):
+ print "Unknown path:", path
+ sys.exit(1)
+
+ db = ImportDatabase(path)
+ db.findModules()
+ unused_imports = db.getUnusedImports()
+ module_paths = unused_imports.keys()
+ module_paths.sort()
+ print "-"*79
+ print "Unused Imports:"
+ print "-"*79
+ for path in module_paths:
+ info = unused_imports[path]
+ if not info:
+ continue
+ line2names = {}
+ for name, line in info:
+ names = line2names.get(line, [])
+ names.append(name)
+ line2names[line] = names
+ lines = line2names.keys()
+ lines.sort()
+ for line in lines:
+ names = ', '.join(line2names[line])
+ print "%s:%s: %s" % (path, line, names)
+ testImports = db.getImportedModuleNames(tests=True)
+ installImports = db.getImportedModuleNames(tests=False)
+ print "-"*79
+ print
+ print "-"*79
+ print "Imports for 'tests' and 'testing' packages"
+ print "-"*79
+ for name in [name for name in testImports if name not in installImports]:
+ print name
+ print "-"*79
+ print
+ print "-"*79
+ print "Install imports"
+ print "-"*79
+ for name in installImports:
+ print name
+ print "-"*79
+
+if __name__ == '__main__':
+ main()
Deleted: z3c.configurator/tags/1.2.0/setup.py
===================================================================
--- z3c.configurator/trunk/setup.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/setup.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,81 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Foundation 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$
-"""
-
-import os
-from setuptools import setup, find_packages
-
-def read(*rnames):
- return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
-
-setup(
- name = 'z3c.configurator',
- version='1.1.3dev',
- author = "Zope Community",
- author_email = "zope-dev at zope.org",
- description = "Dynamic configuration",
- long_description=(
- read('README.txt')
- + '\n\n.. contents::\n\n' +
- read('src', 'z3c', 'configurator', 'README.txt')
- + '\n\n' +
- read('src', 'z3c', 'configurator', 'browser', 'README.txt')
- + '\n\n' +
- read('CHANGES.txt')
- ),
- license = 'ZPL 2.1',
- keywords = 'zope3 z3c configurator configuration',
- classifiers = [
- 'Development Status :: 5 - Production/Stable',
- 'Environment :: Web Environment',
- 'Intended Audience :: Developers',
- 'License :: OSI Approved :: Zope Public License',
- 'Programming Language :: Python',
- 'Natural Language :: English',
- 'Operating System :: OS Independent',
- 'Topic :: Internet :: WWW/HTTP',
- 'Framework :: Zope3'],
- url = 'http://pypi.python.org/pypi/z3c.configurator',
- packages = find_packages('src'),
- include_package_data = True,
- package_dir = {'':'src'},
- namespace_packages = ['z3c'],
- extras_require = dict(
- test = [
- 'zope.app.testing',
- ],
- ),
- install_requires = [
- 'setuptools',
- 'zope.annotation',
- 'zope.app.pagetemplate',
- 'zope.app.securitypolicy',
- 'zope.app.testing',
- 'zope.app.zcmlfiles',
- 'zope.cachedescriptors',
- 'zope.component',
- 'zope.dublincore',
- 'zope.formlib',
- 'zope.i18nmessageid',
- 'zope.interface',
- 'zope.schema',
- 'zope.testbrowser',
- 'zope.testing',
- ],
- dependency_links = ['http://download.zope.org/distribution'],
- zip_safe=False,
- )
-
Copied: z3c.configurator/tags/1.2.0/setup.py (from rev 106790, z3c.configurator/trunk/setup.py)
===================================================================
--- z3c.configurator/tags/1.2.0/setup.py (rev 0)
+++ z3c.configurator/tags/1.2.0/setup.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,77 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Foundation 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$
+"""
+
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(
+ name = 'z3c.configurator',
+ version='1.2.0',
+ author = "Zope Community",
+ author_email = "zope-dev at zope.org",
+ description = "Dynamic configuration",
+ long_description=(
+ read('README.txt')
+ + '\n\n.. contents::\n\n' +
+ read('src', 'z3c', 'configurator', 'README.txt')
+ + '\n\n' +
+ read('src', 'z3c', 'configurator', 'browser', 'README.txt')
+ + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ license = 'ZPL 2.1',
+ keywords = 'zope3 z3c configurator configuration',
+ classifiers = [
+ 'Development Status :: 5 - Production/Stable',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Framework :: Zope3'],
+ url = 'http://pypi.python.org/pypi/z3c.configurator',
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['z3c'],
+ extras_require = dict(
+ test = [
+ 'zope.annotation',
+ 'zope.dublincore',
+ 'zope.formlib',
+ 'zope.securitypolicy',
+ 'zope.testbrowser',
+ 'zope.testing',
+ 'zope.app.pagetemplate',
+ 'zope.app.testing',
+ 'zope.app.zcmlfiles',
+ ],
+ ),
+ install_requires = [
+ 'setuptools',
+ 'zope.component',
+ 'zope.i18nmessageid',
+ 'zope.interface',
+ 'zope.schema',
+ ],
+ zip_safe=False,
+ )
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/SETUP.cfg
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/SETUP.cfg 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/SETUP.cfg 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,3 +0,0 @@
-<data-files zopeskel/etc/package-includes>
- z3c.configurator-*.zcml
-</data-files>
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/configure.zcml
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/browser/configure.zcml 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/configure.zcml 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,14 +0,0 @@
-<configure
- xmlns:zope="http://namespaces.zope.org/zope"
- xmlns="http://namespaces.zope.org/browser"
- i18n_domain="z3c.configurator">
-
- <page
- for="*"
- permission="z3c.configurator.ManageConfigurations"
- name="configurators.html"
- title="Configurators"
- class=".views.ConfigureForm"
- menu="zmi_views"/>
-
-</configure>
\ No newline at end of file
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/configure.zcml (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/browser/configure.zcml)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/configure.zcml (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/configure.zcml 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,16 @@
+<configure
+ xmlns:zope="http://namespaces.zope.org/zope"
+ xmlns="http://namespaces.zope.org/browser"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ zcml:condition="installed zope.formlib"
+ i18n_domain="z3c.configurator">
+
+ <page
+ for="*"
+ permission="z3c.configurator.ManageConfigurations"
+ name="configurators.html"
+ title="Configurators"
+ class=".views.ConfigureForm"
+ menu="zmi_views"/>
+
+</configure>
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/ftesting.zcml
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/browser/ftesting.zcml 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/ftesting.zcml 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,64 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- xmlns:meta="http://namespaces.zope.org/meta"
- i18n_domain="zope">
-
- <include package="zope.app.zcmlfiles" />
-
- <include package="zope.securitypolicy" file="meta.zcml" />
- <include package="zope.app.authentication" />
- <securityPolicy
- component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-
- <include package="zope.app.securitypolicy" />
-
- <role id="zope.Anonymous" title="Everybody"
- description="All users have this role implicitly" />
-
- <role id="zope.Manager" title="Site Manager" />
-
-
- <principal
- id="zope.manager"
- title="Administrator"
- login="mgr"
- password="mgrpw" />
- <grant
- role="zope.Manager"
- principal="zope.manager"
- />
-
- <unauthenticatedPrincipal
- id="zope.anybody"
- title="Unauthenticated User" />
-
- <unauthenticatedGroup
- id="zope.Anybody"
- title="Unauthenticated Users"
- />
-
- <authenticatedGroup
- id="zope.Authenticated"
- title="Authenticated Users"
- />
-
- <everybodyGroup
- id="zope.Everybody"
- title="All Users"
- />
-
- <include package="zope.app.form.browser" />
- <include package="zope.formlib" />
- <include package="z3c.configurator"/>
-
- <adapter
- name="z3c.configurator.testing.settitle"
- factory="z3c.configurator.browser.testing.SetTitle"/>
-
- <adapter
- name="z3c.configurator.testing.setdescription"
- factory="z3c.configurator.browser.testing.SetDescription"/>
-
-
- <grantAll role="zope.Manager" />
-</configure>
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/ftesting.zcml (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/browser/ftesting.zcml)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/ftesting.zcml (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/ftesting.zcml 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,59 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:meta="http://namespaces.zope.org/meta"
+ i18n_domain="zope">
+
+ <include package="zope.app.zcmlfiles" />
+
+ <include package="zope.securitypolicy" file="meta.zcml" />
+ <include package="zope.securitypolicy" />
+ <include package="zope.app.authentication" />
+ <securityPolicy
+ component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+
+ <role id="zope.Anonymous" title="Everybody"
+ description="All users have this role implicitly" />
+
+ <role id="zope.Manager" title="Site Manager" />
+
+ <principal
+ id="zope.manager"
+ title="Administrator"
+ login="mgr"
+ password="mgrpw" />
+
+ <grant
+ role="zope.Manager"
+ principal="zope.manager" />
+
+ <unauthenticatedPrincipal
+ id="zope.anybody"
+ title="Unauthenticated User" />
+
+ <unauthenticatedGroup
+ id="zope.Anybody"
+ title="Unauthenticated Users" />
+
+ <authenticatedGroup
+ id="zope.Authenticated"
+ title="Authenticated Users" />
+
+ <everybodyGroup
+ id="zope.Everybody"
+ title="All Users" />
+
+ <include package="zope.app.form.browser" />
+ <include package="zope.formlib" />
+ <include package="z3c.configurator"/>
+
+ <adapter
+ name="z3c.configurator.testing.settitle"
+ factory="z3c.configurator.browser.testing.SetTitle"/>
+
+ <adapter
+ name="z3c.configurator.testing.setdescription"
+ factory="z3c.configurator.browser.testing.SetDescription"/>
+
+ <grantAll role="zope.Manager" />
+
+</configure>
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/testing.py
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/browser/testing.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/testing.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,32 +0,0 @@
-"""Some test classes
-"""
-from z3c.configurator import configurator
-from zope import interface
-from zope import component
-from zope import schema
-from zope.dublincore.interfaces import IZopeDublinCore
-from zope.annotation.interfaces import IAttributeAnnotatable
-
-class ISingleArg(interface.Interface):
-
- arg = schema.TextLine(title=u'Some Argument')
-
-class SetTitle(configurator.SchemaConfigurationPluginBase):
- """makes an object implement IFoo"""
- component.adapts(IAttributeAnnotatable)
- schema = ISingleArg
-
- def __call__(self, data):
- dc = IZopeDublinCore(self.context)
- dc.title = data.get('arg')
-
-class SetDescription(configurator.SchemaConfigurationPluginBase):
-
- component.adapts(IAttributeAnnotatable)
- schema = ISingleArg
-
- def __call__(self, data):
- dc = IZopeDublinCore(self.context)
- dc.description = data.get('arg')
-
-
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/testing.py (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/browser/testing.py)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/testing.py (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/testing.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,30 @@
+"""Some test classes
+"""
+from z3c.configurator import configurator
+from zope import interface
+from zope import component
+from zope import schema
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.annotation.interfaces import IAttributeAnnotatable
+
+class ISingleArg(interface.Interface):
+
+ arg = schema.TextLine(title=u'Some Argument')
+
+class SetTitle(configurator.SchemaConfigurationPluginBase):
+ """makes an object implement IFoo"""
+ component.adapts(IAttributeAnnotatable)
+ schema = ISingleArg
+
+ def __call__(self, data):
+ dc = IZopeDublinCore(self.context)
+ dc.title = data.get('arg')
+
+class SetDescription(configurator.SchemaConfigurationPluginBase):
+
+ component.adapts(IAttributeAnnotatable)
+ schema = ISingleArg
+
+ def __call__(self, data):
+ dc = IZopeDublinCore(self.context)
+ dc.description = data.get('arg')
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/views.py
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/browser/views.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/views.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,125 +0,0 @@
-from zope import interface
-from zope import schema
-
-from zope import formlib
-from zope.formlib import form
-from zope.app.pagetemplate import ViewPageTemplateFile
-from zope.cachedescriptors.property import Lazy
-from z3c.configurator import interfaces
-from z3c.configurator.i18n import _
-from z3c.configurator import configurator
-
-
-class SelectPlugins(form.PageForm):
-
- """a form to choose plugins, to be applied"""
-
- form_fields = form.Fields(
- schema.Choice(__name__=u'pluginName',
- title=_(u'Plugin Name'),
- vocabulary="Configurator Plugin Names")
- )
-
- @form.action(label=_(u'Apply Configuration'))
- def selectPlugins(self, action, data):
- pluginName = data.get('pluginName')
- configurator.configure(self.context, names=[pluginName])
- self.status = _('Configuration applied')
-
-class IGenerateSchema(interface.Interface):
- """Schema for the minimal generator parameters"""
-
- seed = schema.TextLine(
- title = _(u'Seed'),
- description = _(u'A seed for the random generator'),
- default = u'sample',
- required=False,
- )
-
-
-class ConfigureForm(form.PageForm):
- """Configurator Plugin form"""
-
- base_template = form.EditForm.template
- template = ViewPageTemplateFile('configure.pt')
- subforms = []
-
- form_fields = form.Fields(
- schema.List(__name__=u'pluginNames',
- title=u'Plugin Names',
- value_type=schema.Choice(
- __name__=u'pluginName',
- title=_(u'Plugin Name'),
- vocabulary="Configurator Plugin Names")
- ))
-
- workDone = False
-
- @Lazy
- def _pluginNames(self):
- names = self.request.form.get(self.prefix + '.pluginNames')
- if names and not type(names) is type([]):
- return [names]
- return names
-
- def setUpWidgets(self, ignore_request=False):
- if self._pluginNames:
- plugins = configurator.requiredPlugins(self.context,
- self._pluginNames)
- self.subforms = []
- for name, factory in plugins:
- plugin = factory(self.context)
- if not interfaces.ISchemaConfigurationPlugin.providedBy(
- plugin):
- continue
- subform = PluginSchemaForm(context=self.context,
- request=self.request,
- plugin=plugin,
- prefix=name)
- subform.form_fields = form.Fields(plugin.schema)
- self.subforms.append(subform)
- super(ConfigureForm, self).setUpWidgets(ignore_request=ignore_request)
-
- @form.action(_("Update"))
- def handleUpdate(self, action, data):
- if not self._pluginNames:
- return
- self.setUpWidgets(ignore_request=False)
- result = self.template()
- return result
-
- def _pluginsSelected(self, action):
- return not not self.request.form.get(self.prefix + '.pluginNames')
-
- @form.action(_("Apply"), condition='_pluginsSelected')
- def handleApply(self, action, data):
-
- configuratorData = {}
- for subform in self.subforms:
- subform.update()
- formData = {}
- errors = form.getWidgetsData(subform.widgets,
- subform.prefix,
- formData)
- configuratorData[subform.prefix] = formData
-
- configurator.configure(self.context,
- configuratorData,
- names=self._pluginNames,
- useNameSpaces=True)
- self.status = u'Applied: %s' % u' '.join(self._pluginNames)
-
-
-class PluginSchemaForm(form.AddForm):
- """An editor for a single schema based plugin"""
- interface.implements(formlib.interfaces.ISubPageForm)
- template = formlib.namedtemplate.NamedTemplate('default')
- actions = []
-
- def __init__(self, context, request, plugin=None,
- schema=None, prefix=''):
- self.plugin = plugin
- self.schema = schema
- self.prefix = prefix
- super(PluginSchemaForm, self).__init__(context, request)
-
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/views.py (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/browser/views.py)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/views.py (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/browser/views.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,125 @@
+from zope import interface
+from zope import schema
+
+from zope import formlib
+from zope.formlib import form
+from zope.app.pagetemplate import namedtemplate
+from zope.app.pagetemplate import ViewPageTemplateFile
+from z3c.configurator import interfaces
+from z3c.configurator.i18n import _
+from z3c.configurator import configurator
+
+
+class SelectPlugins(form.PageForm):
+
+ """a form to choose plugins, to be applied"""
+
+ form_fields = form.Fields(
+ schema.Choice(__name__=u'pluginName',
+ title=_(u'Plugin Name'),
+ vocabulary="Configurator Plugin Names")
+ )
+
+ @form.action(label=_(u'Apply Configuration'))
+ def selectPlugins(self, action, data):
+ pluginName = data.get('pluginName')
+ configurator.configure(self.context, names=[pluginName])
+ self.status = _('Configuration applied')
+
+
+class IGenerateSchema(interface.Interface):
+ """Schema for the minimal generator parameters"""
+
+ seed = schema.TextLine(
+ title = _(u'Seed'),
+ description = _(u'A seed for the random generator'),
+ default = u'sample',
+ required=False,
+ )
+
+
+class ConfigureForm(form.PageForm):
+ """Configurator Plugin form"""
+
+ base_template = form.EditForm.template
+ template = ViewPageTemplateFile('configure.pt')
+ subforms = []
+
+ form_fields = form.Fields(
+ schema.List(__name__=u'pluginNames',
+ title=u'Plugin Names',
+ value_type=schema.Choice(
+ __name__=u'pluginName',
+ title=_(u'Plugin Name'),
+ vocabulary="Configurator Plugin Names")
+ ))
+
+ workDone = False
+
+ @property
+ def _pluginNames(self):
+ names = self.request.form.get(self.prefix + '.pluginNames')
+ if names and not type(names) is type([]):
+ return [names]
+ return names
+
+ def setUpWidgets(self, ignore_request=False):
+ if self._pluginNames:
+ plugins = configurator.requiredPlugins(self.context,
+ self._pluginNames)
+ self.subforms = []
+ for name, factory in plugins:
+ plugin = factory(self.context)
+ if not interfaces.ISchemaConfigurationPlugin.providedBy(
+ plugin):
+ continue
+ subform = PluginSchemaForm(context=self.context,
+ request=self.request,
+ plugin=plugin,
+ prefix=name)
+ subform.form_fields = form.Fields(plugin.schema)
+ self.subforms.append(subform)
+ super(ConfigureForm, self).setUpWidgets(ignore_request=ignore_request)
+
+ @form.action(_("Update"))
+ def handleUpdate(self, action, data):
+ if not self._pluginNames:
+ return
+ self.setUpWidgets(ignore_request=False)
+ result = self.template()
+ return result
+
+ def _pluginsSelected(self, action):
+ return not not self.request.form.get(self.prefix + '.pluginNames')
+
+ @form.action(_("Apply"), condition='_pluginsSelected')
+ def handleApply(self, action, data):
+
+ configuratorData = {}
+ for subform in self.subforms:
+ subform.update()
+ formData = {}
+ errors = form.getWidgetsData(subform.widgets,
+ subform.prefix,
+ formData)
+ configuratorData[subform.prefix] = formData
+
+ configurator.configure(self.context,
+ configuratorData,
+ names=self._pluginNames,
+ useNameSpaces=True)
+ self.status = u'Applied: %s' % u' '.join(self._pluginNames)
+
+
+class PluginSchemaForm(form.AddForm):
+ """An editor for a single schema based plugin"""
+ interface.implements(formlib.interfaces.ISubPageForm)
+ template = namedtemplate.NamedTemplate('default')
+ actions = []
+
+ def __init__(self, context, request, plugin=None,
+ schema=None, prefix=''):
+ self.plugin = plugin
+ self.schema = schema
+ self.prefix = prefix
+ super(PluginSchemaForm, self).__init__(context, request)
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/configurator.py
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/configurator.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/configurator.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,107 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 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.
-#
-##############################################################################
-"""Configurator Implementation
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-import zope.component
-import zope.interface
-import zope.schema
-
-from z3c.configurator import interfaces
-
-def getAdapterFactories(component, specific=True):
- """Get adapter registrations where @iface is provided and prefer
- the specific registrations."""
- iface = interfaces.IConfigurationPlugin
- gsm = zope.component.getGlobalSiteManager()
- res = {}
- for reg in gsm.registeredAdapters():
- # Only get adapters for which this interface is provided
- if reg.provided is None or not reg.provided.isOrExtends(iface):
- continue
- if reg.required[0].providedBy(component):
- res[reg.name] = reg.factory
- if specific or reg.name in res:
- continue
- res[reg.name] = reg.factory
- return res
-
-def requiredPlugins(component, names=[]):
-
- """returns a list of tuples of (name, pluginfactory) in the right
- order to be executed"""
-
- if not names:
- # get all names we have available
- names = getAdapterFactories(component,
- specific=True).keys()
-
- # we need this in order to get dependencies from plugins which are
- # not available in the unconfigured component because the provided
- # interfaces may change during execution
- plugins = getAdapterFactories(component,
- specific=False)
-
- def _add(name, res):
- if name in seen:
- return
- seen.add(name)
- deps = getattr(plugins[name], 'dependencies', ())
- for dep in deps:
- if not dep in res:
- _add(dep, res)
- if name not in res:
- res.append(name)
- seen = set()
- res = []
- for name in names:
- _add(name, res)
- return [(name, plugins[name]) for name in res]
-
-def configure(component, data, names=[], useNameSpaces=False):
-
- plugins = requiredPlugins(component, names)
-
- for name, factory in plugins:
- if useNameSpaces is True:
- d = data.get(name, {})
- else:
- d = data
- plugin = factory(component)
- plugin(d)
-
-class ConfigurationPluginBase(object):
- zope.interface.implements(interfaces.IConfigurationPlugin)
-
- def __init__(self, context):
- self.context = context
-
- def __call__(self, data):
- raise NotImplementedError
-
-class SchemaConfigurationPluginBase(object):
- zope.interface.implements(interfaces.ISchemaConfigurationPlugin)
- schema = zope.interface.Interface
-
- def __init__(self, context):
- self.context = context
-
- def verify(self, data):
- for name, field in zope.schema.getFields(self.schema).items():
- field.validate(data.get(name))
-
- def __call__(self, data):
- raise NotImplementedError
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/configurator.py (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/configurator.py)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/configurator.py (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/configurator.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,107 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Foundation 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.
+#
+##############################################################################
+"""Configurator Implementation
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+import zope.component
+import zope.interface
+import zope.schema
+
+from z3c.configurator import interfaces
+
+def getAdapterFactories(component, specific=True):
+ """Get adapter registrations where @iface is provided and prefer
+ the specific registrations."""
+ iface = interfaces.IConfigurationPlugin
+ gsm = zope.component.getGlobalSiteManager()
+ res = {}
+ for reg in gsm.registeredAdapters():
+ # Only get adapters for which this interface is provided
+ if reg.provided is None or not reg.provided.isOrExtends(iface):
+ continue
+ if reg.required[0].providedBy(component):
+ res[reg.name] = reg.factory
+ if specific or reg.name in res:
+ continue
+ res[reg.name] = reg.factory
+ return res
+
+def requiredPlugins(component, names=[]):
+
+ """returns a list of tuples of (name, pluginfactory) in the right
+ order to be executed"""
+
+ if not names:
+ # get all names we have available
+ names = getAdapterFactories(component,
+ specific=True).keys()
+
+ # we need this in order to get dependencies from plugins which are
+ # not available in the unconfigured component because the provided
+ # interfaces may change during execution
+ plugins = getAdapterFactories(component,
+ specific=False)
+
+ def _add(name, res):
+ if name in seen:
+ return
+ seen.add(name)
+ deps = getattr(plugins[name], 'dependencies', ())
+ for dep in deps:
+ if not dep in res:
+ _add(dep, res)
+ if name not in res:
+ res.append(name)
+ seen = set()
+ res = []
+ for name in names:
+ _add(name, res)
+ return [(name, plugins[name]) for name in res]
+
+def configure(component, data, names=[], useNameSpaces=False):
+
+ plugins = requiredPlugins(component, names)
+
+ for name, factory in plugins:
+ if useNameSpaces is True:
+ d = data.get(name, {})
+ else:
+ d = data
+ plugin = factory(component)
+ plugin(d)
+
+class ConfigurationPluginBase(object):
+ zope.interface.implements(interfaces.IConfigurationPlugin)
+
+ def __init__(self, context):
+ self.context = context
+
+ def __call__(self, data):
+ raise NotImplementedError
+
+class SchemaConfigurationPluginBase(object):
+ zope.interface.implements(interfaces.ISchemaConfigurationPlugin)
+ schema = zope.interface.Interface
+
+ def __init__(self, context):
+ self.context = context
+
+ def verify(self, data):
+ for name, field in zope.schema.getFields(self.schema).items():
+ field.validate(data.get(name))
+
+ def __call__(self, data):
+ raise NotImplementedError
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/configure.zcml
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/configure.zcml 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/configure.zcml 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,17 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- i18n_domain="z3c.configurator">
-
- <permission
- id="z3c.configurator.ManageConfigurations"
- title="Manage Configurations"
- />
-
- <utility
- component=".vocabulary.pluginNamesVocabulary"
- provides="zope.schema.interfaces.IVocabularyFactory"
- name="Configurator Plugin Names"/>
-
- <include package=".browser"/>
-
-</configure>
\ No newline at end of file
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/configure.zcml (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/configure.zcml)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/configure.zcml (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/configure.zcml 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,17 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="z3c.configurator">
+
+ <permission
+ id="z3c.configurator.ManageConfigurations"
+ title="Manage Configurations"
+ />
+
+ <utility
+ component=".vocabulary.pluginNamesVocabulary"
+ provides="zope.schema.interfaces.IVocabularyFactory"
+ name="Configurator Plugin Names"/>
+
+ <include package=".browser"/>
+
+</configure>
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/i18n.py
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/i18n.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/i18n.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,10 +0,0 @@
-"""The i18n definitions.
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-import zope.i18nmessageid
-
-_ = zope.i18nmessageid.MessageFactory('z3c.configurator')
-
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/i18n.py (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/i18n.py)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/i18n.py (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/i18n.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,9 @@
+"""The i18n definitions.
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import zope.i18nmessageid
+
+_ = zope.i18nmessageid.MessageFactory('z3c.configurator')
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/interfaces.py
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/interfaces.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/interfaces.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,52 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 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.
-#
-##############################################################################
-"""Configurator Interfaces
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-import zope.interface
-import zope.schema
-
-
-class CyclicDependencyError(ValueError):
- """Cyclic dependency of configuration plugins"""
-
-
-class DataMissingError(ValueError):
- """Error raised when required data is missing during configuration
- execution."""
-
-
-class IConfigurationPlugin(zope.interface.Interface):
- """An object executing one configuration step."""
-
- dependencies = zope.interface.Attribute(
- """A sequence of dependencies to other configuration plugins.""")
-
- def __call__(self, data):
- """Execute the configuration.
-
- The data is a dictionary containing values that might be of interest
- to the configuration plugin. When some required data field is missing,
- then raise a ``DataMissingError`` error.
- """
-
-class ISchemaConfigurationPlugin(IConfigurationPlugin):
- """A configuration plugin that provides a data schema."""
-
- schema = zope.schema.Object(
- title=u"Configuration Schema",
- description=u"The schema describing the data fields needed.",
- schema=zope.interface.interfaces.IInterface)
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/interfaces.py (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/interfaces.py)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/interfaces.py (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/interfaces.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,53 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Foundation 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.
+#
+##############################################################################
+"""Configurator Interfaces
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+import zope.interface
+import zope.schema
+
+
+class CyclicDependencyError(ValueError):
+ """Cyclic dependency of configuration plugins"""
+
+
+class DataMissingError(ValueError):
+ """Error raised when required data is missing during configuration
+ execution."""
+
+
+class IConfigurationPlugin(zope.interface.Interface):
+ """An object executing one configuration step."""
+
+ dependencies = zope.interface.Attribute(
+ """A sequence of dependencies to other configuration plugins.""")
+
+ def __call__(self, data):
+ """Execute the configuration.
+
+ The data is a dictionary containing values that might be of interest
+ to the configuration plugin. When some required data field is missing,
+ then raise a ``DataMissingError`` error.
+ """
+
+
+class ISchemaConfigurationPlugin(IConfigurationPlugin):
+ """A configuration plugin that provides a data schema."""
+
+ schema = zope.schema.Object(
+ title=u"Configuration Schema",
+ description=u"The schema describing the data fields needed.",
+ schema=zope.interface.interfaces.IInterface)
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/tests.py
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/tests.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/tests.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,42 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 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.
-#
-##############################################################################
-"""Configurator Test Setup
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-__docformat__ = 'restructuredtext'
-
-import unittest
-from zope.testing import doctest
-from zope.testing.doctestunit import DocFileSuite
-from zope.app.testing import setup
-
-def setUp(test):
- setup.placelessSetUp()
-
-def tearDown(test):
- setup.placelessTearDown()
-
-
-def test_suite():
- return unittest.TestSuite((
- DocFileSuite('README.txt',
- setUp=setUp, tearDown=tearDown,
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
- ),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/tests.py (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/tests.py)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/tests.py (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/tests.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,40 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Foundation 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.
+#
+##############################################################################
+"""Configurator Test Setup
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+__docformat__ = 'restructuredtext'
+
+import unittest, doctest
+from zope.app.testing import setup
+
+def setUp(test):
+ setup.placelessSetUp()
+
+def tearDown(test):
+ setup.placelessTearDown()
+
+
+def test_suite():
+ return unittest.TestSuite((
+ doctest.DocFileSuite('README.txt',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Deleted: z3c.configurator/tags/1.2.0/src/z3c/configurator/vocabulary.py
===================================================================
--- z3c.configurator/trunk/src/z3c/configurator/vocabulary.py 2009-12-19 18:49:49 UTC (rev 106787)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/vocabulary.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -1,29 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 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.
-#
-##############################################################################
-"""Vocabularies
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-from zope import component
-from zope.schema import vocabulary
-import interfaces
-
-def pluginNamesVocabulary(context):
- """a vocabulary that returns all names of registered configuration
- plugins"""
- terms = []
- plugins = dict(component.getAdapters(
- (context,), interfaces.IConfigurationPlugin))
- return vocabulary.SimpleVocabulary.fromValues(sorted(plugins.keys()))
Copied: z3c.configurator/tags/1.2.0/src/z3c/configurator/vocabulary.py (from rev 106790, z3c.configurator/trunk/src/z3c/configurator/vocabulary.py)
===================================================================
--- z3c.configurator/tags/1.2.0/src/z3c/configurator/vocabulary.py (rev 0)
+++ z3c.configurator/tags/1.2.0/src/z3c/configurator/vocabulary.py 2009-12-20 03:54:58 UTC (rev 106794)
@@ -0,0 +1,29 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Foundation 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.
+#
+##############################################################################
+"""Vocabularies
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+from zope import component
+from zope.schema import vocabulary
+import interfaces
+
+def pluginNamesVocabulary(context):
+ """a vocabulary that returns all names of registered configuration
+ plugins"""
+ terms = []
+ plugins = dict(component.getAdapters(
+ (context,), interfaces.IConfigurationPlugin))
+ return vocabulary.SimpleVocabulary.fromValues(sorted(plugins.keys()))
More information about the checkins
mailing list