[z3-checkins] r25377 - z3/sqlos/trunk

jinty at codespeak.net jinty at codespeak.net
Wed Apr 5 14:48:34 CEST 2006


Author: jinty
Date: Wed Apr  5 14:48:32 2006
New Revision: 25377

Added:
   z3/sqlos/trunk/sampleapp.py   (contents, props changed)
Modified:
   z3/sqlos/trunk/makefile
Log:
Add a sampleapp script that allows people to run the functional testing suite as a sample application. Not quite thoroughly tested yet...

Modified: z3/sqlos/trunk/makefile
==============================================================================
--- z3/sqlos/trunk/makefile	(original)
+++ z3/sqlos/trunk/makefile	Wed Apr  5 14:48:32 2006
@@ -4,6 +4,7 @@
 ZH=${HERE}/../../
 PYTHON=python2.4
 z3includes=Zope3/zopeskel/etc/package-includes
+Z3BRANCH=trunk
 
 all : test clean
 
@@ -36,7 +37,7 @@
 
 .PHONY: z3-checkout
 z3-checkout:
-	-test -d Zope3 || svn co svn://svn.zope.org/repos/main/Zope3/trunk Zope3
+	-test -d Zope3 || svn co svn://svn.zope.org/repos/main/Zope3/$(Z3BRANCH) Zope3
 
 .PHONY: z3-update
 z3-update: z3-checkout
@@ -51,9 +52,12 @@
 .PHONY: sqlos-meta
 sqlos-meta: $(z3includes)/sqlos-meta.zcml $(z3includes)/sqlos-configure.zcml $(z3includes)/sqlos-ftesting.zcml
 
-.PHONY: develop
-develop: Zope3 sqlos-meta
+.PHONY: Zope3-build
+Zope3-build: Zope3
 	cd Zope3 && $(MAKE) PYTHON=$(PYTHON) inplace
+
+.PHONY: develop
+develop: Zope3-build sqlos-meta
 	touch Zope3/src/easy-install.pth
 	PYTHONPATH=Zope3/src $(PYTHON) setup.py develop -S Zope3/src --install-dir Zope3/src
 
@@ -68,3 +72,11 @@
 .PHONY: testall
 test: develop patch
 	cd Zope3 && $(PYTHON) test.py --test-path=../src -s sqlos
+
+Zope3/principals.zcml: Zope3 Zope3/sample_principals.zcml
+	cp Zope3/sample_principals.zcml $@
+
+.PHONY: run-sample
+run-sample: develop Zope3/principals.zcml
+	cp includes/sqlos-ftesting.zcml $(z3includes)/sqlos.testing-configure.zcml
+	sampleapp.py ; rm $(z3includes)/sqlos.testing-configure.zcml

Added: z3/sqlos/trunk/sampleapp.py
==============================================================================
--- (empty file)
+++ z3/sqlos/trunk/sampleapp.py	Wed Apr  5 14:48:32 2006
@@ -0,0 +1,79 @@
+#!/usr/bin/env python2.4
+##############################################################################
+#
+# Copyright (c) 2001, 2002 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.
+#
+##############################################################################
+"""Start script for Zope3: loads configuration and starts the server.
+
+$Id: z3.py 40235 2005-11-18 21:30:31Z srichter $
+"""
+import os
+import sys
+
+basepath = filter(None, sys.path)
+
+def run(argv=list(sys.argv)):
+
+    if sys.version_info < ( 2,3,5 ):
+        print """\
+        ERROR: Your python version is not supported by Zope3.
+        Zope3 needs Python 2.3.5 or greater. You are running:""" + sys.version
+        sys.exit(1)
+
+    # Refuse to run without principals.zcml
+    if not os.path.exists('principals.zcml'):
+        print """\
+        ERROR: You need to create principals.zcml
+
+        The file principals.zcml contains your "bootstrap" user
+        database. You aren't going to get very far without it.  Start
+        by copying sample_principals.zcml and then modify the
+        example principal and role settings.
+        """
+        sys.exit(1)
+
+    # setting python paths
+    program = argv[0]
+    if "--build" in argv:
+        argv.remove("--build")
+        from distutils.util import get_platform
+        PLAT_SPEC = "%s-%s" % (get_platform(), sys.version[0:3])
+        src = os.path.join("build", "lib.%s" % PLAT_SPEC)
+    else:
+        src = 'src'
+
+    here = os.path.dirname(os.path.abspath(program))
+    srcdir = os.path.abspath(src)
+    sys.path = [srcdir] + basepath
+    sys.path[:] = [p for p in sys.path if os.path.abspath(p) != here]
+    
+    # Register the paths
+    import site
+    site.addsitedir(srcdir)
+
+    # setup a subscriber to create the sampleperson tables 
+    def setupTestingTables(event):
+        from sqlos.testing import sampleperson
+        sampleperson.createTestingTables()
+    
+    from zope.app.appsetup.interfaces import IDatabaseOpenedEvent
+    from zope.component import getGlobalSiteManager
+    gsm = getGlobalSiteManager()
+    gsm.subscribe([IDatabaseOpenedEvent], None, setupTestingTables)
+
+    from zope.app.twisted.main import main
+    main(argv[1:])
+
+
+if __name__ == '__main__':
+    os.chdir('Zope3')
+    run()


More information about the z3-checkins mailing list