[Checkins] SVN: grokapps/gbedemosite/ Initial import
Michael Haubenwallner
michael at d2m.at
Wed Oct 8 10:07:40 EDT 2008
Log message for revision 91906:
Initial import
Changed:
A grokapps/gbedemosite/
A grokapps/gbedemosite/README.txt
A grokapps/gbedemosite/bootstrap.py
A grokapps/gbedemosite/buildout.cfg
A grokapps/gbedemosite/setup.py
A grokapps/gbedemosite/src/
A grokapps/gbedemosite/src/gbedemosite/
A grokapps/gbedemosite/src/gbedemosite/__init__.py
A grokapps/gbedemosite/src/gbedemosite/app.py
A grokapps/gbedemosite/src/gbedemosite/app.txt
A grokapps/gbedemosite/src/gbedemosite/app_templates/
A grokapps/gbedemosite/src/gbedemosite/app_templates/index.pt
A grokapps/gbedemosite/src/gbedemosite/app_templates/robots.pt
A grokapps/gbedemosite/src/gbedemosite/configure.zcml
A grokapps/gbedemosite/src/gbedemosite/ftesting.zcml
A grokapps/gbedemosite/src/gbedemosite/tests.py
-=-
Added: grokapps/gbedemosite/README.txt
===================================================================
--- grokapps/gbedemosite/README.txt (rev 0)
+++ grokapps/gbedemosite/README.txt 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,79 @@
+Grok-by-Example: Demosite
+=========================
+
+:Author: d2m (michael at d2m.at)
+
+
+Overview
+========
+
+This demosite shows how to install multiple Grok applications and make
+them available from a single Grok instance.
+
+
+Usage
+-----
+
+This example is a complete Grok app on its own. Here is how to use it::
+
+ # checkout the example to your harddisk
+ svn co svn://svn.zope.org/repos/main/grokapps/gbedemosite
+
+ # change to the newly created directory
+ cd gbedemosite
+
+ # make it a virtualenv
+ virtualenv --no-site-packages .
+
+ # activate the virtualenv
+ source bin/activate
+
+ # checkout a working copy of the different GBE apps
+ svn co svn://svn.zope.org/repos/main/grokapps/gbeguestbook
+ svn co svn://svn.zope.org/repos/main/grokapps/gbe99bottles
+ svn co svn://svn.zope.org/repos/main/grokapps/gbewiki
+ svn co svn://svn.zope.org/repos/main/grokapps/gbepastebin
+
+ # bootstrap the buildout environment
+ bin/python bootstrap.py
+
+ # run the buildout
+ bin/buildout
+
+ # test the example app
+ bin/test
+
+ # start the ZEO server
+ bin/server start
+
+ # run the first ZEO client
+ bin/zopectl fg
+
+ # point your browser to
+ http://localhost:8080
+
+ # login
+ username: grok
+ password: grok
+
+ # create an instance of the 'Demosite' application
+ # (this installs all other GBE apps at once)
+ # and use it
+
+ # run the second ZEO client to debug the application
+ bin/instance2 debug
+ >>> root = app.root()
+ >>> list(root.keys())
+ ...
+ # commit your changes back to the ZODB
+ >>> import transaction
+ >>> transaction.commit()
+
+
+That's it!
+
+Need help? There is the Grok Users mailinglist at grok-dev at zope.org
+(http://mail.zope.org/mailman/listinfo/grok-dev),
+the Grok IRC channel at irc.freenode.net/#grok
+and the Grok website at http://grok.zope.org
+
Added: grokapps/gbedemosite/bootstrap.py
===================================================================
--- grokapps/gbedemosite/bootstrap.py (rev 0)
+++ grokapps/gbedemosite/bootstrap.py 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,66 @@
+##############################################################################
+#
+# 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 85041 2008-03-31 15:57:30Z andreasjung $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+try:
+ import pkg_resources
+except ImportError:
+ 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
+
+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
+assert os.spawnle(
+ os.P_WAIT, sys.executable, quote (sys.executable),
+ '-c', quote (cmd), '-mqNxd', quote (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)
+
+# grokproject specific addition to standard bootstrap.py:
+# Install eggbasket too.
+zc.buildout.buildout.main(sys.argv[1:] + ['install', 'eggbasket'])
Added: grokapps/gbedemosite/buildout.cfg
===================================================================
--- grokapps/gbedemosite/buildout.cfg (rev 0)
+++ grokapps/gbedemosite/buildout.cfg 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,112 @@
+[buildout]
+develop = . gbewiki gbeguestbook gbe99bottles gbepastebin
+parts = eggbasket app data zopectl i18n test zodb server instance2
+newest = false
+extends = http://grok.zope.org/releaseinfo/grok-0.14.cfg
+# eggs will be installed in the default buildout location
+# (see .buildout/default.cfg in your home directory)
+# unless you specify an eggs-directory option here.
+
+versions = versions
+
+[app]
+recipe = zc.zope3recipes>=0.5.3:application
+eggs = gbedemosite
+site.zcml = <include package="gbedemosite" />
+ <include package="zope.app.twisted" />
+
+ <configure i18n_domain="gbedemosite">
+ <unauthenticatedPrincipal id="zope.anybody"
+ title="Unauthenticated User" />
+ <unauthenticatedGroup id="zope.Anybody"
+ title="Unauthenticated Users" />
+ <authenticatedGroup id="zope.Authenticated"
+ title="Authenticated Users" />
+ <everybodyGroup id="zope.Everybody"
+ title="All Users" />
+ <principal id="zope.manager"
+ title="Manager"
+ login="grok"
+ password_manager="Plain Text"
+ password="grok"
+ />
+
+ <!-- Replace the following directive if you do not want
+ public access -->
+ <grant permission="zope.View"
+ principal="zope.Anybody" />
+ <grant permission="zope.app.dublincore.view"
+ principal="zope.Anybody" />
+
+ <role id="zope.Manager" title="Site Manager" />
+ <role id="zope.Member" title="Site Member" />
+ <grantAll role="zope.Manager" />
+ <grant role="zope.Manager"
+ principal="zope.manager" />
+ </configure>
+
+[data]
+recipe = zc.recipe.filestorage
+
+[zodb]
+recipe = zc.recipe.egg:script
+eggs = ZODB3
+
+[server]
+recipe = zc.zodbrecipes:server
+zeo.conf =
+ <zeo>
+ address 8100
+ </zeo>
+ <filestorage 1>
+ path ${buildout:parts-directory}/data/ZEOData.fs
+ </filestorage>
+
+# this section named so that the start/stop script is called bin/zopectl
+[zopectl]
+recipe = zc.zope3recipes:instance
+application = app
+zope.conf = devmode on
+ <zodb>
+ <zeoclient>
+ server 8100
+ </zeoclient>
+ </zodb>
+ site-definition ${buildout:parts-directory}/app/site.zcml
+
+ <accesslog>
+ <logfile>
+ path ${buildout:parts-directory}/zopectl/access.log
+ </logfile>
+ </accesslog>
+
+ <eventlog>
+ <logfile>
+ formatter zope.exceptions.log.Formatter
+ path STDOUT
+ </logfile>
+ </eventlog>
+address = 8080
+
+[instance2]
+recipe = zc.zope3recipes:instance
+extends = zopectl
+address = 9080
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = gbedemosite
+defaults = ['--tests-pattern', '^f?tests$', '-v']
+
+# this section named so that the i18n scripts are called bin/i18n...
+[i18n]
+recipe = lovely.recipe:i18n
+package = gbedemosite
+domain = gbedemosite
+location = src/gbedemosite
+output = locales
+
+[eggbasket]
+recipe = z3c.recipe.eggbasket
+eggs = grok
+url = http://grok.zope.org/releaseinfo/grok-eggs-0.14.tgz
Added: grokapps/gbedemosite/setup.py
===================================================================
--- grokapps/gbedemosite/setup.py (rev 0)
+++ grokapps/gbedemosite/setup.py 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,34 @@
+from setuptools import setup, find_packages
+
+version = '0.1'
+
+setup(name='gbedemosite',
+ version=version,
+ description="Grok-by-Example",
+ long_description="""\
+ create a multi-application demosite
+""",
+ # Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers
+ classifiers=[],
+ keywords="grok example",
+ author="d2m",
+ author_email="michael at d2m.at",
+ url="http://blog.d2m.at",
+ license="ZPL2",
+ package_dir={'': 'src'},
+ packages=find_packages('src'),
+ include_package_data=True,
+ zip_safe=False,
+ install_requires=['setuptools',
+ 'grok',
+ 'grokui.admin',
+ 'z3c.testsetup',
+ 'gbewiki',
+ 'gbeguestbook',
+ 'gbe99bottles',
+ 'gbepastebin',
+ ],
+ entry_points="""
+ # Add entry points here
+ """,
+ )
Added: grokapps/gbedemosite/src/gbedemosite/__init__.py
===================================================================
--- grokapps/gbedemosite/src/gbedemosite/__init__.py (rev 0)
+++ grokapps/gbedemosite/src/gbedemosite/__init__.py 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1 @@
+# package
\ No newline at end of file
Added: grokapps/gbedemosite/src/gbedemosite/app.py
===================================================================
--- grokapps/gbedemosite/src/gbedemosite/app.py (rev 0)
+++ grokapps/gbedemosite/src/gbedemosite/app.py 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,27 @@
+import grok
+
+import zope.component
+
+class Demosite(grok.Application, grok.Container):
+ pass
+
+class Index(grok.View):
+ pass
+
+class Robots(grok.View):
+ grok.name('robots.txt')
+
+ at grok.subscribe(Demosite, grok.IObjectAddedEvent)
+def handle(obj, event):
+ applications=(('gbeguestbook.app.Application','Guestbook'),
+ ('gbe99bottles.app.Song','Song'),
+ ('gbewiki.app.WikiPage','Wiki'),
+ ('gbepastebin.app.Application','Pastebin'),
+ )
+ for application, name in applications:
+ app = zope.component.getUtility(grok.interfaces.IApplication,
+ name=application)
+ try:
+ obj[name] = app()
+ except DuplicationError:
+ pass
Added: grokapps/gbedemosite/src/gbedemosite/app.txt
===================================================================
--- grokapps/gbedemosite/src/gbedemosite/app.txt (rev 0)
+++ grokapps/gbedemosite/src/gbedemosite/app.txt 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,31 @@
+Do a functional doctest test on the app.
+========================================
+
+:Test-Layer: functional
+
+ >>> from gbedemosite.app import Demosite
+ >>> root = getRootFolder()
+ >>> root['app'] = Demosite()
+ >>> sorted(list(root['app'].keys()))
+ [u'Guestbook', u'Pastebin', u'Song', u'Wiki']
+
+Run tests in the testbrowser
+----------------------------
+
+The zope.testbrowser.browser module exposes a Browser class that
+simulates a web browser similar to Mozilla Firefox or IE. We use that
+to test how our application behaves in a browser. For more
+information, see http://pypi.python.org/pypi/zope.testbrowser.
+
+Create a browser and visit the instance you just created:
+
+ >>> from zope.testbrowser.testing import Browser
+ >>> browser = Browser()
+ >>> browser.open('http://localhost/app')
+
+Check some basic information about the page you visit:
+
+ >>> browser.url
+ 'http://localhost/app'
+ >>> browser.headers.get('Status').upper()
+ '200 OK'
Added: grokapps/gbedemosite/src/gbedemosite/app_templates/index.pt
===================================================================
--- grokapps/gbedemosite/src/gbedemosite/app_templates/index.pt (rev 0)
+++ grokapps/gbedemosite/src/gbedemosite/app_templates/index.pt 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,26 @@
+<html>
+<head>
+<title>Grok-By-Example: Demo site</title>
+<base target="_blank" />
+</head>
+<body>
+<h1>Grok-By-Example</h1>
+<p>Basic Grok apps ported from other python web frameworks
+(<a href="http://pypi.python.org/pypi/Grok-By-Example">PyPI: Grok-By-Example</a>)</p>
+
+<ul>
+ <li>
+ <a tal:attributes="href string:${view/application_url}/Guestbook">Guestbook</a>
+ </li>
+ <li>
+ <a tal:attributes="href string:${view/application_url}/Song">99 Bottles of Beer</a>
+ </li>
+ <li>
+ <a tal:attributes="href string:${view/application_url}/Wiki">Wiki</a>
+ </li>
+ <li>
+ <a tal:attributes="href string:${view/application_url}/Pastebin">Pastebin</a>
+ </li>
+</ul>
+</body>
+</html>
Added: grokapps/gbedemosite/src/gbedemosite/app_templates/robots.pt
===================================================================
Added: grokapps/gbedemosite/src/gbedemosite/configure.zcml
===================================================================
--- grokapps/gbedemosite/src/gbedemosite/configure.zcml (rev 0)
+++ grokapps/gbedemosite/src/gbedemosite/configure.zcml 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,6 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:grok="http://namespaces.zope.org/grok">
+ <include package="grok" />
+ <includeDependencies package="." />
+ <grok:grok package="." />
+</configure>
Added: grokapps/gbedemosite/src/gbedemosite/ftesting.zcml
===================================================================
--- grokapps/gbedemosite/src/gbedemosite/ftesting.zcml (rev 0)
+++ grokapps/gbedemosite/src/gbedemosite/ftesting.zcml 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,35 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="gbedemosite"
+ package="gbedemosite"
+ >
+
+ <include package="grok" />
+ <include package="gbedemosite" />
+
+ <!-- Typical functional testing security setup -->
+ <securityPolicy
+ component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
+ />
+
+ <unauthenticatedPrincipal
+ id="zope.anybody"
+ title="Unauthenticated User"
+ />
+ <grant
+ permission="zope.View"
+ principal="zope.anybody"
+ />
+
+ <principal
+ id="zope.mgr"
+ title="Manager"
+ login="mgr"
+ password="mgrpw"
+ />
+
+ <role id="zope.Manager" title="Site Manager" />
+ <grantAll role="zope.Manager" />
+ <grant role="zope.Manager" principal="zope.mgr" />
+
+</configure>
Added: grokapps/gbedemosite/src/gbedemosite/tests.py
===================================================================
--- grokapps/gbedemosite/src/gbedemosite/tests.py (rev 0)
+++ grokapps/gbedemosite/src/gbedemosite/tests.py 2008-10-08 14:07:39 UTC (rev 91906)
@@ -0,0 +1,12 @@
+import os.path
+import z3c.testsetup
+import gbedemosite
+from zope.app.testing.functional import ZCMLLayer
+
+
+ftesting_zcml = os.path.join(
+ os.path.dirname(gbedemosite.__file__), 'ftesting.zcml')
+FunctionalLayer = ZCMLLayer(ftesting_zcml, __name__, 'FunctionalLayer',
+ allow_teardown=True)
+
+test_suite = z3c.testsetup.register_all_tests('gbedemosite')
More information about the Checkins
mailing list