[Checkins] SVN: five.localsitemanager/ Initial directory layout and
code for five.localsitemanager.
Rocky Burt
rocky at serverzen.com
Thu Feb 22 09:58:45 EST 2007
Log message for revision 72762:
Initial directory layout and code for five.localsitemanager.
Changed:
A five.localsitemanager/branches/
A five.localsitemanager/tags/
A five.localsitemanager/trunk/
A five.localsitemanager/trunk/CHANGES.txt
A five.localsitemanager/trunk/INSTALL.txt
A five.localsitemanager/trunk/MANIFEST.in
A five.localsitemanager/trunk/README.txt
A five.localsitemanager/trunk/setup.cfg.in
A five.localsitemanager/trunk/setup.py
A five.localsitemanager/trunk/src/
A five.localsitemanager/trunk/src/five/
A five.localsitemanager/trunk/src/five/__init__.py
A five.localsitemanager/trunk/src/five/localsitemanager/
A five.localsitemanager/trunk/src/five/localsitemanager/__init__.py
A five.localsitemanager/trunk/src/five/localsitemanager/browser.py
A five.localsitemanager/trunk/src/five/localsitemanager/components.py
A five.localsitemanager/trunk/src/five/localsitemanager/localsitemanager.txt
A five.localsitemanager/trunk/src/five/localsitemanager/overrides.zcml
A five.localsitemanager/trunk/src/five/localsitemanager/tests.py
-=-
Added: five.localsitemanager/trunk/CHANGES.txt
===================================================================
--- five.localsitemanager/trunk/CHANGES.txt 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/CHANGES.txt 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,7 @@
+CHANGES
+=======
+
+five.localsitemanager 0.1 (unreleased)
+--------------------------------------
+
+Initial version
Added: five.localsitemanager/trunk/INSTALL.txt
===================================================================
--- five.localsitemanager/trunk/INSTALL.txt 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/INSTALL.txt 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,43 @@
+Installing This Package
+=======================
+
+Prerequisites
+-------------
+
+* Zope 2.10.x
+
+* setuptools_
+
+
+Installation
+------------
+
+Place the ``five`` top-level package into your instance's
+``lib/python`` directory. You can also install it as an egg using
+easy_install_, for example into your instance by turning it into a
+workingenv_.
+
+
+Configuration
+-------------
+
+Place a ``five.localsitemanager-configure.zcml`` file into your instance's
+``etc/package-includes`` directory with the following contents::
+
+ <include package="five.localsitemanager" />
+
+Alternatively, you can also add this line to the bottom of
+``etc/site.zcml``.
+
+
+Running the Tests
+-----------------
+
+Use the following command to run this package's tests:
+
+ $ bin/zopectl test -s five.localsitemanager
+
+
+.. _workingenv: http://cheeseshop.python.org/pypi/workingenv.py
+.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
+.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
Added: five.localsitemanager/trunk/MANIFEST.in
===================================================================
--- five.localsitemanager/trunk/MANIFEST.in 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/MANIFEST.in 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1 @@
+exclude setup.cfg
Added: five.localsitemanager/trunk/README.txt
===================================================================
--- five.localsitemanager/trunk/README.txt 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/README.txt 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,33 @@
+five.localsitemanager
+=====================
+
+Overview
+--------
+
+``five.localsitemanager`` provides a local site manager based on the
+standard Zope 3 local site manager for Zope 2.
+
+Changes
+-------
+
+See CHANGES.txt.
+
+Installation
+------------
+
+See INSTALL.txt.
+
+Developer Resources
+-------------------
+
+- Subversion browser:
+
+ http://svn.zope.org/five.localsitemanager
+
+- Read-only Subversion checkout:
+
+ $ svn co svn://svn.zope.org/repos/main/five.localsitemanager/trunk
+
+- Writable Subversion checkout:
+
+ $ svn co svn+ssh://svn.zope.org/repos/main/five.localsitemanager/trunk
Added: five.localsitemanager/trunk/setup.cfg.in
===================================================================
--- five.localsitemanager/trunk/setup.cfg.in 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/setup.cfg.in 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,4 @@
+
+[egg_info]
+tag_build = .dev
+tag_svn_revision = 1
Added: five.localsitemanager/trunk/setup.py
===================================================================
--- five.localsitemanager/trunk/setup.py 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/setup.py 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,36 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Setup for five.localsitemanager package
+
+$Id$
+"""
+import os
+from setuptools import setup, Extension
+
+setup(name='five.localsitemanager',
+ version='0.1',
+ url='http://svn.zope.org/five.localsitemanager',
+ license='ZPL 2.1',
+ description='Local site manager implementation for Zope 2',
+ author='Zope Corporation and Contributors',
+ author_email='z3-five at codespeak.net',
+ long_description='',
+
+ packages=['five', 'five.localsitemanager'],
+ package_dir = {'': 'src'},
+ namespace_packages=['five',],
+ include_package_data = True,
+
+ zip_safe = True,
+ )
Added: five.localsitemanager/trunk/src/five/__init__.py
===================================================================
--- five.localsitemanager/trunk/src/five/__init__.py 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/src/five/__init__.py 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,7 @@
+# namespace package boilerplate
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError, e:
+ from pkgutil import extend_path
+ __path__ = extend_path(__path__, __name__)
+
Added: five.localsitemanager/trunk/src/five/localsitemanager/__init__.py
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/__init__.py 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/src/five/localsitemanager/__init__.py 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1 @@
+# make this directory a package
Added: five.localsitemanager/trunk/src/five/localsitemanager/browser.py
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/browser.py 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/src/five/localsitemanager/browser.py 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,22 @@
+from five.localsitemanager.components import FivePersistentComponents
+from zope.component.globalregistry import base
+
+from Products.Five.component.browser import ObjectManagerSiteView
+from Products.Five.component.interfaces import IObjectManagerSite
+from Products.Five.component import enableSite
+
+class ObjectManagerSiteView(ObjectManagerSiteView):
+ """Configure the site setup for an ObjectManager.
+ """
+
+ def makeSite(self):
+ if IObjectManagerSite.providedBy(self.context):
+ raise ValueError('This is already a site')
+
+ enableSite(self.context, iface=IObjectManagerSite)
+
+ #TODO in the future we'll have to walk up to other site
+ # managers and put them in the bases
+ components = FivePersistentComponents()
+ components.__bases__ = (base,)
+ self.context.setSiteManager(components)
Added: five.localsitemanager/trunk/src/five/localsitemanager/components.py
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/components.py 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/src/five/localsitemanager/components.py 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,4 @@
+from zope.component.persistentregistry import PersistentComponents
+
+class FivePersistentComponents(PersistentComponents):
+ pass
Added: five.localsitemanager/trunk/src/five/localsitemanager/localsitemanager.txt
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/localsitemanager.txt 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/src/five/localsitemanager/localsitemanager.txt 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,89 @@
+Local Site Manager
+==================
+
+We start from an empty folder. Since ``OFS.Folder``'s extend
+``ObjectSiteManager`` they all get to be ``IPossibleSite``'s.
+
+ >>> from OFS.Folder import Folder
+ >>> site = Folder('site')
+
+Of course we now need to transform that IPossibleSite into a real ISite.
+
+ >>> import zope.component
+ >>> from zope.app.component.hooks import setSite as setActiveSite
+
+ >>> from five.localsitemanager.browser import ObjectManagerSiteView
+ >>> siteconfig = ObjectManagerSiteView(site, None)
+ >>> siteconfig.makeSite()
+ >>> sitemanager = site.getSiteManager()
+ >>> sitemanager
+ <FivePersistentComponents ...>
+
+Utilities
+---------
+
+Utilities can now be registered with our site manager. We can confirm this
+by setting up a test utility.
+
+ >>> from OFS.SimpleItem import SimpleItem
+ >>> from zope import interface
+
+ >>> class ITestUtility(interface.Interface):
+ ... def helloworld(): pass
+
+ >>> class TestUtility(SimpleItem):
+ ... interface.implements(ITestUtility)
+ ... def helloworld(self):
+ ... print 'Hello World'
+
+ >>> sitemanager.registerUtility(TestUtility('test'),
+ ... name=u'hello_world',
+ ... provided=ITestUtility)
+ >>> sitemanager.getUtility(ITestUtility, name=u'hello_world')
+ <TestUtility ...>
+
+Make sure the utility lookup only works when the correct active site has
+been configured.
+
+ >>> setActiveSite(None)
+ >>> zope.component.queryUtility(ITestUtility, name=u'hello_world') is None
+ True
+
+ >>> setActiveSite(site)
+ >>> zope.component.queryUtility(ITestUtility, name=u'hello_world')
+ <TestUtility ...>
+
+Adapters
+---------
+
+Adapters can now be registered with our site manager. We can confirm this
+by setting up a test adapter.
+
+ >>> from OFS.SimpleItem import SimpleItem
+ >>> from zope import interface
+
+ >>> class IFoo(interface.Interface): pass
+ >>> class Foo(object): interface.implements(IFoo)
+
+ >>> class ITestAdapter(interface.Interface): pass
+ >>> class TestAdapter(SimpleItem): interface.implements(ITestAdapter)
+
+
+ >>> sitemanager.registerAdapter(TestAdapter,
+ ... required=(IFoo,),
+ ... provided=ITestAdapter)
+ >>> sitemanager.getAdapter(Foo(), ITestAdapter)
+ <TestAdapter ...>
+
+Make sure the adapter lookup only works when the correct active site has
+been configured.
+
+ >>> setActiveSite(None)
+ >>> zope.component.queryAdapter(Foo(), ITestAdapter) is None
+ True
+
+ >>> setActiveSite(site)
+ >>> zope.component.queryAdapter(Foo(), ITestAdapter)
+ <TestAdapter ...>
+ >>> ITestAdapter(Foo())
+ <TestAdapter ...>
Added: five.localsitemanager/trunk/src/five/localsitemanager/overrides.zcml
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/overrides.zcml 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/src/five/localsitemanager/overrides.zcml 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,15 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
+
+ <configure package="Products.Five.component">
+ <browser:page
+ for="OFS.interfaces.IObjectManager"
+ name="components.html"
+ class="five.localsitemanager.browser.ObjectManagerSiteView"
+ template="components.pt"
+ permission="five.ManageSite"
+ />
+ </configure>
+
+</configure>
Added: five.localsitemanager/trunk/src/five/localsitemanager/tests.py
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/tests.py 2007-02-22 14:57:32 UTC (rev 72761)
+++ five.localsitemanager/trunk/src/five/localsitemanager/tests.py 2007-02-22 14:58:44 UTC (rev 72762)
@@ -0,0 +1,12 @@
+import unittest
+from Testing.ZopeTestCase import ZopeDocFileSuite
+from Testing.ZopeTestCase import FunctionalDocFileSuite
+
+def test_suite():
+ return unittest.TestSuite([
+ ZopeDocFileSuite('localsitemanager.txt',
+ package="five.localsitemanager")
+ ])
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
More information about the Checkins
mailing list