diff options
author | Hanno Schlichting <hanno@hannosch.eu> | 2010-04-30 17:42:26 +0000 |
---|---|---|
committer | Hanno Schlichting <hanno@hannosch.eu> | 2010-04-30 17:42:26 +0000 |
commit | 6b6fe742e9a2535ca33a4b310a7e832cad31b824 (patch) | |
tree | 995869a5e6cc6b76b7cabc8479a9dc7a10833ace | |
parent | 232cfd7e8b22d1bb73743bcb8da62d0ac1ab865d (diff) | |
download | zope-browser-6b6fe742e9a2535ca33a4b310a7e832cad31b824.tar.gz |
Update bootstrap and add missing svn:eol-style
-rw-r--r-- | bootstrap.py | 173 | ||||
-rw-r--r-- | buildout.cfg | 24 | ||||
-rw-r--r-- | src/zope/__init__.py | 14 | ||||
-rw-r--r-- | src/zope/browser/__init__.py | 2 | ||||
-rw-r--r-- | src/zope/browser/interfaces.py | 218 | ||||
-rw-r--r-- | src/zope/browser/tests.py | 64 |
6 files changed, 282 insertions, 213 deletions
diff --git a/bootstrap.py b/bootstrap.py index 43d948e..3404296 100644 --- a/bootstrap.py +++ b/bootstrap.py @@ -1,52 +1,121 @@ -##############################################################################
-#
-# 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: bootstrap.py 73733 2007-03-27 13:29:11Z dobe $
-"""
-
-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)
+############################################################################## +# +# 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 +from optparse import OptionParser + +tmpeggs = tempfile.mkdtemp() + +is_jython = sys.platform.startswith('java') + +# parsing arguments +parser = OptionParser() +parser.add_option("-v", "--version", dest="version", + help="use a specific zc.buildout version") +parser.add_option("-d", "--distribute", + action="store_true", dest="distribute", default=False, + help="Use Disribute rather than Setuptools.") + +parser.add_option("-c", None, action="store", dest="config_file", + help=("Specify the path to the buildout configuration " + "file to be used.")) + +options, args = parser.parse_args() + +# if -c was provided, we push it back into args for buildout' main function +if options.config_file is not None: + args += ['-c', options.config_file] + +if options.version is not None: + VERSION = '==%s' % options.version +else: + VERSION = '' + +USE_DISTRIBUTE = options.distribute +args = args + ['bootstrap'] + +to_reload = False +try: + import pkg_resources + if not hasattr(pkg_resources, '_distribute'): + to_reload = True + raise ImportError +except ImportError: + ez = {} + if USE_DISTRIBUTE: + exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py' + ).read() in ez + ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True) + else: + exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' + ).read() in ez + ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) + + if to_reload: + reload(pkg_resources) + else: + import pkg_resources + +if sys.platform == 'win32': + def quote(c): + if ' ' in c: + return '"%s"' % c # work around spawn lamosity on windows + else: + return c +else: + def quote (c): + return c + +cmd = 'from setuptools.command.easy_install import main; main()' +ws = pkg_resources.working_set + +if USE_DISTRIBUTE: + requirement = 'distribute' +else: + requirement = 'setuptools' + +if is_jython: + import subprocess + + assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', + quote(tmpeggs), 'zc.buildout' + VERSION], + env=dict(os.environ, + PYTHONPATH= + ws.find(pkg_resources.Requirement.parse(requirement)).location + ), + ).wait() == 0 + +else: + assert os.spawnle( + os.P_WAIT, sys.executable, quote (sys.executable), + '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION, + dict(os.environ, + PYTHONPATH= + ws.find(pkg_resources.Requirement.parse(requirement)).location + ), + ) == 0 + +ws.add_entry(tmpeggs) +ws.require('zc.buildout' + VERSION) +import zc.buildout.buildout +zc.buildout.buildout.main(args) +shutil.rmtree(tmpeggs) diff --git a/buildout.cfg b/buildout.cfg index 598effe..f7d2204 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -1,12 +1,12 @@ -[buildout]
-develop = .
-parts = test py
-
-[test]
-recipe = zc.recipe.testrunner
-eggs = zope.browser [test]
-
-[py]
-recipe = zc.recipe.egg
-eggs = zope.browser
-interpreter = py
+[buildout] +develop = . +parts = test py + +[test] +recipe = zc.recipe.testrunner +eggs = zope.browser [test] + +[py] +recipe = zc.recipe.egg +eggs = zope.browser +interpreter = py diff --git a/src/zope/__init__.py b/src/zope/__init__.py index c2c4975..2e2033b 100644 --- a/src/zope/__init__.py +++ b/src/zope/__init__.py @@ -1,7 +1,7 @@ -# this is a namespace package
-try:
- import pkg_resources
- pkg_resources.declare_namespace(__name__)
-except ImportError:
- import pkgutil
- __path__ = pkgutil.extend_path(__path__, __name__)
+# this is a namespace package +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/src/zope/browser/__init__.py b/src/zope/browser/__init__.py index e7ae9de..4014849 100644 --- a/src/zope/browser/__init__.py +++ b/src/zope/browser/__init__.py @@ -1 +1 @@ -# make a package
+# make a package diff --git a/src/zope/browser/interfaces.py b/src/zope/browser/interfaces.py index efa5c80..00eb9b7 100644 --- a/src/zope/browser/interfaces.py +++ b/src/zope/browser/interfaces.py @@ -1,109 +1,109 @@ -##############################################################################
-#
-# Copyright (c) 2004-2009 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.
-#
-##############################################################################
-"""Shared dependency less Zope3 brwoser components.
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import Attribute
-from zope.interface import Interface
-
-class IView(Interface):
- """ Views are multi-adapters for context and request objects.
- """
- context = Attribute("The context object the view renders")
- request = Attribute("The request object driving the view")
-
-class IBrowserView(IView):
- """ Views which are specialized for requests from a browser
-
- o Such views are distinct from those geerated via WebDAV, FTP, XML-RPC,
- etc..
- """
-
-class IAdding(IBrowserView):
- """ Multi-adapter interface for views which add items to containers.
-
- o The 'context' of the view must implement ``zope.container.IContainer``.
- """
- def add(content):
- """Add content object to context.
-
- Add using the name in `contentName`.
-
- Return the added object in the context of its container.
-
- If `contentName` is already used in container, raise
- ``zope.container.interfaces.DuplicateIDError``.
- """
-
- contentName = Attribute(
- """The content name, usually set by the Adder traverser.
-
- If the content name hasn't been defined yet, returns ``None``.
-
- Some creation views might use this to optionally display the
- name on forms.
- """
- )
-
- def nextURL():
- """Return the URL that the creation view should redirect to.
-
- This is called by the creation view after calling add.
-
- It is the adder's responsibility, not the creation view's to
- decide what page to display after content is added.
- """
-
- def nameAllowed():
- """Return whether names can be input by the user.
- """
-
- def addingInfo():
- """Return add menu data as a sequence of mappings.
-
- Each mapping contains 'action', 'title', and possibly other keys.
-
- The result is sorted by title.
- """
-
- def isSingleMenuItem():
- """Return whether there is single menu item or not."""
-
- def hasCustomAddView():
- "This should be called only if there is `singleMenuItem` else return 0"
-
-
-class ITerms(Interface):
- """ Adapter providing lookups for vocabulary terms.
- """
- def getTerm(value):
- """Return an ITitledTokenizedTerm object for the given value
-
- LookupError is raised if the value isn't in the source
- """
-
- def getValue(token):
- """Return a value for a given identifier token
-
- LookupError is raised if there isn't a value in the source.
- """
-
-class ISystemErrorView(Interface):
- """Error views that can classify their contexts as system errors
- """
-
- def isSystemError():
- """Return a boolean indicating whether the error is a system errror
- """
+############################################################################## +# +# Copyright (c) 2004-2009 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. +# +############################################################################## +"""Shared dependency less Zope3 brwoser components. +""" +__docformat__ = 'restructuredtext' + +from zope.interface import Attribute +from zope.interface import Interface + +class IView(Interface): + """ Views are multi-adapters for context and request objects. + """ + context = Attribute("The context object the view renders") + request = Attribute("The request object driving the view") + +class IBrowserView(IView): + """ Views which are specialized for requests from a browser + + o Such views are distinct from those geerated via WebDAV, FTP, XML-RPC, + etc.. + """ + +class IAdding(IBrowserView): + """ Multi-adapter interface for views which add items to containers. + + o The 'context' of the view must implement ``zope.container.IContainer``. + """ + def add(content): + """Add content object to context. + + Add using the name in `contentName`. + + Return the added object in the context of its container. + + If `contentName` is already used in container, raise + ``zope.container.interfaces.DuplicateIDError``. + """ + + contentName = Attribute( + """The content name, usually set by the Adder traverser. + + If the content name hasn't been defined yet, returns ``None``. + + Some creation views might use this to optionally display the + name on forms. + """ + ) + + def nextURL(): + """Return the URL that the creation view should redirect to. + + This is called by the creation view after calling add. + + It is the adder's responsibility, not the creation view's to + decide what page to display after content is added. + """ + + def nameAllowed(): + """Return whether names can be input by the user. + """ + + def addingInfo(): + """Return add menu data as a sequence of mappings. + + Each mapping contains 'action', 'title', and possibly other keys. + + The result is sorted by title. + """ + + def isSingleMenuItem(): + """Return whether there is single menu item or not.""" + + def hasCustomAddView(): + "This should be called only if there is `singleMenuItem` else return 0" + + +class ITerms(Interface): + """ Adapter providing lookups for vocabulary terms. + """ + def getTerm(value): + """Return an ITitledTokenizedTerm object for the given value + + LookupError is raised if the value isn't in the source + """ + + def getValue(token): + """Return a value for a given identifier token + + LookupError is raised if there isn't a value in the source. + """ + +class ISystemErrorView(Interface): + """Error views that can classify their contexts as system errors + """ + + def isSystemError(): + """Return a boolean indicating whether the error is a system errror + """ diff --git a/src/zope/browser/tests.py b/src/zope/browser/tests.py index dac1209..29b15fa 100644 --- a/src/zope/browser/tests.py +++ b/src/zope/browser/tests.py @@ -1,32 +1,32 @@ -##############################################################################
-#
-# 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:$
-"""
-__docformat__ = "reStructuredText"
-
-import unittest
-from zope.testing import doctest
-
-
-def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite('README.txt',
- optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
- ),
- ))
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+############################################################################## +# +# 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:$ +""" +__docformat__ = "reStructuredText" + +import unittest +from zope.testing import doctest + + +def test_suite(): + return unittest.TestSuite(( + doctest.DocFileSuite('README.txt', + optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS, + ), + )) + + +if __name__ == '__main__': + unittest.main(defaultTest='test_suite') |