From: Stefan Bund Date: Sat, 24 Jul 2010 11:32:20 +0000 (+0200) Subject: Fix 'buildout.cfg' modification code X-Git-Url: http://g0dil.de/git?p=zope-bootstrap.git;a=commitdiff_plain;h=3f2d2b9a20aacd0332ec00b586575063a2ee7ee2 Fix 'buildout.cfg' modification code --- diff --git a/Makefile.buildout b/Makefile.buildout index 3728542..47c5738 100644 --- a/Makefile.buildout +++ b/Makefile.buildout @@ -1,13 +1,88 @@ # -*- makefile -*- +# Usage: +# @$(buildout_opt) [set|add|append|remove]
[] +# +# Change setting for in
. Actions are +# +# set Set to replacing any existing value +# add If is unset, set to +# append Append to the end of the current value of +# remove Remove any assignment to +# +define buildout_opt + _buildout_getopt_() { \ + sed -n -e "/^\[$$1\]/,/^\[/ba" -eb -e:a -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/p" $$cfgfile | \ + sed -e '$$d'; \ + }; \ + _buildout_haveopt() { \ + [ -n "`_buildout_getopt_ "$$1" "$$2"`" ]; \ + }; \ + _buildout_getopt() { \ + _buildout_checkopt_ "$$1" "$$2" | -e '1s/[^=]* *= *//'; \ + }; \ + _buildout_addopt() { \ + sed -i -e "/\[$$1\]/ba" -eb -e:a -ea\\ -e "$$2 = $$3" $$cfgfile; \ + }; \ + _buildout_replaceopt() { \ + sed -i -e "/^\[$$1\]/,/^\[/ba" -eb -e:a \ + -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/bb" -eb -e:b \ + -e "/^$$2 *=/bc" -ebd -e:c \ + -ec\\ -e "$$2 = $$3" -eb -e:d \ + -e "/^\([^ \t]\|\$$\)/b" -ed \ + $$cfgfile; \ + }; \ + _buildout_appendopt() { \ + sed -i -e "/^\[$$1\]/,/^\[/ba" -eb -e:a \ + -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/bb" -eb -e:b \ + -e /^\([^ \t]\|$$\)/bc -eb -e:c \ + -ei\\ -e " $$3" \ + $$cfgfile; \ + }; \ + _buildout_removeopt() { \ + sed -i -e "/^\[$$1\]/,/^\[/ba" -eb -e:a \ + -e "/^$$2 *=/,/^\([^ \t]\|\$$\)/bb" -eb -e:b \ + -e "/^\([^ \t]\|\$$\)/b" -ed \ + $$cfgfile; \ + }; \ + _buildout_opt_set() { \ + if _buildout_haveopt "$$1" "$$2"; then \ + _buildout_replaceopt "$$1" "$$2" "$$3"; \ + else \ + _buildout_addopt "$$1" "$$2" "$$3"; \ + fi; \ + }; \ + _buildout_opt_add() { \ + if ! _buildout_haveopt "$$1" "$$2"; then \ + _buildout_addopt "$$1" "$$2" "$$3"; \ + fi; \ + }; \ + _buildout_opt_append() { \ + if builout_haveopt "$$1" "$$2"; then \ + _buildout_appendopt "$$1" "$$2" "$$3"; \ + else \ + _buildouT_addopt "$$1" "$$2" "$$3"; \ + fi; \ + }; \ + _builout_opt_remove() { \ + if buildout_haveopt "$$1" "$$2"; then \ + _buildout_removeopt "$$1" "$$2"; \ + fi; \ + }; \ + _buildout_opt() { \ + echo "$$1: option '[$$3]/$$4' $$2 '$$5'"; \ + cfgfile="$$1"; \ + _buildout_opt_$$2 "$$3" "$$4" "$$5"; \ + }; \ + _buildout_opt +endef + buildout-net.cfg: buildout.cfg - @sed -i -e '/\[buildout\]/ba' -eb -e:a \ - -ea\\ -e 'download-cache = $(DLCACHE)/downloads' \ - -ea\\ -e 'install-from-cache = true' \ - -ea\\ -e 'extends-cache = $(DLCACHE)/extends' \ - -ea\\ -e 'newest = false' \ - buildout.cfg || ( rm -f buildout.cfg; false ) - @mkdir -p $(DLCACHE)/downloads $(DLCACHE)/extends || ( rm -f buildout.cfg; false ) + @$(buildout_opt) buildout.cfg add buildout download_cache $(DLCACHE)/downloads + @$(buildout_opt) buildout.cfg add buildout extends-cache $(DLCACHE)/extends + @$(buildout_opt) buildout.cfg set buildout install_from_cache true + @$(buildout_opt) buildout.cfg set buildout newest true + mkdir -p $(DLCACHE)/downloads $(DLCACHE)/extends @( \ echo "[buildout]"; \ echo "extends = buildout.cfg"; \ diff --git a/skel-zope3/.gitignore b/skel-zope3/.gitignore new file mode 100644 index 0000000..6e26ebc --- /dev/null +++ b/skel-zope3/.gitignore @@ -0,0 +1,13 @@ +*.pyc +*.egg-info/ +/.env +/python/ +/buildout-net.cfg +/bin/ +/develop-eggs/ +/downloads/ +/log/ +/var/ +/parts/ +/.installed.cfg +/dlcache/ diff --git a/skel-zope3/apidoc.zcml b/skel-zope3/apidoc.zcml new file mode 100644 index 0000000..59b34b7 --- /dev/null +++ b/skel-zope3/apidoc.zcml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/skel-zope3/buildout.cfg b/skel-zope3/buildout.cfg new file mode 100644 index 0000000..3a8eb92 --- /dev/null +++ b/skel-zope3/buildout.cfg @@ -0,0 +1,32 @@ +[buildout] +install_from_cache = true +extends-cache = dlcache/extends +download_cache = dlcache/downloads +develop = . +newest = true +parts = app test +eggs-directory = downloads + +# These settings pin egg versions to the Zope 3.4.0 Known Good Set +# if you want to upgrade the KGS version, you need to change the URL +# below. If you will comment/remove these settings, you'll get the +# latest versions of Zope eggs that are not guaranteed to work well +# together. +extends = http://download.zope.org/zope3.4/3.4.0/versions.cfg +versions = versions + +[app] +recipe = zc.recipe.egg +eggs = appmain + zope.app.apidoc + zope.app.securitypolicy + z3c.evalexception>=2.0 + Paste + PasteScript + PasteDeploy +interpreter = python + +[test] +recipe = zc.recipe.testrunner +eggs = appmain +defaults = ['--tests-pattern', '^f?tests$', '-v'] diff --git a/skel-zope3/debug.ini b/skel-zope3/debug.ini new file mode 100644 index 0000000..3a5965e --- /dev/null +++ b/skel-zope3/debug.ini @@ -0,0 +1,13 @@ +[filter-app:main] +# Change the last part from 'ajax' to 'pdb' for a post-mortem debugger +# on the console: +use = egg:z3c.evalexception#ajax +next = zope + +[app:zope] +use = egg:appmain + +[server:main] +use = egg:Paste#http +host = 127.0.0.1 +port = 8080 diff --git a/skel-zope3/deploy.ini b/skel-zope3/deploy.ini new file mode 100644 index 0000000..a480426 --- /dev/null +++ b/skel-zope3/deploy.ini @@ -0,0 +1,7 @@ +[app:main] +use = egg:appmain + +[server:main] +use = egg:Paste#http +host = 127.0.0.1 +port = 8080 diff --git a/skel-zope3/setup.py b/skel-zope3/setup.py new file mode 100644 index 0000000..c0f76c4 --- /dev/null +++ b/skel-zope3/setup.py @@ -0,0 +1,58 @@ +from setuptools import setup, find_packages + +setup(name='appmain', + + # Fill in project info below + version='0.1', + description="", + long_description="", + keywords='', + author='', + author_email='', + url='', + license='', + # Get more from http://www.python.org/pypi?%3Aaction=list_classifiers + classifiers=['Programming Language :: Python', + 'Environment :: Web Environment', + 'Topic :: Internet :: WWW/HTTP :: WSGI :: Application', + 'Framework :: Zope3', + ], + + packages=find_packages('src'), + package_dir = {'': 'src'}, + include_package_data=True, + zip_safe=False, + install_requires=['setuptools', + 'ZODB3', + 'ZConfig', + 'zdaemon', + 'zope.publisher', + 'zope.traversing', + 'zope.app.wsgi>=3.4.0', + 'zope.app.appsetup', + 'zope.app.zcmlfiles', + # The following packages aren't needed from the + # beginning, but end up being used in most apps + 'zope.annotation', + 'zope.copypastemove', + 'zope.formlib', + 'zope.i18n', + 'zope.app.authentication', + 'zope.app.session', + 'zope.app.intid', + 'zope.app.keyreference', + 'zope.app.catalog', + # The following packages are needed for functional + # tests only + 'zope.testing', + 'zope.app.testing', + 'zope.app.securitypolicy', + ], + entry_points = """ + [console_scripts] + appmain-debug = appmain.startup:interactive_debug_prompt + appmain-ctl = appmain.startup:zdaemon_controller + [paste.app_factory] + main = appmain.startup:application_factory + """ + ) diff --git a/skel-zope3/site.zcml b/skel-zope3/site.zcml new file mode 100644 index 0000000..51407c3 --- /dev/null +++ b/skel-zope3/site.zcml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/skel-zope3/src/appmain/__init__.py b/skel-zope3/src/appmain/__init__.py new file mode 100644 index 0000000..d67d458 --- /dev/null +++ b/skel-zope3/src/appmain/__init__.py @@ -0,0 +1 @@ +# Make this directory a package diff --git a/skel-zope3/src/appmain/configure.zcml b/skel-zope3/src/appmain/configure.zcml new file mode 100644 index 0000000..b176532 --- /dev/null +++ b/skel-zope3/src/appmain/configure.zcml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/skel-zope3/src/appmain/ftesting.zcml b/skel-zope3/src/appmain/ftesting.zcml new file mode 100644 index 0000000..9d5b407 --- /dev/null +++ b/skel-zope3/src/appmain/ftesting.zcml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/skel-zope3/src/appmain/startup.py b/skel-zope3/src/appmain/startup.py new file mode 100644 index 0000000..478af5d --- /dev/null +++ b/skel-zope3/src/appmain/startup.py @@ -0,0 +1,35 @@ +import os +import sys +import code +import zdaemon.zdctl +import zope.app.wsgi +import zope.app.debug + +def application_factory(global_conf, conf='zope.conf'): + zope_conf = os.path.join(global_conf['here'], conf) + return zope.app.wsgi.getWSGIApplication(zope_conf) + +def interactive_debug_prompt(zope_conf='zope.conf'): + db = zope.app.wsgi.config(zope_conf) + debugger = zope.app.debug.Debugger.fromDatabase(db) + # Invoke an interactive interpreter shell + banner = ("Welcome to the interactive debug prompt.\n" + "The 'root' variable contains the ZODB root folder.\n" + "The 'app' variable contains the Debugger, 'app.publish(path)' " + "simulates a request.") + code.interact(banner=banner, local={'debugger': debugger, + 'app': debugger, + 'root': debugger.root()}) + +class ControllerCommands(zdaemon.zdctl.ZDCmd): + + def do_debug(self, rest): + interactive_debug_prompt() + + def help_debug(self): + print "debug -- Initialize the application, providing a debugger" + print " object at an interactive Python prompt." + +def zdaemon_controller(zdaemon_conf='zdaemon.conf'): + args = ['-C', zdaemon_conf] + sys.argv[1:] + zdaemon.zdctl.main(args, options=None, cmdclass=ControllerCommands) diff --git a/skel-zope3/src/appmain/testing.py b/skel-zope3/src/appmain/testing.py new file mode 100644 index 0000000..4178830 --- /dev/null +++ b/skel-zope3/src/appmain/testing.py @@ -0,0 +1,21 @@ +import os.path +from zope.testing import doctest +from zope.app.testing import functional + +ftesting_zcml = os.path.join(os.path.dirname(__file__), 'ftesting.zcml') +FunctionalLayer = functional.ZCMLLayer(ftesting_zcml, __name__, + 'FunctionalLayer') + +def FunctionalDocTestSuite(module=None, **kw): + module = doctest._normalize_module(module) + suite = functional.FunctionalDocTestSuite(module, **kw) + suite.layer = FunctionalLayer + return suite + +def FunctionalDocFileSuite(path, **kw): + suite = functional.FunctionalDocFileSuite(path, **kw) + suite.layer = FunctionalLayer + return suite + +class FunctionalTestCase(functional.FunctionalTestCase): + layer = FunctionalLayer diff --git a/skel-zope3/zdaemon.conf b/skel-zope3/zdaemon.conf new file mode 100644 index 0000000..cae6a23 --- /dev/null +++ b/skel-zope3/zdaemon.conf @@ -0,0 +1,8 @@ + + program bin/paster serve deploy.ini + daemon on + transcript log/zdaemon.log + socket-name var/zdaemonsock + # Enable this to run the child process as a different user + # user zope + diff --git a/skel-zope3/zope.conf b/skel-zope3/zope.conf new file mode 100644 index 0000000..175931d --- /dev/null +++ b/skel-zope3/zope.conf @@ -0,0 +1,46 @@ +# Identify the component configuration used to define the site: +site-definition site.zcml + + + # Wrap standard FileStorage with BlobStorage proxy to get ZODB blobs + # support. + # This won't be needed with ZODB 3.9, as its FileStorage supports + # blobs by itself. If you use ZODB 3.9, remove the proxy and specify + # the blob-dir parameter right in in filestorage, just after path. + + blob-dir var/blobs + + path var/Data.fs + + + +# Uncomment this if you want to connect to a ZEO server instead: +# +# server localhost:8100 +# storage 1 +# # ZEO client cache, in bytes +# cache-size 20MB +# # Uncomment to have a persistent disk cache +# #client zeo1 +# + + + + # This sets up logging to both a file and to standard output (STDOUT). + # The "path" setting can be a relative or absolute filesystem path or + # the tokens STDOUT or STDERR. + + + path log/z3.log + formatter zope.exceptions.log.Formatter + + + + path STDOUT + formatter zope.exceptions.log.Formatter + + + +# Comment this line to disable developer mode. This should be done in +# production +devmode on