[Checkins] SVN: lovely.zetup/trunk/ move lovely zetup to zope.org
Bernd Dorn
bernd.dorn at lovelysystems.com
Tue May 27 10:33:06 EDT 2008
Log message for revision 86981:
move lovely zetup to zope.org
Changed:
A lovely.zetup/trunk/
A lovely.zetup/trunk/CHANGES.txt
A lovely.zetup/trunk/bootstrap.py
A lovely.zetup/trunk/buildout.cfg
A lovely.zetup/trunk/coverage.cfg
A lovely.zetup/trunk/paste.ini
A lovely.zetup/trunk/setup.py
A lovely.zetup/trunk/src/
A lovely.zetup/trunk/src/lovely/
A lovely.zetup/trunk/src/lovely/__init__.py
A lovely.zetup/trunk/src/lovely/zetup/
A lovely.zetup/trunk/src/lovely/zetup/README.txt
A lovely.zetup/trunk/src/lovely/zetup/__init__.py
A lovely.zetup/trunk/src/lovely/zetup/app.py
A lovely.zetup/trunk/src/lovely/zetup/browser/
A lovely.zetup/trunk/src/lovely/zetup/browser/__init__.py
A lovely.zetup/trunk/src/lovely/zetup/browser/configure.zcml
A lovely.zetup/trunk/src/lovely/zetup/browser/contents.pt
A lovely.zetup/trunk/src/lovely/zetup/browser/views.py
A lovely.zetup/trunk/src/lovely/zetup/config.py
A lovely.zetup/trunk/src/lovely/zetup/configure.zcml
A lovely.zetup/trunk/src/lovely/zetup/event.py
A lovely.zetup/trunk/src/lovely/zetup/factory.py
A lovely.zetup/trunk/src/lovely/zetup/interfaces.py
A lovely.zetup/trunk/src/lovely/zetup/publication.py
A lovely.zetup/trunk/src/lovely/zetup/publication.txt
A lovely.zetup/trunk/src/lovely/zetup/testing/
A lovely.zetup/trunk/src/lovely/zetup/testing/__init__.py
A lovely.zetup/trunk/src/lovely/zetup/testing/ftesting.zcml
A lovely.zetup/trunk/src/lovely/zetup/testing/layer.txt
A lovely.zetup/trunk/src/lovely/zetup/testing/logging.cfg
A lovely.zetup/trunk/src/lovely/zetup/testing/paste.ini
A lovely.zetup/trunk/src/lovely/zetup/testing/testing.py
A lovely.zetup/trunk/src/lovely/zetup/testing/tests.py
A lovely.zetup/trunk/src/lovely/zetup/testing/xmlrpc.py
A lovely.zetup/trunk/src/lovely/zetup/tests.py
A lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/
A lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/__init__.py
A lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/browser.zcml
A lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/configure.zcml
A lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/folder.zcml
A lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/meta.zcml
-=-
Added: lovely.zetup/trunk/CHANGES.txt
===================================================================
--- lovely.zetup/trunk/CHANGES.txt (rev 0)
+++ lovely.zetup/trunk/CHANGES.txt 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,11 @@
+=======================
+Changes in lovely.zetup
+=======================
+
+before first release
+====================
+
+- implemented testbrowser
+- implemented paste app testing layer
+- moved over from lovely.zetup
+- removed ini based config
Property changes on: lovely.zetup/trunk/CHANGES.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/bootstrap.py
===================================================================
--- lovely.zetup/trunk/bootstrap.py (rev 0)
+++ lovely.zetup/trunk/bootstrap.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# 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)
Property changes on: lovely.zetup/trunk/bootstrap.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/buildout.cfg
===================================================================
--- lovely.zetup/trunk/buildout.cfg (rev 0)
+++ lovely.zetup/trunk/buildout.cfg 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,21 @@
+[buildout]
+extends = coverage.cfg
+develop = .
+parts = paste-scripts test importchecker
+ coverage-test coverage-out-dir
+ coverage-report coverage-report-dir
+ coverage
+find-links = http://download.zope.org/distribution
+
+[test]
+recipe = zc.recipe.testrunner
+defaults = ['--auto-color']
+eggs = lovely.zetup [test]
+
+[paste-scripts]
+recipe = zc.recipe.egg:script
+eggs = lovely.zetup
+ PasteScript
+
+[importchecker]
+recipe = lovely.recipe:importchecker
Property changes on: lovely.zetup/trunk/buildout.cfg
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/coverage.cfg
===================================================================
--- lovely.zetup/trunk/coverage.cfg (rev 0)
+++ lovely.zetup/trunk/coverage.cfg 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,33 @@
+
+[coverage-out-dir]
+recipe = lovely.recipe:mkdir
+path = ${buildout:parts-directory}/coverage_out
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+defaults = ['--coverage=${coverage-out-dir:path}']
+eggs = lovely.zetup [test]
+
+[coverage-report-dir]
+recipe = lovely.recipe:mkdir
+path = ${buildout:parts-directory}/coverage_report
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('${coverage-out-dir:path}', '${coverage-report-dir:path}')
+
+[coverage]
+recipe = lovely.recipe:mkfile
+path = ${buildout:bin-directory}/coverage
+mode = 0755
+content = #!/bin/sh
+ echo "Coverage cleanup..."
+ rm ${coverage-out-dir:path}/*
+ rm ${coverage-report-dir:path}/*
+ echo "Running coverage test..."
+ bin/coverage-test
+ echo "creating coverage report..."
+ bin/coverage-report
+
Property changes on: lovely.zetup/trunk/coverage.cfg
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/paste.ini
===================================================================
--- lovely.zetup/trunk/paste.ini (rev 0)
+++ lovely.zetup/trunk/paste.ini 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,11 @@
+[app:main]
+use = egg:lovely.zetup
+cfg = src/lovely/zetup/testing/testing.py
+
+[server:main]
+use = egg:paste#http
+host = localhost
+port = 9999
+threadpool_workers = 4
+threadpool_spawn_if_under = 0
+threadpool_max_requests = 0
Added: lovely.zetup/trunk/setup.py
===================================================================
--- lovely.zetup/trunk/setup.py (rev 0)
+++ lovely.zetup/trunk/setup.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,37 @@
+import os
+from setuptools import setup, find_packages
+
+setup(
+ name="lovely.zetup",
+ version="0.0.0",
+ zip_safe = False,
+ include_package_data = True,
+ packages = find_packages('src'),
+ namespace_packages=['lovely'],
+ extras_require = dict(
+ test = ['zope.testing',
+ 'zope.app.authentication',
+ #'zc.testbrowser'
+ ]
+ ),
+ install_requires = ['setuptools',
+ 'zope.interface',
+ 'zope.component',
+ 'zope.schema',
+ 'zope.event',
+ 'zope.error',
+ 'zope.app.component',
+ 'wsgi_intercept',
+ #'zope.app.zcmlfiles',
+ 'transaction',
+ #'zope.app.securitypolicy',
+ 'Paste',
+ 'PasteDeploy',
+ 'z3c.configurator',
+ ],
+ package_dir = {'':'src'},
+ entry_points = """
+ [paste.app_factory]
+ main = lovely.zetup.factory:app_factory
+ """
+ )
Property changes on: lovely.zetup/trunk/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/__init__.py
===================================================================
--- lovely.zetup/trunk/src/lovely/__init__.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/__init__.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,5 @@
+# this is a namespace package
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+ pass
Property changes on: lovely.zetup/trunk/src/lovely/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/README.txt
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/README.txt (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/README.txt 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,226 @@
+========================
+lovely.zetup with paste
+========================
+
+This example shows how to configure lovely.zetup as a wsgi
+application with the whole zope functionality but without the
+need of a ZODB storage and without zconfig.
+
+All config files reside in the testing subdirectory.
+
+ >>> import lovely.zetup, os
+ >>> testDir = os.path.join(os.path.dirname(lovely.zetup.__file__),
+ ... 'testing')
+
+Let ust first have a look at the paste config file. Via the use option
+we tell paste to use the lovely.zetup appfactory. The cfg options
+describes the relative path from this config file to the application
+specific config file which will be shown further down.
+
+ >>> print file(os.path.join(testDir, 'paste.ini')).read()
+ [app:main]
+ use = egg:lovely.zetup
+ cfg = testing.py
+ logging = off
+
+Note: The logging off switch means we don't enable logging
+configuration at all. We need this in testing because the zope
+testrunner somehow adds a NullHandler to the logger which then cannot
+be removed anymore.
+
+Application Configuration File
+==============================
+
+All configuration files are written in python. Below we see the
+contents of the application configuraton for this example.
+
+ >>> cfgFile = os.path.join(testDir, 'testing.py')
+ >>> cfg = {}
+ >>> execfile(cfgFile, {}, cfg)
+
+The config file has to define local variables - 'app' and an optional
+'sites' dictionary.
+
+ >>> from pprint import pprint
+
+The app dictionary
+------------------
+
+ >>> pprint(cfg['app'])
+ {'features': ['devmode'], 'logging': 'logging.cfg', 'zcml': 'ftesting.zcml'}
+
+The logging key defines which config file should be used to
+configure logging. This is actually a standard logging config file as
+described in
+http://docs.python.org/lib/logging-config-fileformat.html.
+
+The zcml key defines the path to the site's zcml file. And the
+'features' key is a list of named features to be enabled.
+
+
+The sites dictionary
+--------------------
+
+The sites dictionary is optional and defines the objects to be created
+upon startup along with config. The created objects do not
+necessarily need to be sites, but it is a common use-case to have
+sites below root - each with its own configuration.
+
+Each key in this dict is a site name.
+
+ >>> sites = cfg['sites']
+ >>> sites.keys()
+ [u'testsite', u'secondsite']
+
+
+There is one required key, which defines the IFactory utility to use
+as factory for the instantiation of the site object. In some cases
+this might be a custom site implementation, but for this test we just
+use the normal zope folder factory.
+
+ >>> sites['testsite']['factory']
+ 'zope.app.content.Folder'
+
+The settings key is just a custom example entry. Any item
+defined is available via the site object at runtime. So arbitrary
+configuration can be applied for special cases.
+
+ >>> sites['testsite']['settings']
+ {'testing.option1': 1}
+
+Each key defined in the ``configurator`` item defines which
+configurator with the given name should be run on the created
+object. For further information on configurators see the documentation
+of z3c.configurator.
+
+We have 2 configurators configured.
+
+ >>> pprint(sites['testsite']['configurators'])
+ {'testconfigurator.one': {'alist': ['server1:11211', 'server2:11211'],
+ 'someunicode': u'noreply at example.com'},
+ 'testconfigurator.two': {'afloat': 1.0, 'astring': 'Value of Name'}}
+
+The running Application
+=======================
+
+Let us now start our example application. We do this with the paste
+test fixture.
+
+ >>> from paste.fixture import TestApp
+ >>> app = TestApp('config:paste.ini',
+ ... relative_to=testDir)
+ called: 'ConfTwo', on u'testsite' with data:
+ {'afloat': 1.0, 'astring': 'Value of Name'}
+ called: 'ConfOne', on u'testsite' with data:
+ {'someunicode': u'noreply at example.com',
+ 'alist': ['server1:11211', 'server2:11211']}
+ called: 'ConfTwo', on u'secondsite' with data:
+ {'afloat': 1.0, 'astring': 'Value of Name'}
+ called: 'ConfOne', on u'secondsite' with data:
+ {'someunicode': u'noreply at example.com', 'alist':
+ ['server1:11211', 'server2:11211']}
+
+The example configurators we configured above are for testing and just
+print out some information when called. So therefore the printouts
+above. You see that each configurator is called twice because
+we defined two sites in our ``testing.cfg`` with the same config file.
+
+Now we should have a root object that can be traversed.
+
+ >>> app.get('/@@absolute_url').body
+ 'http://localhost'
+
+And the two site objects.
+
+ >>> app.get('/testsite/@@absolute_url').body
+ 'http://localhost/testsite'
+ >>> app.get('/secondsite/@@absolute_url').body
+ 'http://localhost/secondsite'
+
+The default contents view of the Rotterdam skin needs principal annotations.
+This package overwrites the content views for IFolder.
+
+ >>> from base64 import b64encode
+ >>> mgrHeaders = {'Authorization':'Basic %s' % b64encode('mgr:pw')}
+ >>> app.get('/@@contents.html', headers=mgrHeaders)
+ <Response 200 Ok '<!DOCTYPE html PUBLI'>
+
+The contents view for the site manager still has this problem.
+
+ >>> app.get('/++etc++site/@@contents.html', headers=mgrHeaders)
+ Traceback (most recent call last):
+ ...
+ AppError: Bad response: 500 Internal Server Error (not 200 OK or 3xx redirect for /++etc++site/@@contents.html)
+ <html><title>System Error</title>
+ <body>
+ A system error occurred.
+ </body>
+ </html>
+
+We can disable the error handling by the server by setting a wsgi
+environment variable. So we can investigate the error.
+
+ >>> env = {'wsgi.handleErrors': False}
+ >>> app.get('/++etc++site/@@contents.html', headers=mgrHeaders,
+ ... extra_environ=env)
+ Traceback (most recent call last):
+ ...
+ TypeError: ('Could not adapt',
+ <zope.app.security.principalregistry.Principal object at ...>,
+ <InterfaceClass zope.annotation.interfaces.IAnnotations>)
+
+We can do the same the way zope's testbrowser is doing it.
+
+ >>> env = {'HTTP_X_ZOPE_HANDLE_ERRORS': 'False'}
+ >>> app.get('/++etc++site/@@contents.html', headers=mgrHeaders,
+ ... extra_environ=env)
+ Traceback (most recent call last):
+ ...
+ TypeError: ('Could not adapt',
+ <zope.app.security.principalregistry.Principal object at ...>,
+ <InterfaceClass zope.annotation.interfaces.IAnnotations>)
+
+So the reason is that we have no principal annotation which is used to
+hold copy/paste info in the skin. So far this should not be a problem,
+because the only thing we need in zmi so far is the error report view
+and this works ;-)
+
+ >>> app.get('/++etc++site/errors/@@index.html', headers=mgrHeaders)
+ <Response 200 Ok '<!DOCTYPE html PUBLI'>
+
+Not all views of ++etc++process are available but runtime information
+can be viewed.
+
+ >>> app.get('/++etc++process/index.html', headers=mgrHeaders)
+ <Response 200 Ok '<!DOCTYPE html PUBLI'>
+
+XMLRPC Calls
+============
+
+XML-RPC requests are hanlded with the xmlrpc request factory. Actually
+this is a fault because we have not body.
+
+ >>> body = """<?xml version='1.0'?>
+ ... <methodCall>
+ ... <methodName>contents</methodName>
+ ... <params>
+ ... </params>
+ ... </methodCall>
+ ... """
+
+We get a folder listing here
+
+ >>> res = app.post('/', params=body, headers={'Content-Type':'text/xml'})
+ >>> print res.body
+ <?xml version='1.0'?>
+ <methodResponse>
+ <params>
+ <param>
+ <value><array><data>
+ <value><string>testsite</string></value>
+ <value><string>secondsite</string></value>
+ </data></array></value>
+ </param>
+ </params>
+ </methodResponse>
+ <BLANKLINE>
Property changes on: lovely.zetup/trunk/src/lovely/zetup/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/__init__.py
===================================================================
Property changes on: lovely.zetup/trunk/src/lovely/zetup/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/app.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/app.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/app.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,91 @@
+##############################################################################
+#
+# Copyright (c) 2006-2008 Lovely Systems GmbH. All Rights Reserved.
+#
+# This software is subject to the provisions of the Lovely Visible Source
+# License, Version 1.0 (LVSL). A copy of the LVSL 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'
+
+from zope.app.wsgi import WSGIPublisherApplication
+from zope.app.publication.interfaces import IPublicationRequestFactory
+from zope.publisher.browser import BrowserRequest
+from publication import NoZODBPublication
+from zope import interface
+from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.browser import setDefaultSkin
+from zope.publisher.publish import publish
+import zope.publisher.xmlrpc
+import xmlrpclib
+
+class XMLRPCRequest(zope.publisher.xmlrpc.XMLRPCRequest):
+
+ def processInputs(self):
+ 'See IPublisherRequest'
+ # override because we only read content_length in locking sockets
+ length = int(self._environ.get('CONTENT_LENGTH'))
+ lines = self._body_instream.read(length)
+ self._args, function = xmlrpclib.loads(lines)
+ # Translate '.' to '/' in function to represent object
+ # traversal.
+ function = function.split('.')
+ if function:
+ self.setPathSuffix(function)
+
+
+class PublicationRequestFactory(object):
+ interface.implements(IPublicationRequestFactory)
+
+ def __init__(self):
+ """See `zope.app.publication.interfaces.IPublicationRequestFactory`"""
+ self._publication_cache = {}
+ self._publication = NoZODBPublication()
+
+ def __call__(self, input_stream, env):
+ """See
+ `zope.app.publication.interfaces.IPublicationRequestFactory`"""
+ method = env.get('REQUEST_METHOD', 'GET').upper()
+ contentType = env.get('CONTENT_TYPE', '')
+ if method=='POST' and contentType == 'text/xml':
+ klass = XMLRPCRequest
+ else:
+ klass = BrowserRequest
+ request = klass(input_stream, env)
+ request.setPublication(self._publication)
+ if IBrowserRequest.providedBy(request):
+ # only browser requests have skins
+ setDefaultSkin(request)
+ return request
+
+class Application(WSGIPublisherApplication):
+
+ def __init__(self):
+ self.requestFactory = PublicationRequestFactory()
+
+ def __call__(self, environ, start_response):
+ """See zope.app.wsgi.interfaces.IWSGIApplication"""
+ request = self.requestFactory(environ['wsgi.input'], environ)
+ # Let's support post-mortem debugging
+ if 'HTTP_X_ZOPE_HANDLE_ERRORS' in environ:
+ handle_errors = environ.get('HTTP_X_ZOPE_HANDLE_ERRORS') == 'True'
+ else:
+ handle_errors = environ.get('wsgi.handleErrors', True)
+ request = publish(request, handle_errors=handle_errors)
+ response = request.response
+
+ # Start the WSGI server response
+ start_response(response.getStatusString(), response.getHeaders())
+
+ # Return the result body iterable.
+ return response.consumeBodyIter()
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/app.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/browser/__init__.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/browser/__init__.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/browser/__init__.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1 @@
+# package
Property changes on: lovely.zetup/trunk/src/lovely/zetup/browser/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/browser/configure.zcml
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/browser/configure.zcml (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/browser/configure.zcml 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,22 @@
+<configure xmlns="http://namespaces.zope.org/browser">
+
+ <page
+ name="index.html"
+ for="zope.app.container.interfaces.IContainer"
+ class=".views.NoZODBContents"
+ template="contents.pt"
+ permission="zope.View"
+ menu="zmi_views" title="Contents"
+ />
+
+ <page
+ name="contents.html"
+ for="zope.app.container.interfaces.IContainer"
+ class=".views.NoZODBContents"
+ template="contents.pt"
+ permission="zope.View"
+ menu="zmi_views" title="Contents"
+ />
+
+</configure>
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/browser/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/browser/contents.pt
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/browser/contents.pt (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/browser/contents.pt 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,58 @@
+<html metal:use-macro="context/@@standard_macros/view"
+ i18n:domain="zope">
+<body>
+<div metal:fill-slot="body">
+ <div metal:define-macro="contents">
+ <table id="sortable" class="listing" summary="Content listing"
+ i18n:attributes="summary">
+ <thead>
+ <tr>
+ <th i18n:translate="">Name</th>
+ <th i18n:translate="">Title</th>
+ <th i18n:translate="">Size</th>
+ <th i18n:translate="">Created</th>
+ <th i18n:translate="">Modified</th>
+ </tr>
+ </thead>
+ <tbody>
+ <metal:block tal:repeat="item view/listContentInfo">
+ <tr tal:define="oddrow repeat/item/odd; url item/url;
+ id_quoted item/id/url:quote"
+ tal:attributes="class python:oddrow and 'even' or 'odd'" >
+ <td><a href="#"
+ tal:attributes="href
+ string:${url}/@@SelectedManagementView.html"
+ tal:content="structure item/icon|default">
+ </a
+ ><span>
+ <a href="#"
+ tal:attributes="href
+ string:${url}/@@SelectedManagementView.html"
+ tal:content="item/id"
+ >foo</a
+ ></span
+ ></td>
+ <td>
+ <span
+ tal:content="item/title|default"
+ i18n:translate=""
+ > </span>
+ </td>
+ <td><span tal:content="item/size/sizeForDisplay|nothing"
+ i18n:translate="">
+ </span></td>
+ <td><span tal:define="created item/created|default"
+ tal:content="created"
+ i18n:translate=""> </span></td>
+ <td><span tal:define="modified item/modified|default"
+ tal:content="modified"
+ i18n:translate=""> </span></td>
+ </tr>
+ </metal:block>
+ </tbody>
+ </table>
+ </div>
+</div>
+</body>
+</html>
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/browser/contents.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/browser/views.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/browser/views.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/browser/views.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,79 @@
+##############################################################################
+#
+# Copyright (c) 2006-2008 Lovely Systems GmbH. All Rights Reserved.
+#
+# This software is subject to the provisions of the Lovely Visible Source
+# License, Version 1.0 (LVSL). A copy of the LVSL 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 urllib
+
+from zope import component
+
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.security.interfaces import Unauthorized
+from zope.size.interfaces import ISized
+from zope.app.container.browser.contents import Contents
+
+class NoZODBContents(Contents):
+
+ """handles contents without zodb
+
+ >>> from zope.publisher.browser import TestRequest
+ >>> class Content(object):pass
+ >>> obj = Content()
+ >>> obj.title=u"some title"
+ >>> from zope import interface
+ >>> interface.directlyProvides(obj, IZopeDublinCore)
+ >>> request = TestRequest()
+ >>> v = NoZODBContents({}, request)
+ >>> v.context['first'] = obj
+ >>> v.request = request
+ >>> [i for i in v.listContentInfo()]
+ [{'title': u'some title', 'url': 'first',
+ 'object': <lovely.zetup.browser.views.Content object at ...>,
+ 'cb_id': 'first', 'id': 'first', 'icon': None}]
+ """
+
+ def listContentInfo(self):
+ for id, obj in self.context.items():
+ info = {}
+ info['id'] = info['cb_id'] = id
+ info['object'] = obj
+ info['url'] = urllib.quote(id.encode('utf-8'))
+ zmi_icon = component.queryMultiAdapter((obj,
+ self.request),
+ name='zmi_icon')
+ if zmi_icon is None:
+ info['icon'] = None
+ else:
+ info['icon'] = zmi_icon()
+ dc = IZopeDublinCore(obj, None)
+ if dc is not None:
+ title = self.safe_getattr(dc, 'title', None)
+ if title:
+ info['title'] = title
+ formatter = self.request.locale.dates.getFormatter(
+ 'dateTime', 'short')
+ created = self.safe_getattr(dc, 'created', None)
+ if created is not None:
+ info['created'] = formatter.format(created)
+ modified = self.safe_getattr(dc, 'modified', None)
+ if modified is not None:
+ info['modified'] = formatter.format(modified)
+ sized_adapter = ISized(obj, None)
+ if sized_adapter is not None:
+ info['size'] = sized_adapter
+ yield info
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/browser/views.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/config.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/config.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/config.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,92 @@
+##############################################################################
+#
+# Copyright (c) 2006-2008 Lovely Systems GmbH. All Rights Reserved.
+#
+# This software is subject to the provisions of the Lovely Visible Source
+# License, Version 1.0 (LVSL). A copy of the LVSL 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 os
+from logging.config import fileConfig
+from zope.app.appsetup import appsetup
+from interfaces import IConfig, IConfigurableSite, ISiteConfig
+from zope import interface
+from zope import component
+import logging
+import time
+
+class Config(object):
+
+ """Config objects are instantiated with a path to a python file.
+
+ >>> Config('/notexistent')
+ Traceback (most recent call last):
+ ...
+ ValueError: Config file not found '/notexistent'
+
+ We need at least an app local in the file.
+
+ >>> path = os.path.join(os.path.dirname(__file__), '__init__.py')
+ >>> Config(path)
+ Traceback (most recent call last):
+ ...
+ ValueError: No app dict in config '.../zetup/__init__.py'
+
+ """
+ interface.implements(IConfig)
+
+ def __init__(self, path, withLogging=True):
+ if not os.path.isfile(path):
+ raise ValueError, "Config file not found %r" % path
+ self.data = {}
+ execfile(path, {}, self.data)
+ if not 'app' in self.data:
+ raise ValueError, "No app dict in config %r" % path
+ t = time.time()
+ self.path = os.path.abspath(path)
+ self.dir = os.path.dirname(self.path)
+ self.withLogging = withLogging
+ self.setUpLogging()
+ self.setUpZope()
+ self.setUpSiteConfigs()
+ logging.info('Configured Application %s' % (time.time()-t))
+
+ def setUpZope(self):
+ zcml = os.path.join(self.dir,
+ self.data['app']['zcml'])
+ features = tuple(self.data['app'].get('features', ()))
+ appsetup.config(zcml, features=features)
+
+ def setUpLogging(self):
+ path = self.data['app'].get('logging')
+ if self.withLogging and path:
+ cfg = os.path.join(self.dir, path)
+ fileConfig(cfg)
+
+ def setUpSiteConfigs(self):
+ self.sites = self.data.get('sites', {})
+
+class SiteConfig(object):
+
+ component.adapts(IConfigurableSite)
+ interface.implements(ISiteConfig)
+
+ def __init__(self, context):
+ self.context = context
+
+ @property
+ def config(self):
+ gConfig = component.getUtility(IConfig)
+ return gConfig.sites[self.context.__name__]
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/config.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/configure.zcml
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/configure.zcml (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/configure.zcml 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,28 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope">
+
+ <class class=".publication.App">
+ <allow
+ attributes="getSiteManager"
+ />
+ <require
+ permission="zope.ManageServices"
+ attributes="setSiteManager"
+ />
+ <require
+ permission="zope.View"
+ interface="zope.app.container.interfaces.IReadContainer"
+ />
+ <require
+ permission="zope.ManageContent"
+ interface="zope.app.container.interfaces.IWriteContainer"
+ />
+ </class>
+
+ <adapter factory=".config.SiteConfig"/>
+
+ <subscriber handler=".event.applyConfigurators"/>
+
+ <include package=".browser" />
+
+</configure>
Property changes on: lovely.zetup/trunk/src/lovely/zetup/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/event.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/event.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/event.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,14 @@
+from zope import component
+from zope import interface
+import interfaces
+from zope.app.container.interfaces import IObjectAddedEvent
+from z3c.configurator import configurator
+
+ at component.adapter(interfaces.IConfigurableSite,
+ IObjectAddedEvent)
+def applyConfigurators(obj, event):
+ cfg = interfaces.ISiteConfig(obj).config
+ configurators = cfg.get('configurators')
+ if configurators is not None:
+ configurator.configure(obj, configurators, names=configurators.keys(),
+ useNameSpaces=True)
Property changes on: lovely.zetup/trunk/src/lovely/zetup/event.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/factory.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/factory.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/factory.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,61 @@
+import os.path
+from config import Config
+from app import Application
+from zope import component
+
+_app = None
+_configPath = None
+
+def app_factory(gcfg, cfg=None, logging=True):
+
+ """initializer for past based setups
+
+ A config path is required.
+ >>> app_factory({})
+ Traceback (most recent call last):
+ ...
+ ValueError: Missing config path None
+
+ And it has to exist.
+ >>> testing = os.path.join(os.path.dirname(__file__), 'testing', 'xy')
+ >>> app_factory({'__file__':testing}, cfg='notthere.py')
+ Traceback (most recent call last):
+ ...
+ ValueError: Config file not found '.../notthere.py'
+ >>> app = app_factory({'__file__':testing}, cfg='testing.py')
+ 20...
+
+ Called twice the app is the same.
+ >>> app_factory({'__file__':testing}, cfg='testing.py') is app
+ True
+
+ We can only run one config at a time.
+ >>> app_factory({'__file__':testing}, cfg='paste.ini')
+ Traceback (most recent call last):
+ ...
+ RuntimeError: There is already another config running '.../testing.py'
+ """
+ if logging in ("0", "no", "false", "off"):
+ logging = False
+ if cfg is None:
+ raise ValueError, "Missing config path %r" % cfg
+ global _app, _configPath
+ cfgFile = os.path.join(os.path.dirname(gcfg['__file__']), cfg)
+ if _configPath is not None and _configPath != cfgFile:
+ raise RuntimeError, "There is already another config" \
+ +" running %r" % _configPath
+ if not os.path.isfile(cfgFile):
+ raise ValueError, "Config file not found %r" % cfgFile
+ _configPath = cfgFile
+ if _app is not None:
+ return _app
+ cfg = Config(cfgFile, withLogging=logging)
+ component.provideUtility(cfg)
+ _app = Application()
+ return _app
+
+def reset():
+ global _app, _configPath
+ _app = None
+ _configPath = None
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/factory.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/interfaces.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/interfaces.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/interfaces.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,46 @@
+##############################################################################
+#
+# Copyright (c) 2006-2008 Lovely Systems GmbH. All Rights Reserved.
+#
+# This software is subject to the provisions of the Lovely Visible Source
+# License, Version 1.0 (LVSL). A copy of the LVSL 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'
+
+from zope import interface
+
+
+class IConfig(interface.Interface):
+ pass
+
+
+class IConfigurableSite(interface.Interface):
+ """marker for configurable sites"""
+
+class ISiteConfig(interface.Interface):
+
+ config = interface.Attribute('Site configparser instance')
+
+
+class INoZODBStarted(interface.Interface):
+ """An event fired after the configuration is finished."""
+
+ root = interface.Attribute('The zetup root object')
+
+
+class NoZODBStarted(object):
+ interface.implements(INoZODBStarted)
+
+ def __init__(self, root):
+ self.root = root
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/publication.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/publication.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/publication.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,94 @@
+##############################################################################
+#
+# Copyright (c) 2006-2008 Lovely Systems GmbH. All Rights Reserved.
+#
+# This software is subject to the provisions of the Lovely Visible Source
+# License, Version 1.0 (LVSL). A copy of the LVSL 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 logging
+import time
+
+from zope import interface
+from zope import component
+from zope import event
+
+from zope.component.interfaces import IFactory
+from zope.security.checker import ProxyFactory
+from zope.publisher.browser import BrowserRequest
+from zope.error.interfaces import IErrorReportingUtility
+from zope.error.error import RootErrorReportingUtility
+from zope.lifecycleevent import ObjectCreatedEvent
+from zope.app.applicationcontrol.applicationcontrol \
+ import applicationControllerRoot
+
+from zope.app.component import hooks
+from zope.app.publication.browser import BrowserPublication
+from zope.app.publication.interfaces import (
+ IRequestPublicationFactory,
+ IBrowserRequestFactory,
+ )
+from zope.app.component.site import LocalSiteManager
+from zope.app.folder.interfaces import IRootFolder
+from zope.app.component.site import SiteManagerContainer
+from zope.app.container.contained import setitem
+
+from interfaces import IConfig, IConfigurableSite, NoZODBStarted
+
+
+class App(dict, SiteManagerContainer):
+ interface.implements(IRootFolder)
+
+ def __init__(self):
+ t = time.time()
+ sm = LocalSiteManager(self)
+ self.setSiteManager(sm)
+ hooks.setSite(self)
+ eru = RootErrorReportingUtility()
+ event.notify(ObjectCreatedEvent(eru))
+ sm['errors'] = eru
+ sm.registerUtility(eru, IErrorReportingUtility)
+ self.setUpSites()
+ logging.info('Set up root Application %s' % (time.time()-t))
+ event.notify(NoZODBStarted(self))
+
+ def setUpSites(self):
+ config = component.getUtility(IConfig)
+ for name, sc in config.sites.items():
+ factory = sc.get('factory')
+ factory = component.getUtility(IFactory, factory)
+ obj = factory()
+ if not IConfigurableSite.providedBy(obj):
+ interface.alsoProvides(obj, IConfigurableSite)
+ event.notify(ObjectCreatedEvent(obj))
+ setitem(self, self.__setitem__, name, obj)
+ logging.info('Set up site %r' % name)
+
+ def __repr__(self):
+ return "<%s>" % self.__class__.__name__
+
+
+class NoZODBPublication(BrowserPublication):
+
+ def __init__(self):
+ app = ProxyFactory(App())
+ event.notify(ObjectCreatedEvent(app))
+ self._app = app
+
+ def getApplication(self, request):
+ stack = request.getTraversalStack()
+ if '++etc++process' in stack:
+ return applicationControllerRoot
+ return self._app
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/publication.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/publication.txt
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/publication.txt (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/publication.txt 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,107 @@
+===================================
+Site creating none zodb publication
+===================================
+
+This publication does not require zodb and creates the root folder and
+sites by using ini files.
+
+ >>> from lovely.zetup import publication
+
+The publication requires an IConfig utility to be registered globally.
+
+ >>> from lovely.zetup import config
+ >>> from zope import component
+ >>> import os
+ >>> configFile = os.path.join(os.path.dirname(publication.__file__),
+ ... 'testing', 'testing.py')
+
+We disable the logging conf for the test. This also configures the
+ftesting.zcml file.
+
+ >>> cfg = config.Config(configFile, withLogging=False)
+
+And register the config.
+
+ >>> component.provideUtility(cfg)
+
+ >>> from zope.component.eventtesting import clearEvents, getEvents
+ >>> clearEvents()
+
+Now let us create the publication. This creates a global app instance
+and runs all configurators defined in the config file. Two
+configurators where added for testing, one with data.
+
+ >>> pub = publication.NoZODBPublication()
+ called: 'ConfTwo', on u'testsite' with data: ...
+ called: 'ConfOne', on u'testsite' with data: ...
+ called: 'ConfTwo', on u'secondsite' with data: ...
+ called: 'ConfOne', on u'secondsite' with data: ...
+
+There is an event fired after a new application has been fully created.
+
+ >>> from lovely.zetup.interfaces import INoZODBStarted
+ >>> events = getEvents(INoZODBStarted)
+ >>> events
+ [<lovely.zetup.interfaces.NoZODBStarted object at ...>]
+ >>> [e.root for e in events]
+ [<App>]
+
+Let us get the app. We need a request for this.
+
+ >>> from zope.publisher.browser import TestRequest
+ >>> request = TestRequest()
+
+The application is actualy a subclass of dict that holds the sites
+defined by the config. In order to get some subobjects of the site we
+need to have at least an interaction.
+
+ >>> from zope.security.management import newInteraction, endInteraction
+ >>> newInteraction()
+ >>> app = pub.getApplication(request)
+ >>> sorted(app.items())
+ [(u'secondsite', <zope.app.folder.folder.Folder object at ...>),
+ (u'testsite', <zope.app.folder.folder.Folder object at ...>)]
+
+
+The app is security proxied
+
+ >>> type(app)
+ <type 'zope.security._proxy._Proxy'>
+
+The application is a singleton
+
+ >>> app is pub.getApplication(request)
+ True
+
+Let us get the test site and the site config for it.
+
+ >>> from lovely.zetup.interfaces import ISiteConfig
+ >>> site = app['testsite']
+ >>> siteConfig = ISiteConfig(site)
+
+Now we can get the site configuration dictionarry.
+
+ >>> c = siteConfig.config
+ >>> from pprint import pprint
+ >>> pprint(c)
+ {'configurators': {'testconfigurator.one': {'alist': ['server1:11211',
+ 'server2:11211'],
+ 'someunicode': u'noreply at example.com'},
+ 'testconfigurator.two': {'afloat': 1.0,
+ 'astring': 'Value of Name'}},
+ 'factory': 'zope.app.content.Folder',
+ 'settings': {'testing.option1': 1}}
+
+Let us get some settings.
+
+ >>> c.get('settings')['testing.option1']
+ 1
+
+Also the factory that was used to create the testsite is in this
+config. This is actually the only option that is required for a site
+config.
+
+ >>> c.get('factory')
+ 'zope.app.content.Folder'
+
+ >>> endInteraction()
Property changes on: lovely.zetup/trunk/src/lovely/zetup/publication.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/testing/__init__.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/testing/__init__.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/testing/__init__.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,54 @@
+from paste.deploy import loadapp
+from paste.fixture import TestApp
+import sys
+import os
+import lovely.zetup.factory
+from lovely.zetup.factory import reset
+from zope.app.testing import setup
+from zope.security.proxy import removeSecurityProxy
+import wsgi_intercept.zope_testbrowser
+
+_pasteApp = None
+
+def getTestApp(**kwargs):
+ return TestApp(getPasteApplication(), **kwargs)
+
+def getPasteApplication():
+ return _pasteApp
+
+def getRootFolder(proxied=True):
+ f = lovely.zetup.factory._app.requestFactory._publication._app
+ if not proxied:
+ return removeSecurityProxy(f)
+ return f
+
+def setUpInterceptServer(domain='nohost', port=80):
+ wsgi_intercept.add_wsgi_intercept(domain, port, getPasteApplication)
+
+class Browser(wsgi_intercept.zope_testbrowser.WSGI_Browser):
+
+ def __init__(self, *args, **kwargs):
+ super(Browser, self).__init__(*args, **kwargs)
+ self.mech_browser.set_handle_robots(False)
+
+class PasteAppLayer(object):
+
+ """sets up a layer with an app"""
+
+ __bases__ = ()
+ __name__ = 'PasteAppLayer'
+
+ def __init__(self, cfg):
+ globs = sys._getframe(1).f_globals
+ self.cfg = cfg
+ self.there = os.path.dirname(globs['__file__'])
+
+ def setUp(self):
+ global _pasteApp
+ _pasteApp = loadapp(self.cfg, relative_to=self.there)
+
+ def tearDown(self):
+ setup.placefulTearDown()
+ reset()
+ global _pasteApp
+ _pasteApp = None
Property changes on: lovely.zetup/trunk/src/lovely/zetup/testing/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/testing/ftesting.zcml
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/testing/ftesting.zcml (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/testing/ftesting.zcml 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,77 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ xmlns:meta="http://namespaces.zope.org/meta"
+ xmlns:xmlrpc="http://namespaces.zope.org/xmlrpc"
+ i18n_domain="zope">
+
+ <include package="lovely.zetup.zcmlfiles" />
+
+ <include package="zope.securitypolicy" file="meta.zcml"/>
+ <include package="zope.securitypolicy"/>
+ <securityPolicy
+ component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
+ <role id="zope.Manager" title="Site Manager" />
+ <include package="zope.app.authentication"/>
+
+ <role id="zope.Anonymous" title="Everybody"
+ description="All users have this role implicitly" />
+
+ <role id="zope.Member" title="Site Member" />
+
+ <adapter factory="lovely.zetup.tests.ConfOne"
+ for="*"
+ name="testconfigurator.one"/>
+
+ <adapter factory="lovely.zetup.tests.ConfTwo"
+ for="*"
+ name="testconfigurator.two"/>
+
+ <unauthenticatedPrincipal
+ id="zope.Anonymous"
+ title="Unauthenticated User" />
+
+ <unauthenticatedGroup
+ id="zope.Anybody"
+ title="Unauthenticated Users"
+ />
+
+ <authenticatedGroup
+ id="zope.Authenticated"
+ title="Authenticated Users"
+ />
+
+ <everybodyGroup
+ id="zope.Everybody"
+ title="All Users"
+ />
+
+
+ <principal
+ id="zope.manager"
+ title="Manager"
+ login="mgr"
+ password="pw"
+ />
+
+ <grant permission="zope.View"
+ role="zope.Anonymous" />
+
+ <grant permission="zope.app.dublincore.view"
+ role="zope.Anonymous" />
+
+ <grant
+ role="zope.Manager"
+ principal="zope.manager"
+ />
+
+ <xmlrpc:view
+ for="zope.app.folder.folder.IFolder"
+ methods="contents"
+ class="lovely.zetup.testing.xmlrpc.FolderListing"
+ permission="zope.Public"
+ />
+
+ <grantAll role="zope.Manager"/>
+
+</configure>
Property changes on: lovely.zetup/trunk/src/lovely/zetup/testing/ftesting.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/testing/layer.txt
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/testing/layer.txt (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/testing/layer.txt 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,52 @@
+===========
+Paste Layer
+===========
+
+This layer creates a paste application using lovely.zetup. This test
+actually runs on this layer so we can get the appplication.
+
+ >>> from lovely.zetup import testing
+
+This is a single app application so the paste application object is
+actually the same as the zope application.
+
+ >>> testing.getPasteApplication()
+ <lovely.zetup.app.Application object at ...>
+
+We can get the root folder.
+
+ >>> rf = testing.getRootFolder()
+ >>> rf
+ <App>
+
+By defautl the root folder is security proxied.
+
+ >>> type(rf)
+ <type 'zope.security._proxy._Proxy'>
+
+We can remove the proxy.
+
+ >>> rf = testing.getRootFolder(proxied=False)
+ >>> type(rf)
+ <class 'lovely.zetup.publication.App'>
+
+Now we can access attributes.
+
+ >>> sorted(rf.keys())
+ [u'secondsite', u'testsite']
+
+There is also a convinience function to get a paste TestApp object.
+
+ >>> ta = testing.getTestApp()
+ >>> ta
+ <paste.fixture.TestApp object at ...>
+ >>> ta.get('/secondsite/@@absolute_url').body
+ 'http://localhost/secondsite'
+
+We can also start a wsgi interception and get a test browser.
+
+ >>> testing.setUpInterceptServer()
+ >>> browser = testing.Browser()
+ >>> browser.open('http://nohost/@@absolute_url')
+ >>> browser.url
+ 'http://nohost/@@absolute_url'
Property changes on: lovely.zetup/trunk/src/lovely/zetup/testing/layer.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/testing/logging.cfg
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/testing/logging.cfg (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/testing/logging.cfg 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,28 @@
+[loggers]
+keys=root,SiteError
+
+[handlers]
+keys=consoleHandler
+
+[formatters]
+keys=simpleFormatter
+
+[logger_root]
+level=DEBUG
+handlers=consoleHandler
+
+[logger_SiteError]
+level=DEBUG
+handlers=consoleHandler
+qualname=SiteError
+
+[handler_consoleHandler]
+class=StreamHandler
+level=INFO
+formatter=simpleFormatter
+args=(sys.stdout,)
+
+[formatter_simpleFormatter]
+format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
+datefmt=
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/testing/logging.cfg
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/testing/paste.ini
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/testing/paste.ini (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/testing/paste.ini 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,4 @@
+[app:main]
+use = egg:lovely.zetup
+cfg = testing.py
+logging = off
Added: lovely.zetup/trunk/src/lovely/zetup/testing/testing.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/testing/testing.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/testing/testing.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,24 @@
+
+app = {
+ 'logging': 'logging.cfg',
+ 'zcml': 'ftesting.zcml',
+ 'features':['devmode'],
+ }
+
+testsite = {
+ 'factory': 'zope.app.content.Folder',
+ 'settings':{'testing.option1': 1},
+ 'configurators':
+ {'testconfigurator.one':
+ {'someunicode':u'noreply at example.com',
+ 'alist':['server1:11211', 'server2:11211']},
+ 'testconfigurator.two':
+ {'astring':'Value of Name',
+ 'afloat':1.0}
+ },
+ }
+
+sites = {
+ u'testsite':testsite,
+ u'secondsite':testsite,
+ }
Property changes on: lovely.zetup/trunk/src/lovely/zetup/testing/testing.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/testing/tests.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/testing/tests.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/testing/tests.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,31 @@
+##############################################################################
+#
+# Copyright (c) 2006-2008 Lovely Systems GmbH. All Rights Reserved.
+#
+# This software is subject to the provisions of the Lovely Visible Source
+# License, Version 1.0 (LVSL). A copy of the LVSL 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 doctest, unittest
+from lovely.zetup.testing import PasteAppLayer
+from zope.testing.doctest import DocFileSuite
+
+testPasteAppLayer = PasteAppLayer('config:paste.ini')
+
+def test_suite():
+ layer = DocFileSuite('layer.txt',
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ )
+ layer.layer = testPasteAppLayer
+ return unittest.TestSuite((layer,))
Property changes on: lovely.zetup/trunk/src/lovely/zetup/testing/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/testing/xmlrpc.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/testing/xmlrpc.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/testing/xmlrpc.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,4 @@
+
+class FolderListing:
+ def contents(self):
+ return list(self.context.keys())
Property changes on: lovely.zetup/trunk/src/lovely/zetup/testing/xmlrpc.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/tests.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/tests.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/tests.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,69 @@
+##############################################################################
+#
+# Copyright (c) 2006-2008 Lovely Systems GmbH. All Rights Reserved.
+#
+# This software is subject to the provisions of the Lovely Visible Source
+# License, Version 1.0 (LVSL). A copy of the LVSL 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 doctest, unittest
+
+from zope import component
+from zope.component import eventtesting
+from zope.app.testing import setup
+from zope.testing.doctest import DocFileSuite, DocTestSuite
+
+from z3c.configurator.configurator import SchemaConfigurationPluginBase
+from zope.app.component.testing import PlacefulSetup
+from factory import reset
+from zope.testing.cleanup import addCleanUp
+
+class ConfOne(SchemaConfigurationPluginBase):
+
+ def __call__(self, data):
+ print "called: %r, on %r with data: %r" % (
+ self.__class__.__name__, self.context.__name__, data)
+
+class ConfTwo(ConfOne):
+ pass
+
+def setUp(test):
+ addCleanUp(reset)
+ component.provideHandler(eventtesting.events.append, (None,))
+
+def tearDown(test):
+ setup.placefulTearDown()
+
+def test_suite():
+ uSuites = (
+ DocFileSuite('README.txt', setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ DocTestSuite('lovely.zetup.factory',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ DocTestSuite('lovely.zetup.config',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ DocTestSuite('lovely.zetup.browser.views',
+ setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ DocFileSuite('publication.txt', setUp=setUp, tearDown=tearDown,
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
+ )
+ return unittest.TestSuite(uSuites)
Property changes on: lovely.zetup/trunk/src/lovely/zetup/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/__init__.py
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/__init__.py (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/__init__.py 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1 @@
+#
Property changes on: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/browser.zcml
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/browser.zcml (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/browser.zcml 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,17 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
+
+ <browser:defaultView name="index.html" />
+ <browser:defaultSkin name="Rotterdam" />
+
+ <include package="zope.app.exception.browser" />
+ <include package="zope.traversing.browser" />
+ <include package="zope.app.security.browser" />
+
+ <include package="zope.app.container.browser" />
+ <include package="zope.app.form.browser" />
+
+ <include package="zope.app.component.browser" />
+
+</configure>
Property changes on: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/browser.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/configure.zcml
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/configure.zcml (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/configure.zcml 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,84 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ i18n_domain="zope"
+ >
+
+ <!-- Meta configuration (new directives) -->
+ <include file="meta.zcml" />
+
+ <!-- Note that we need to do this early, as later startup
+ subscribers may break without fixups -->
+
+ <include package="zope.app.component" />
+
+ <!-- Ordinary Application (non-view) configuration) -->
+
+ <include package="zope.app.interface" />
+ <include package="zope.app.security" />
+ <include package="zope.component" />
+ <include package="zope.annotation" />
+ <include package="zope.app.dependable" />
+ <include package="zope.app.content" />
+ <include package="zope.publisher" />
+
+ <include package="zope.app.zcmlfiles" file="menus.zcml" />
+
+ <!--
+ <include package="zope.copypastemove" />
+ -->
+ <include package="zope.size" />
+ <include package="zope.location" />
+ <include package="zope.app.container" />
+
+ <include package="zope.app.publisher" />
+
+ <include package="zope.app.publication" file="meta.zcml" />
+ <include package="zope.app.publication" />
+
+
+ <include package="zope.traversing" />
+ <include package="zope.app.pagetemplate" />
+ <include package="zope.app.generations" />
+ <include package="zope.app.zapi" />
+
+ <!-- Views -->
+ <include package="zope.app.http" />
+
+ <!-- Translations -->
+ <configure package="zope.app.locales">
+ <i18n:registerTranslations directory="." />
+ </configure>
+
+ <include package="zope.app.i18n" />
+
+ <!-- Database boostrapping and maintanance -->
+ <include package="zope.app.appsetup" />
+
+ <!-- Utilities -->
+ <include package="zope.app.error" />
+
+ <!-- Broken-object support -->
+ <include package="zope.app.broken" />
+
+ <!-- Skins -->
+ <include package="zope.app.basicskin" />
+
+ <include package="zope.app.rotterdam" />
+
+ <!-- Additional packages -->
+
+ <include package="zope.app.applicationcontrol" />
+ <include package="zope.dublincore" />
+ <include package="zope.app.wsgi" />
+
+ <!-- Content types -->
+ <include file="folder.zcml" />
+
+ <!-- Browser Configurations -->
+ <include file="browser.zcml" />
+
+ <!-- include this package -->
+ <include package="lovely.zetup"/>
+
+</configure>
Property changes on: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/configure.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/folder.zcml
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/folder.zcml (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/folder.zcml 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,63 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ package="zope.app.folder"
+ i18n_domain="zope"
+ >
+
+ <interface
+ interface=".interfaces.IFolder"
+ type="zope.app.content.interfaces.IContentType"
+ />
+
+ <class class=".folder.Folder">
+ <factory
+ id="zope.app.content.Folder"
+ title="Folder"
+ description="Minimal folder"
+ />
+ <allow
+ attributes="getSiteManager"
+ />
+ <require
+ permission="zope.ManageServices"
+ attributes="setSiteManager"
+ />
+ <require
+ permission="zope.View"
+ interface="zope.app.container.interfaces.IReadContainer"
+ />
+ <require
+ permission="zope.ManageContent"
+ interface="zope.app.container.interfaces.IWriteContainer"
+ />
+ </class>
+
+ <adapter
+ for=".interfaces.IFolder"
+ provides="zope.filerepresentation.interfaces.IDirectoryFactory"
+ factory="zope.app.container.directory.Cloner"
+ permission="zope.ManageContent"
+ />
+
+ <adapter
+ for=".interfaces.IFolder"
+ provides="zope.filerepresentation.interfaces.IReadDirectory"
+ factory=".filerepresentation.ReadDirectory"
+ permission="zope.View"
+ />
+
+ <adapter
+ provides="zope.location.interfaces.ISublocations"
+ for=".interfaces.IFolder"
+ factory=".folder.FolderSublocations"
+ />
+
+ <browser:icon
+ name="zmi_icon"
+ for=".interfaces.IFolder"
+ file="browser/folder_icon.gif"
+ />
+
+</configure>
+
Property changes on: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/folder.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/meta.zcml
===================================================================
--- lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/meta.zcml (rev 0)
+++ lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/meta.zcml 2008-05-27 14:33:05 UTC (rev 86981)
@@ -0,0 +1,19 @@
+<configure xmlns="http://namespaces.zope.org/zope">
+
+<!-- Standard configuration directives -->
+
+<!-- BBB deprecated as of 2006/02/24. To be removed after 12 months. -->
+<!--
+<include package="zope.modulealias" file="meta.zcml" />
+-->
+<include package="zope.app.component" file="meta.zcml" />
+<include package="zope.app.component.browser" file="meta.zcml" />
+<include package="zope.app.publisher" file="meta.zcml" />
+<include package="zope.app.security" file="meta.zcml" />
+<include package="zope.app.form.browser" file="meta.zcml" />
+<include package="zope.i18n" file="meta.zcml" />
+<include package="zope.app.pagetemplate" file="meta.zcml" />
+<include package="zope.app.schema" file="meta.zcml" />
+<include package="zope.app.container.browser" file="meta.zcml" />
+
+</configure>
Property changes on: lovely.zetup/trunk/src/lovely/zetup/zcmlfiles/meta.zcml
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the Checkins
mailing list