[Checkins] SVN: zc.publication/branches/dev/ Proof of concept.
Jim Fulton
jim at zope.com
Fri Jun 12 06:59:06 EDT 2009
Log message for revision 100895:
Proof of concept.
Changed:
U zc.publication/branches/dev/buildout.cfg
A zc.publication/branches/dev/examples/
A zc.publication/branches/dev/examples/hello/
A zc.publication/branches/dev/examples/hello/hello.ini
A zc.publication/branches/dev/examples/hello/hello.py
A zc.publication/branches/dev/examples/hello/hello.zcml
A zc.publication/branches/dev/examples/hello/setup.py
U zc.publication/branches/dev/setup.py
A zc.publication/branches/dev/src/zc/publication/
A zc.publication/branches/dev/src/zc/publication/README.txt
A zc.publication/branches/dev/src/zc/publication/__init__.py
A zc.publication/branches/dev/src/zc/publication/configure.zcml
A zc.publication/branches/dev/src/zc/publication/error.py
A zc.publication/branches/dev/src/zc/publication/noauth.py
-=-
Modified: zc.publication/branches/dev/buildout.cfg
===================================================================
--- zc.publication/branches/dev/buildout.cfg 2009-06-12 10:43:40 UTC (rev 100894)
+++ zc.publication/branches/dev/buildout.cfg 2009-06-12 10:59:06 UTC (rev 100895)
@@ -1,12 +1,24 @@
[buildout]
-develop = .
-parts = test py
+develop = . examples/hello
+parts = test py hello
[test]
recipe = zc.recipe.testrunner
-eggs =
+eggs = zc.publication
[py]
recipe = zc.recipe.egg
eggs = ${test:eggs}
interpreter = py
+
+[hello]
+recipe = zc.recipe.egg
+eggs = ${test:eggs}
+ PasteScript
+ hello-example
+initialization = import os
+scripts = paster=hello
+arguments = [
+ 'serve',
+ os.path.join('${buildout:directory}', 'examples', 'hello', 'hello.ini'),
+ ]
Added: zc.publication/branches/dev/examples/hello/hello.ini
===================================================================
--- zc.publication/branches/dev/examples/hello/hello.ini (rev 0)
+++ zc.publication/branches/dev/examples/hello/hello.ini 2009-06-12 10:59:06 UTC (rev 100895)
@@ -0,0 +1,10 @@
+
+[app:main]
+use = egg:zope.publisher
+publication = egg:zc.publication
+root = hello:Hello
+zcml = hello.zcml
+
+[server:main]
+use = egg:Paste#http
+port = 8080
Property changes on: zc.publication/branches/dev/examples/hello/hello.ini
___________________________________________________________________
Added: svn:eol-style
+ native
Added: zc.publication/branches/dev/examples/hello/hello.py
===================================================================
--- zc.publication/branches/dev/examples/hello/hello.py (rev 0)
+++ zc.publication/branches/dev/examples/hello/hello.py 2009-06-12 10:59:06 UTC (rev 100895)
@@ -0,0 +1,13 @@
+
+import zope.publisher.browser
+
+class Hello(zope.publisher.browser.BrowserPage):
+
+ def __init__(self, request):
+ self.request = request
+
+ def __call__(self):
+ return """<html><body>
+ Hello world
+ </body></html>
+ """
Property changes on: zc.publication/branches/dev/examples/hello/hello.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: zc.publication/branches/dev/examples/hello/hello.zcml
===================================================================
--- zc.publication/branches/dev/examples/hello/hello.zcml (rev 0)
+++ zc.publication/branches/dev/examples/hello/hello.zcml 2009-06-12 10:59:06 UTC (rev 100895)
@@ -0,0 +1,10 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ >
+ <include package="zc.publication" />
+
+
+ <class class="hello.Hello">
+ <allow attributes="__call__" />
+ </class>
+</configure>
Property changes on: zc.publication/branches/dev/examples/hello/hello.zcml
___________________________________________________________________
Added: svn:eol-style
+ native
Added: zc.publication/branches/dev/examples/hello/setup.py
===================================================================
--- zc.publication/branches/dev/examples/hello/setup.py (rev 0)
+++ zc.publication/branches/dev/examples/hello/setup.py 2009-06-12 10:59:06 UTC (rev 100895)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 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.
+#
+##############################################################################
+from setuptools import setup
+
+setup(name='hello-example')
Property changes on: zc.publication/branches/dev/examples/hello/setup.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: zc.publication/branches/dev/setup.py
===================================================================
--- zc.publication/branches/dev/setup.py 2009-06-12 10:43:40 UTC (rev 100894)
+++ zc.publication/branches/dev/setup.py 2009-06-12 10:59:06 UTC (rev 100895)
@@ -11,12 +11,23 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-name, version = 'zc.', '0'
+name, version = 'zc.publication', '0'
-install_requires = ['setuptools']
+install_requires = [
+ 'setuptools',
+ 'zope.authentication',
+ 'zope.principalregistry',
+ 'zope.publisher',
+ 'zope.app.component',
+ 'zope.app.publication',
+ 'zope.error',
+ 'ZConfig',
+ ]
extras_require = dict(test=['zope.testing'])
entry_points = """
+[zope.publisher.publication_factory]
+default = zc.publication:Publication
"""
from setuptools import setup
Added: zc.publication/branches/dev/src/zc/publication/README.txt
===================================================================
--- zc.publication/branches/dev/src/zc/publication/README.txt (rev 0)
+++ zc.publication/branches/dev/src/zc/publication/README.txt 2009-06-12 10:59:06 UTC (rev 100895)
@@ -0,0 +1,56 @@
+Introduction
+============
+
+zc.publication.publcation is a publication object that extends
+``zope.app.publication.browser.BrowserPublication`` with the ability
+to provide an alternative root object, rather than one read from a
+ZODB database.
+
+Let's look at an example::
+
+
+ import zope.publisher.browser
+
+ class Hello(zope.publisher.browser.BrowserPage):
+
+ def __init__(self, request):
+ self.request = request
+
+ def __call__(self):
+ return """<html><body>
+ Hello world
+ </body></html>
+ """
+
+We'll put the code above in a module, ``hello``.
+
+We also create a paste configuration file::
+
+ [app:main]
+ use = egg:zope.publisher
+ publication = egg:zc.publication
+ root = hello:Hello
+ zcml = hello.zcml
+
+Here, we:
+
+- Use the ``zope.publisher`` WSGI application designed to work with paste.
+
+- Use the ``zc.publication`` publication plugin for zope.publisher
+
+- We specify a callable that takes a request and returns an object. In
+ this case, we specify the Hello class.
+
+- We specify the name of a ZCML file to be read to establish
+ application configuration settings.
+
+With these settings, we can access the URL::
+
+ http://localhost/
+
+and get the response::
+
+ <html><body>
+ Hello world
+ </body></html>
+
Property changes on: zc.publication/branches/dev/src/zc/publication/README.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Added: zc.publication/branches/dev/src/zc/publication/__init__.py
===================================================================
--- zc.publication/branches/dev/src/zc/publication/__init__.py (rev 0)
+++ zc.publication/branches/dev/src/zc/publication/__init__.py 2009-06-12 10:59:06 UTC (rev 100895)
@@ -0,0 +1,53 @@
+##############################################################################
+#
+# Copyright Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import os
+import zope.app.publication.browser
+import zope.publisher.paste
+
+class Publication(zope.app.publication.browser.BrowserPublication):
+
+ def __init__(self, DEFAULT=None, **options):
+ if DEFAULT:
+ DEFAULT = DEFAULT.copy()
+ DEFAULT.update(options)
+ options = DEFAULT
+
+ super(Publication, self).__init__(None)
+
+ root = options['root']
+ if root.startswith('egg:'):
+ root = zope.publisher.paste.get_egg(root[4:], 'zc.publication.root')
+ base = os.getcwd() # XXX
+ else:
+ module_name, expr = root.split(':')
+ module = __import__(module_name, {}, {}, ['*'])
+ root = eval(expr, options, module.__dict__)
+ base = os.path.dirname(module.__file__)
+
+ self.getApplication = root
+
+ zcml = options.get('zcml')
+ if zcml is not None:
+ zcml = os.path.join(base, zcml)
+ import zope.configuration.xmlconfig
+ zope.configuration.xmlconfig.xmlconfig(open(zcml))
+
+ logconfig = options.get('logging')
+ if logconfig:
+ import ZConfig
+ ZConfig.configureLoggers(logconfig)
+ else:
+ import logging
+ logging.basicConfig()
Property changes on: zc.publication/branches/dev/src/zc/publication/__init__.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: zc.publication/branches/dev/src/zc/publication/configure.zcml
===================================================================
--- zc.publication/branches/dev/src/zc/publication/configure.zcml (rev 0)
+++ zc.publication/branches/dev/src/zc/publication/configure.zcml 2009-06-12 10:59:06 UTC (rev 100895)
@@ -0,0 +1,22 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ >
+ <include package="zope.component" file="meta.zcml" />
+ <include package="zope.app.component" file="meta.zcml" />
+ <include package="zope.app.publisher" file="meta.zcml" />
+ <include package="zope.app.publication" file="meta.zcml" />
+ <include package="zope.security" file="meta.zcml" />
+ <include package="zope.publisher" />
+ <include package="zope.app.publication" />
+
+ <utility
+ provides="zope.error.interfaces.IErrorReportingUtility"
+ component=".error"
+ />
+ <utility
+ provides="zope.authentication.interfaces.IAuthentication"
+ component=".noauth"
+ />
+ <browser:defaultView name="index.html" />
+</configure>
Property changes on: zc.publication/branches/dev/src/zc/publication/configure.zcml
___________________________________________________________________
Added: svn:eol-style
+ native
Added: zc.publication/branches/dev/src/zc/publication/error.py
===================================================================
--- zc.publication/branches/dev/src/zc/publication/error.py (rev 0)
+++ zc.publication/branches/dev/src/zc/publication/error.py 2009-06-12 10:59:06 UTC (rev 100895)
@@ -0,0 +1,19 @@
+##############################################################################
+#
+# Copyright Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+import logging
+
+logger = logging.getLogger('SiteError')
+
+def raising(info, request=None):
+ logger.error("Error for request\n%s", exc_info=info)
Property changes on: zc.publication/branches/dev/src/zc/publication/error.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: zc.publication/branches/dev/src/zc/publication/noauth.py
===================================================================
--- zc.publication/branches/dev/src/zc/publication/noauth.py (rev 0)
+++ zc.publication/branches/dev/src/zc/publication/noauth.py 2009-06-12 10:59:06 UTC (rev 100895)
@@ -0,0 +1,36 @@
+##############################################################################
+#
+# Copyright 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.
+#
+##############################################################################
+"""Never authenticate.
+
+This is a suitable plugin for apps that don't support login.
+"""
+
+import zope.authentication.interfaces
+import zope.principalregistry.principalregistry
+
+def authenticate(request):
+ pass
+
+
+def unauthenticatedPrincipal():
+ return zope.principalregistry.principalregistry.UnauthenticatedPrincipal(
+ '', 'Unauthenticated', 'No one can authenticate')
+
+def unauthorized(id, request):
+ pass
+
+def getPrincipal(id):
+ if id == '':
+ return unauthenticatedPrincipal()
+ raise zope.authentication.interfaces.PrincipalLookupError(id)
Property changes on: zc.publication/branches/dev/src/zc/publication/noauth.py
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
More information about the Checkins
mailing list