zope.app.server-3.6.0/0000755000177100020040000000000011542403754014452 5ustar menesismenesiszope.app.server-3.6.0/CHANGES.txt0000644000177100020040000000142611542403742016263 0ustar menesismenesis======= CHANGES ======= 3.6.0 (2011-03-23) ------------------ - Moved ``zope.app.server.zpasswd`` to ``zope.password.zpasswd``. 3.5.0 (2009-12-19) ------------------ - Use ``zope.password`` instead of ``zope.app.authentication`` - Depend on new ``zope.processlifetime`` implementations instead of using BBB imports from ``zope.app.appsetup``. 3.4.2 (2008-08-18) ------------------ - Moved a doctest into a unittest to fix failures in the KGS test suite (see LP #257954) 3.4.1 (2008-02-25) ------------------ - Fixed restart so that the process exits with a non-zero exit status so it gets restarted by zdaemon, or an equivalent mechanism. - Removed the use of ``ThreadedAsync``. 3.4.0 (2007-10-27) ------------------ - Initial release independent of the main Zope tree. zope.app.server-3.6.0/PKG-INFO0000644000177100020040000000377211542403754015560 0ustar menesismenesisMetadata-Version: 1.0 Name: zope.app.server Version: 3.6.0 Summary: ZServer integration for Zope 3 Applications Home-page: http://cheeseshop.python.org/pypi/zope.app.server Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: This package integrates ZServer -- Zope's HTTP and FTP server -- into a Zope 3 application setup. It also defines the script skeleton for a classic Zope 3 application. ======= CHANGES ======= 3.6.0 (2011-03-23) ------------------ - Moved ``zope.app.server.zpasswd`` to ``zope.password.zpasswd``. 3.5.0 (2009-12-19) ------------------ - Use ``zope.password`` instead of ``zope.app.authentication`` - Depend on new ``zope.processlifetime`` implementations instead of using BBB imports from ``zope.app.appsetup``. 3.4.2 (2008-08-18) ------------------ - Moved a doctest into a unittest to fix failures in the KGS test suite (see LP #257954) 3.4.1 (2008-02-25) ------------------ - Fixed restart so that the process exits with a non-zero exit status so it gets restarted by zdaemon, or an equivalent mechanism. - Removed the use of ``ThreadedAsync``. 3.4.0 (2007-10-27) ------------------ - Initial release independent of the main Zope tree. Keywords: zope3 zserver server http ftp wsgi Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope3 zope.app.server-3.6.0/README.txt0000644000177100020040000000025011542403742016142 0ustar menesismenesisThis package integrates ZServer -- Zope's HTTP and FTP server -- into a Zope 3 application setup. It also defines the script skeleton for a classic Zope 3 application. zope.app.server-3.6.0/setup.py0000644000177100020040000000567611542403742016177 0ustar menesismenesis############################################################################## # # Copyright (c) 2006 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. # ############################################################################## # This package is developed by the Zope Toolkit project, documented here: # http://docs.zope.org/zopetoolkit # When developing and releasing this package, please follow the documented # Zope Toolkit policies as described by this documentation. ############################################################################## """Setup for zope.app.server package """ import os from setuptools import setup, find_packages def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() setup(name='zope.app.server', version='3.6.0', author='Zope Corporation and Contributors', author_email='zope-dev@zope.org', description='ZServer integration for Zope 3 Applications', long_description=( read('README.txt') + '\n\n' + read('CHANGES.txt') ), keywords = "zope3 zserver server http ftp wsgi", classifiers = [ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: Zope Public License', 'Programming Language :: Python', 'Natural Language :: English', 'Operating System :: OS Independent', 'Topic :: Internet :: WWW/HTTP', 'Framework :: Zope3'], url='http://cheeseshop.python.org/pypi/zope.app.server', license='ZPL 2.1', packages=find_packages('src'), package_dir = {'': 'src'}, namespace_packages=['zope', 'zope.app'], extras_require = dict(test=['zope.app.testing']), install_requires=['setuptools', 'zope.app.applicationcontrol', 'zope.app.appsetup >= 3.11', 'zope.app.publication', 'zope.app.wsgi', 'zope.configuration', 'zope.deprecation', 'zope.event', 'zope.interface', 'zope.publisher', 'zope.server', 'zope.password >= 3.6', 'zope.processlifetime', 'zdaemon', 'ZConfig', 'ZODB3', ], include_package_data = True, zip_safe = False, ) zope.app.server-3.6.0/COPYRIGHT.txt0000644000177100020040000000004011542403742016552 0ustar menesismenesisZope Foundation and Contributorszope.app.server-3.6.0/LICENSE.txt0000644000177100020040000000402611542403742016274 0ustar menesismenesisZope Public License (ZPL) Version 2.1 A copyright notice accompanies this license document that identifies the copyright holders. This license has been certified as open source. It has also been designated as GPL compatible by the Free Software Foundation (FSF). Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions in source code must retain the accompanying copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the accompanying copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Names of the copyright holders must not be used to endorse or promote products derived from this software without prior written permission from the copyright holders. 4. The right to distribute this software or to use it for any purpose does not give you the right to use Servicemarks (sm) or Trademarks (tm) of the copyright holders. Use of them is covered by separate agreement with the copyright holders. 5. If any files are modified, you must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. Disclaimer THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. zope.app.server-3.6.0/bootstrap.py0000644000177100020040000000330211542403742017034 0ustar menesismenesis############################################################################## # # Copyright (c) 2006 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. # ############################################################################## """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. """ 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) zope.app.server-3.6.0/setup.cfg0000644000177100020040000000007311542403754016273 0ustar menesismenesis[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 zope.app.server-3.6.0/src/0000755000177100020040000000000011542403754015241 5ustar menesismenesiszope.app.server-3.6.0/src/zope.app.server.egg-info/0000755000177100020040000000000011542403754021774 5ustar menesismenesiszope.app.server-3.6.0/src/zope.app.server.egg-info/PKG-INFO0000644000177100020040000000377211542403753023101 0ustar menesismenesisMetadata-Version: 1.0 Name: zope.app.server Version: 3.6.0 Summary: ZServer integration for Zope 3 Applications Home-page: http://cheeseshop.python.org/pypi/zope.app.server Author: Zope Corporation and Contributors Author-email: zope-dev@zope.org License: ZPL 2.1 Description: This package integrates ZServer -- Zope's HTTP and FTP server -- into a Zope 3 application setup. It also defines the script skeleton for a classic Zope 3 application. ======= CHANGES ======= 3.6.0 (2011-03-23) ------------------ - Moved ``zope.app.server.zpasswd`` to ``zope.password.zpasswd``. 3.5.0 (2009-12-19) ------------------ - Use ``zope.password`` instead of ``zope.app.authentication`` - Depend on new ``zope.processlifetime`` implementations instead of using BBB imports from ``zope.app.appsetup``. 3.4.2 (2008-08-18) ------------------ - Moved a doctest into a unittest to fix failures in the KGS test suite (see LP #257954) 3.4.1 (2008-02-25) ------------------ - Fixed restart so that the process exits with a non-zero exit status so it gets restarted by zdaemon, or an equivalent mechanism. - Removed the use of ``ThreadedAsync``. 3.4.0 (2007-10-27) ------------------ - Initial release independent of the main Zope tree. Keywords: zope3 zserver server http ftp wsgi Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: Zope Public License Classifier: Programming Language :: Python Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Internet :: WWW/HTTP Classifier: Framework :: Zope3 zope.app.server-3.6.0/src/zope.app.server.egg-info/top_level.txt0000644000177100020040000000000511542403753024520 0ustar menesismenesiszope zope.app.server-3.6.0/src/zope.app.server.egg-info/SOURCES.txt0000644000177100020040000000245311542403753023663 0ustar menesismenesisCHANGES.txt COPYRIGHT.txt LICENSE.txt README.txt bootstrap.py buildout.cfg setup.py src/zope/__init__.py src/zope.app.server.egg-info/PKG-INFO src/zope.app.server.egg-info/SOURCES.txt src/zope.app.server.egg-info/dependency_links.txt src/zope.app.server.egg-info/namespace_packages.txt src/zope.app.server.egg-info/not-zip-safe src/zope.app.server.egg-info/requires.txt src/zope.app.server.egg-info/top_level.txt src/zope/app/__init__.py src/zope/app/server/__init__.py src/zope/app/server/accesslog.py src/zope/app/server/accesslog.xml src/zope/app/server/configure.zcml src/zope/app/server/ftp.py src/zope/app/server/main.py src/zope/app/server/mkzopeinstance.py src/zope/app/server/schema.xml src/zope/app/server/server.py src/zope/app/server/servercontrol.py src/zope/app/server/servertype.py src/zope/app/server/wsgi.py src/zope/app/server/zpasswd.py src/zope/app/server/tests/__init__.py src/zope/app/server/tests/site.zcml src/zope/app/server/tests/test_accesslog.py src/zope/app/server/tests/test_ftp.py src/zope/app/server/tests/test_mkzopeinstance.py src/zope/app/server/tests/test_schema.py src/zope/app/server/tests/test_server.py src/zope/app/server/tests/test_servertype.py src/zope/app/server/zopeskel/bin/debugzope.in src/zope/app/server/zopeskel/bin/runzope.in src/zope/app/server/zopeskel/etc/zope.conf.inzope.app.server-3.6.0/src/zope.app.server.egg-info/namespace_packages.txt0000644000177100020040000000001611542403753026323 0ustar menesismenesiszope zope.app zope.app.server-3.6.0/src/zope.app.server.egg-info/not-zip-safe0000644000177100020040000000000111542403743024220 0ustar menesismenesis zope.app.server-3.6.0/src/zope.app.server.egg-info/dependency_links.txt0000644000177100020040000000000111542403753026041 0ustar menesismenesis zope.app.server-3.6.0/src/zope.app.server.egg-info/requires.txt0000644000177100020040000000042511542403753024374 0ustar menesismenesissetuptools zope.app.applicationcontrol zope.app.appsetup >= 3.11 zope.app.publication zope.app.wsgi zope.configuration zope.deprecation zope.event zope.interface zope.publisher zope.server zope.password >= 3.6 zope.processlifetime zdaemon ZConfig ZODB3 [test] zope.app.testingzope.app.server-3.6.0/src/zope/0000755000177100020040000000000011542403754016216 5ustar menesismenesiszope.app.server-3.6.0/src/zope/__init__.py0000644000177100020040000000031011542403742020316 0ustar menesismenesis# this is a namespace package try: import pkg_resources pkg_resources.declare_namespace(__name__) except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) zope.app.server-3.6.0/src/zope/app/0000755000177100020040000000000011542403754016776 5ustar menesismenesiszope.app.server-3.6.0/src/zope/app/__init__.py0000644000177100020040000000031011542403742021076 0ustar menesismenesis# this is a namespace package try: import pkg_resources pkg_resources.declare_namespace(__name__) except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) zope.app.server-3.6.0/src/zope/app/server/0000755000177100020040000000000011542403754020304 5ustar menesismenesiszope.app.server-3.6.0/src/zope/app/server/servertype.py0000644000177100020040000000412311542403742023063 0ustar menesismenesis############################################################################## # # Copyright (c) 2001, 2002 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. # ############################################################################## """Server Type """ from zope.interface import Interface, implements class IServerType(Interface): """Server type utility. This is a pure read-only interface, since the values are set through a ZCML directive and we shouldn't be able to change them. """ def create(name, task_dispatcher, db, port=None, verbose=None, ip=None): """Create the server knowing the port, task dispatcher and the ZODB. Returns the new server. """ class ServerType(object): implements(IServerType) def __init__(self, factory, requestFactory, logFactory, defaultPort, defaultVerbose, defaultIP=''): self._factory = factory self._requestFactory = requestFactory self._logFactory = logFactory self._defaultPort = defaultPort self._defaultVerbose = defaultVerbose self._defaultIP = defaultIP def create(self, name, task_dispatcher, db, port=None, verbose=None, ip=None): 'See IServerType' request_factory = self._requestFactory(db) if port is None: port = self._defaultPort if ip is None: ip = self._defaultIP if verbose is None: verbose = self._defaultVerbose return self._factory(request_factory, name, ip, port, task_dispatcher=task_dispatcher, verbose=verbose, hit_log=self._logFactory(), ) zope.app.server-3.6.0/src/zope/app/server/accesslog.xml0000644000177100020040000000104711542403742022770 0ustar menesismenesis Configuration for the access logger. Note that the setting of verbosity level and message formats are not used. All logging is done using the Common Log Format. zope.app.server-3.6.0/src/zope/app/server/__init__.py0000644000177100020040000000002711542403742022411 0ustar menesismenesis# Make this a package. zope.app.server-3.6.0/src/zope/app/server/wsgi.py0000644000177100020040000000474411542403742021635 0ustar menesismenesis############################################################################## # # Copyright (c) 2005 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. # ############################################################################## """WSGI-compliant HTTP server setup. """ __docformat__ = "reStructuredText" import zope.interface from zope.server.http.commonaccesslogger import CommonAccessLogger from zope.server.http import wsgihttpserver from zope.app.publication.httpfactory import HTTPPublicationRequestFactory from zope.app.wsgi import WSGIPublisherApplication import servertype class ServerType(object): zope.interface.implements(servertype.IServerType) def __init__(self, factory, applicationFactory, logFactory, defaultPort, defaultVerbose, defaultIP='', requestFactory=HTTPPublicationRequestFactory): self._factory = factory self._applicationFactory = applicationFactory self._requestFactory = requestFactory self._logFactory = logFactory self._defaultPort = defaultPort self._defaultVerbose = defaultVerbose self._defaultIP = defaultIP def create(self, name, task_dispatcher, db, port=None, verbose=None, ip=None): 'See IServerType' application = self._applicationFactory( db, factory=self._requestFactory) if port is None: port = self._defaultPort if ip is None: ip = self._defaultIP if verbose is None: verbose = self._defaultVerbose return self._factory(application, name, ip, port, task_dispatcher=task_dispatcher, verbose=verbose, hit_log=self._logFactory(), ) http = ServerType(wsgihttpserver.WSGIHTTPServer, WSGIPublisherApplication, CommonAccessLogger, 8080, True) pmhttp = ServerType(wsgihttpserver.PMDBWSGIHTTPServer, WSGIPublisherApplication, CommonAccessLogger, 8013, True) zope.app.server-3.6.0/src/zope/app/server/server.py0000644000177100020040000000322111542403742022157 0ustar menesismenesis############################################################################## # # Copyright (c) 2003 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. # ############################################################################## """Datatype for a section in a Zope 3 configuration file. This is called by the ZConfig machinery while processing a configuration. """ import zope.component from zope.app.server.servertype import IServerType class ServerFactory(object): """Factory for server objects. The factories are part of the configuration data returned by ZConfig. """ def __init__(self, section): """Initialize the factory based on a section.""" self.type = section.type self.address = section.address self.verbose = section.verbose def create(self, task_dispatcher, database): """Return a server based on the server types defined via ZCML.""" servertype = zope.component.getUtility(IServerType, self.type) # The server object self-registers with the asyncore mainloop. return servertype.create( self.type, task_dispatcher, database, ip=self.address[0], port=self.address[1], verbose=self.verbose) zope.app.server-3.6.0/src/zope/app/server/main.py0000644000177100020040000000730011542403742021577 0ustar menesismenesis############################################################################## # # Copyright (c) 2003 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. # ############################################################################## """Functions that control how the Zope appserver knits itself together. """ import asyncore import logging import os import sys import time from zdaemon import zdoptions import zope.app.appsetup.appsetup import zope.processlifetime import zope.app.appsetup.product from zope.event import notify from zope.server.taskthreads import ThreadedTaskDispatcher CONFIG_FILENAME = "zope.conf" class ZopeOptions(zdoptions.ZDOptions): logsectionname = None def default_configfile(self): dir = os.path.normpath( os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir)) for filename in [CONFIG_FILENAME, CONFIG_FILENAME + ".in"]: filename = os.path.join(dir, filename) if os.path.isfile(filename): return filename return None exit_status = None def main(args=None): # Record start times (real time and CPU time) t0 = time.time() c0 = time.clock() setup(load_options(args)) t1 = time.time() c1 = time.clock() logging.info("Startup time: %.3f sec real, %.3f sec CPU", t1-t0, c1-c0) run() sys.exit(exit_status or 0) def debug(args=None): options = load_options(args) zope.app.appsetup.product.setProductConfigurations( options.product_config) zope.app.appsetup.config(options.site_definition) db = zope.app.appsetup.appsetup.multi_database(options.databases)[0][0] notify(zope.processlifetime.DatabaseOpened(db)) return db def run(): try: global exit_status while asyncore.socket_map and exit_status is None: asyncore.poll(30.0) except KeyboardInterrupt: # Exit without spewing an exception. pass def load_options(args=None): if args is None: args = sys.argv[1:] options = ZopeOptions() options.schemadir = os.path.dirname(os.path.abspath(__file__)) options.realize(args) options = options.configroot if options.path: sys.path[:0] = [os.path.abspath(p) for p in options.path] return options def setup(options): sys.setcheckinterval(options.check_interval) zope.app.appsetup.product.setProductConfigurations( options.product_config) options.eventlog() options.accesslog() for logger in options.loggers: logger() features = ('zserver',) # Provide the devmode, if activated if options.devmode: features += ('devmode',) logging.warning("Developer mode is enabled: this is a security risk " "and should NOT be enabled on production servers. Developer mode " "can be turned off in etc/zope.conf") zope.app.appsetup.config(options.site_definition, features=features) db = zope.app.appsetup.appsetup.multi_database(options.databases)[0][0] notify(zope.processlifetime.DatabaseOpened(db)) task_dispatcher = ThreadedTaskDispatcher() task_dispatcher.setThreadCount(options.threads) for server in options.servers: server.create(task_dispatcher, db) notify(zope.processlifetime.ProcessStarting()) return db zope.app.server-3.6.0/src/zope/app/server/zpasswd.py0000644000177100020040000000141211542403742022344 0ustar menesismenesis############################################################################## # # Copyright (c) 2004 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. # ############################################################################## """Implementation of the zpasswd script. """ import zope.deprecation zope.deprecation.moved('zope.password.zpasswd', 'zope.app.server 3.7.0') zope.app.server-3.6.0/src/zope/app/server/mkzopeinstance.py0000644000177100020040000003131111542403742023704 0ustar menesismenesis############################################################################## # # Copyright (c) 2004 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. # ############################################################################## """Implementation of the mkzopeinstance script. This creates a new instances of the Zope server instance home. An 'instance home' contains two things: - application server configuration and data - server process control scripts and data """ import optparse import os import shutil import sys from xml.sax.saxutils import quoteattr as xml_quoteattr import zope.app.server from zope.password import password from zope.app.applicationcontrol import zopeversion def main(argv=None, from_checkout=False): """Top-level script function to create a new Zope instance.""" if argv is None: argv = sys.argv try: options = parse_args(argv, from_checkout) except SystemExit, e: if e.code: return 2 else: return 0 app = Application(options) try: return app.process() except KeyboardInterrupt: return 1 except SystemExit, e: return e.code class Application(object): def __init__(self, options): self.options = options self.need_blank_line = False def read_input_line(self, prompt): # The tests replace this to make sure the right things happen. if not self.options.interactive: print >>sys.stderr, ('Error: Tried to ask for user input in' ' non-interactive mode.') sys.exit(1) return raw_input(prompt) def read_password(self, prompt): # The tests replace this to make sure the right things happen. if not self.options.interactive: print >>sys.stderr, ('Error: Tried to ask for user input in' ' non-interactive mode.') sys.exit(1) import getpass try: return getpass.getpass(prompt) except KeyboardInterrupt: # The cursor was left on the same line as the prompt, # which we don't like. Print a blank line. print raise def process(self): options = self.options # make sure we can find the skeleton if not os.path.isdir(options.skeleton): print >>sys.stderr, "skeleton directory", options.skeleton print >>sys.stderr, "does not exist or is not a directory" return 1 # create the destination if not options.destination: options.destination = self.get_skeltarget() options.destination = os.path.abspath(options.destination) if not os.path.exists(options.destination): try: os.mkdir(options.destination) except OSError, e: print >>sys.stderr, "could not create instance home:", e return 1 elif not os.path.isdir(options.destination): print >>sys.stderr, options.destination, "is not a directory" print >>sys.stderr, ("(instance homes cannot be created in" " non-directories)") return 1 if not options.username: options.username = self.get_username() (options.password_manager, password_manager) = self.get_password_manager() if not options.password: options.password = self.get_password() options.password = password_manager.encodePassword(options.password) # now create the instance! self.copy_skeleton() if options.add_package_includes: # need to copy ZCML differently since it's not in the skeleton: import __main__ swhome = os.path.dirname( os.path.dirname(os.path.realpath(__main__.__file__))) shutil.copy2(os.path.join(swhome, "securitypolicy.zcml"), os.path.join(options.destination, "etc")) return 0 def get_skeltarget(self): self.print_message(SKELTARGET_MESSAGE) self.need_blank_line = True while 1: skeltarget = self.read_input_line("Directory: ").strip() if skeltarget == '': print >>sys.stderr, 'You must specify a directory' continue return os.path.expanduser(skeltarget) def get_username(self): self.print_message(USERNAME_MESSAGE) self.need_blank_line = True while 1: username = self.read_input_line("Username: ").strip() if not username: print >>sys.stderr, "You must specify an administrative user" continue return username def get_password(self): self.print_message(PASSWORD_MESSAGE) while 1: password = self.read_password("Password: ") if not password: print >>sys.stderr, "Password may not be empty" continue if password != password.strip() or password.split() != [password]: print >>sys.stderr, "Password may not contain spaces" continue break again = self.read_password("Verify password: ") if again != password: print >>sys.stderr, "Password not verified!" sys.exit(1) return password def get_password_manager(self): if not self.options.password_manager and not self.options.interactive: self.options.password_manager = password.managers[0][0] if self.options.password_manager: for name, manager in password.managers: if name == self.options.password_manager: return (name, manager) print >>sys.stderr, "Unknown password manager!" sys.exit(1) self.print_message(PASSWORD_MANAGER_MESSAGE) for i, (name, manager) in enumerate(password.managers): print "% i. %s" % (i + 1, name) print self.need_blank_line = True while 1: password_manager = self.read_input_line( "Password Manager Number [1]: ") if not password_manager: index = 0 break elif password_manager.isdigit(): index = int(password_manager) if index > 0 and index <= len(password.managers): index -= 1 break print >>sys.stderr, "You must select a password manager" print "%r password manager selected" % password.managers[index][0] return password.managers[index] def print_message(self, message): if self.need_blank_line: print self.need_blank_line = False print message def copy_skeleton(self): options = self.options # TODO we should be able to compute the script script = os.path.abspath(sys.argv[0]) zope_home = os.path.dirname(os.path.dirname(script)) zope_init = os.path.dirname(os.path.abspath(zope.app.__file__)) software_home = os.path.dirname(os.path.dirname(zope_init)) self.replacements = [ ("<>", options.username), ("<>", xml_quoteattr(options.username)), ("<>", options.password), ("<>", xml_quoteattr(options.password)), ("<>", options.password_manager), ("<>", sys.executable), ("<>", options.destination), ("<>", zope_home), ("<>", software_home), ] self.copytree(self.options.skeleton, self.options.destination) if options.zserver: self.copytree( os.path.join(os.path.dirname(zope.app.server.__file__), 'zopeskel'), self.options.destination, ) def copytree(self, src, dst): # Similar to shutil.copytree(), but doesn't care about # symlinks, doesn't collect errors, and uses self.copyfile() # instead of shutil.copy2(). assert os.path.isdir(dst), dst names = os.listdir(src) if ".svn" in names: names.remove(".svn") for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) if os.path.isdir(srcname): if not os.path.exists(dstname): os.mkdir(dstname) self.copytree(srcname, dstname) else: self.copyfile(srcname, dstname) # There shouldn't be any need to deal with devices, sockets etc. def copyfile(self, src, dst): if dst.endswith(".in"): dst = dst[:-3] text = open(src, "rU").read() # perform replacements for var, string in self.replacements: text = text.replace(var, string) # If the file exists, keep the old file. This is a # hopefully temporary hack to get around distutils # stripping the permissions on the server skeletin files. # We reuse the original default files, which have the # right permissions. old = os.path.exists(dst) if old: f = open(dst, "r+") f.truncate(0) else: f = open(dst, "w") f.write(text) f.close() if not old: shutil.copymode(src, dst) shutil.copystat(src, dst) else: shutil.copy2(src, dst) SKELTARGET_MESSAGE = """\ Please choose a directory in which you'd like to install Zope 'instance home' files such as database files, configuration files, etc. """ USERNAME_MESSAGE = """\ Please choose a username for the initial administrator account. This is required to allow Zope's management interface to be used. """ PASSWORD_MESSAGE = """\ Please provide a password for the initial administrator account. """ PASSWORD_MANAGER_MESSAGE = """\ Please select a password manager which will be used for encode the password of the initial administrator account. """ def parse_args(argv, from_checkout=False): """Parse the command line, returning an object representing the input.""" path, prog = os.path.split(os.path.realpath(argv[0])) version = "%prog for " + zopeversion.ZopeVersionUtility.getZopeVersion() p = optparse.OptionParser(prog=prog, usage="%prog [options]", version=version) p.add_option("-d", "--dir", dest="destination", metavar="DIR", help="the dir in which the instance home should be created") p.add_option("-s", "--skelsrc", dest="skeleton", metavar="DIR", help="template skeleton directory") p.add_option("-m", "--password-manager", dest="password_manager", metavar="NAME", help=("set the name of the password manager" " to be used for encode the password")) p.add_option("-u", "--user", dest="username", metavar="USER:PASSWORD", help="set the user name and password of the initial user") p.add_option("--non-interactive", dest="interactive", action="store_false", default=True, help="do no interactive prompting") p.add_option("--zserver", dest="zserver", action="store_true", help="""\ Use the older ZServer network server rather than the default Twisted server. The Twisted integration with Zope is experimental and not recommended for use in production sites. We do encourage it's use in development or in sites that can stand a little uncertianty, so that we can gain more experience with it. """, ) options, args = p.parse_args(argv[1:]) if options.skeleton is None: options.add_package_includes = from_checkout basedir = os.path.dirname(path) # no assurance that this exists! options.skeleton = os.path.join(basedir, "zopeskel") else: options.add_package_includes = False options.program = prog options.version = version if args: p.error("too many arguments") options.password = None if options.username and ":" in options.username: options.username, options.password = options.username.split(":", 1) return options zope.app.server-3.6.0/src/zope/app/server/ftp.py0000644000177100020040000000366211542403742021453 0ustar menesismenesis############################################################################## # # Copyright (c) 2004 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. # ############################################################################## """FTP server """ from zope.app.publication.ftp import FTPPublication from zope.app.publication.interfaces import IPublicationRequestFactory from zope.publisher.ftp import FTPRequest from zope.server.ftp.logger import CommonFTPActivityLogger from zope.server.ftp.publisher import PublisherFTPServer from zope.app.server.servertype import ServerType import zope.interface class FTPRequestFactory(object): """FTP Request factory FTP request factories for a given database create FTP requests with publications on the given database: .. The test below has been disabled and moved to test_ftp.py (LP #257954) >>> from ZODB.tests.util import DB >>> db = DB() >>> factory = FTPRequestFactory(db) >>> from cStringIO import StringIO >>> request = factory(StringIO(''), {'credentials': None, 'path': '/'}) >>> request.publication.db is db True >>> db.close() """ zope.interface.implements(IPublicationRequestFactory) def __init__(self, db): self.publication = FTPPublication(db) def __call__(self, input_stream, env): request = FTPRequest(input_stream, env) request.setPublication(self.publication) return request server = ServerType( PublisherFTPServer, FTPRequestFactory, CommonFTPActivityLogger, 8021, True) zope.app.server-3.6.0/src/zope/app/server/servercontrol.py0000644000177100020040000000313111542403742023560 0ustar menesismenesis############################################################################## # # Copyright (c) 2001,2002,2003 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. # ############################################################################## """Server Control Implementation """ from zope.app.applicationcontrol.interfaces import IServerControl from zope.interface import implements import zope.app.server.main class ServerControl(object): implements(IServerControl) def shutdown(self, time=0): """See zope.app.applicationcontrol.interfaces.IServerControl""" # TODO: Graceful shutdown does not work yet. # This will work for servers started directly and by zdaemon. Passing # an exit status of 0 causes zdaemon to not restart the process. zope.app.server.main.exit_status = 0 def restart(self, time=0): """See zope.app.applicationcontrol.interfaces.IServerControl""" # TODO: Graceful restart does not work yet. # TODO: Make sure this is only called if we are running via zdaemon. # Passing an exit status of 1 causes zdaemon to restart the process. zope.app.server.main.exit_status = 1 serverControl = ServerControl() zope.app.server-3.6.0/src/zope/app/server/configure.zcml0000644000177100020040000000120411542403742023146 0ustar menesismenesis zope.app.server-3.6.0/src/zope/app/server/accesslog.py0000644000177100020040000000242511542403742022621 0ustar menesismenesis############################################################################## # # Copyright (c) 2004 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. # ############################################################################## """Configuration support for the access log. This assumes that access logging is being performed through the logger object returned by logging.getLogger('accesslog'). """ import logging from ZConfig.components.logger.logger import LoggerFactoryBase class AccessLogFactory(LoggerFactoryBase): """Logger factory that returns the access logger.""" name = "accesslog" def create(self): logger = LoggerFactoryBase.create(self) logger.setLevel(logging.INFO) logger.propagate = False formatter = logging.Formatter() for handler in logger.handlers: handler.setFormatter(formatter) return logger zope.app.server-3.6.0/src/zope/app/server/tests/0000755000177100020040000000000011542403754021446 5ustar menesismenesiszope.app.server-3.6.0/src/zope/app/server/tests/test_schema.py0000644000177100020040000000227511542403742024322 0ustar menesismenesis############################################################################## # # Copyright (c) 2003 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. # ############################################################################## """Test that the Zope appserver configuration schema can be loaded. """ import os.path import unittest import ZConfig class TestConfiguration(unittest.TestCase): def test_schema(self): dir = os.path.dirname(os.path.dirname(__file__)) filename = os.path.join(dir, "schema.xml") ZConfig.loadSchema(filename) def test_suite(): return unittest.makeSuite(TestConfiguration) if __name__ == "__main__": try: __file__ except NameError: import sys __file__ = sys.argv[0] unittest.main(defaultTest="test_suite") zope.app.server-3.6.0/src/zope/app/server/tests/__init__.py0000644000177100020040000000002711542403742023553 0ustar menesismenesis# Make this a package. zope.app.server-3.6.0/src/zope/app/server/tests/test_mkzopeinstance.py0000644000177100020040000003535411542403742026120 0ustar menesismenesis############################################################################## # # Copyright (c) 2004 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. # ############################################################################## """Tests for the implementation of the mkzopeinstance script. """ import os import shutil import sys import tempfile import unittest import zope.app.server from StringIO import StringIO from zope.app.server import mkzopeinstance class TestBase(unittest.TestCase): def setUp(self): self.stdout = StringIO() self.stderr = StringIO() self.old_stdout = sys.stdout self.old_stderr = sys.stderr sys.stdout = self.stdout sys.stderr = self.stderr def tearDown(self): sys.stdout = self.old_stdout sys.stderr = self.old_stderr class ArgumentParsingTestCase(TestBase): """Ensure the command line is properly converted to an options object. """ def parse_args(self, args): argv = ["foo/bar.py"] + args options = mkzopeinstance.parse_args(argv) self.assertEqual(options.program, "bar.py") self.assert_(options.version) return options def test_no_arguments(self): options = self.parse_args([]) def test_version_long(self): self.check_stdout_content(["--version"]) def test_help_long(self): self.check_stdout_content(["--help"]) def test_help_short(self): self.check_stdout_content(["-h"]) def check_stdout_content(self, args): try: options = self.parse_args(args) except SystemExit, e: self.assertEqual(e.code, 0) self.assert_(self.stdout.getvalue()) self.failIf(self.stderr.getvalue()) else: self.fail("expected SystemExit") def test_without_destination(self): options = self.parse_args([]) self.assertEqual(options.destination, None) def test_destination_long(self): options = self.parse_args(["--dir", "some/dir"]) self.assertEqual(options.destination, "some/dir") def test_destination_short(self): options = self.parse_args(["-d", "some/dir"]) self.assertEqual(options.destination, "some/dir") def test_without_skeleton(self): # make sure we get *some* skeleton directory by default # there's no claim that it exists options = self.parse_args([]) self.assertNotEqual(options.skeleton, None) def test_with_skeleton_long(self): options = self.parse_args(["--skelsrc", "some/dir"]) self.assertEqual(options.skeleton, "some/dir") self.failIf(options.add_package_includes) def test_with_skeleton_short(self): options = self.parse_args(["-s", "some/dir"]) self.assertEqual(options.skeleton, "some/dir") self.failIf(options.add_package_includes) def test_without_username(self): options = self.parse_args([]) self.assertEqual(options.username, None) self.assertEqual(options.password, None) def test_username_without_password_long(self): options = self.parse_args(["--user", "User"]) self.assertEqual(options.username, "User") self.assertEqual(options.password, None) def test_username_without_password_short(self): options = self.parse_args(["-u", "User"]) self.assertEqual(options.username, "User") self.assertEqual(options.password, None) def test_username_with_password_long(self): options = self.parse_args(["--user", "User:Pass"]) self.assertEqual(options.username, "User") self.assertEqual(options.password, "Pass") def test_username_with_password_short(self): options = self.parse_args(["-u", "User:Pass"]) self.assertEqual(options.username, "User") self.assertEqual(options.password, "Pass") def test_without_password_manager(self): options = self.parse_args([]) self.assertEqual(options.password_manager, None) def test_password_manager_short(self): options = self.parse_args(["-m", "Manager"]) self.assertEqual(options.password_manager, "Manager") def test_password_manager_long(self): options = self.parse_args(["--password-manager", "Manager"]) self.assertEqual(options.password_manager, "Manager") def test_junk_positional_arg(self): try: self.parse_args(["junk"]) except SystemExit, e: self.assert_(e.code) else: self.fail("expected SystemExit") class InputCollectionTestCase(TestBase): def setUp(self): super(InputCollectionTestCase, self).setUp() self.tmpdir = tempfile.mkdtemp(prefix="test-mkzopeinstance-") self.skeleton = os.path.join(self.tmpdir, "skel") self.instance = os.path.join(self.tmpdir, "inst") os.mkdir(self.skeleton) def tearDown(self): shutil.rmtree(self.tmpdir) super(InputCollectionTestCase, self).tearDown() def createOptions(self): options = Options() options.skeleton = self.skeleton options.interactive = True return options def test_get_skeltarget(self): options = self.createOptions() input = [" ", " foo "] app = ControlledInputApplication(options, input) skel = app.get_skeltarget() self.assertEqual(skel, "foo") self.assertEqual(input, []) self.assert_(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_process_creates_destination(self): options = self.createOptions() input = [self.instance] app = ControlledInputApplication(options, input) self.assertEqual(app.process(), 0) self.assert_(os.path.isdir(self.instance)) self.assertEqual(input, []) self.failUnless(app.all_input_consumed()) def test_zserver_support(self): # test the zserver option. We should get zserver versions of # runzope, zopectl, debugzope and zope.conf. Any of these # that we provide in put skeleton should be overritten. # privide a dummy runzope os.mkdir(os.path.join(self.skeleton, 'bin')) f = open(os.path.join(self.skeleton, 'bin', 'runzope.in'), 'w') f.write('runzope') f.close() options = self.createOptions() options.destination = self.instance options.interactive = False options.zserver = True app = ControlledInputApplication(options, []) self.assertEqual(app.process(), 0) self.assert_( 'from zope.app.server.main import main' in open(os.path.join(self.instance, 'bin', 'runzope')).read() ) self.assert_( 'from zope.app.server.main import debug' in open(os.path.join(self.instance, 'bin', 'debugzope')).read() ) self.assert_(os.path.exists( os.path.join(self.instance, 'etc', 'zope.conf') )) def test_process_aborts_on_file_destination(self): options = self.createOptions() options.destination = self.instance open(self.instance, "w").close() app = ControlledInputApplication(options, []) self.assertEqual(app.process(), 1) self.assert_(self.stderr.getvalue()) def test_process_aborts_on_failed_destination_creation(self): options = self.createOptions() options.destination = os.path.join(self.instance, "foo") app = ControlledInputApplication(options, []) self.assertEqual(app.process(), 1) self.assert_(self.stderr.getvalue()) def test_get_username(self): options = self.createOptions() app = ControlledInputApplication(options, ["myuser"]) usr = app.get_username() self.assertEqual(usr, "myuser") self.failIf(self.stderr.getvalue()) self.failUnless(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_get_username_strips_whitespace(self): options = self.createOptions() app = ControlledInputApplication(options, [" myuser\t"]) usr = app.get_username() self.assertEqual(usr, "myuser") self.failIf(self.stderr.getvalue()) self.failUnless(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_get_username_ignores_empty_names(self): options = self.createOptions() app = ControlledInputApplication(options, ["", " ", "\t", "myuser"]) usr = app.get_username() self.assertEqual(usr, "myuser") self.failUnless(self.stderr.getvalue()) self.failUnless(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_get_password_manager(self): options = self.createOptions() options.password_manager = None app = ControlledInputApplication(options, ["1"]) name, pwm = app.get_password_manager() self.assertEqual(name, "Plain Text") self.assertEqual(pwm.encodePassword("foo"), "foo") self.failIf(self.stderr.getvalue()) self.failUnless(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_get_wrong_password_manager(self): options = self.createOptions() options.password_manager = "Unknown" app = ControlledInputApplication(options, []) try: app.get_password_manager() except SystemExit, e: self.assertEqual(e.code, 1) else: self.fail("expected SystemExit") self.failUnless(self.stderr.getvalue()) self.failIf(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_get_password(self): options = self.createOptions() app = ControlledInputApplication(options, ["foo", "foo"]) pw = app.get_password() self.assertEqual(pw, "foo") self.failIf(self.stderr.getvalue()) self.failUnless(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_get_password_not_verified(self): options = self.createOptions() app = ControlledInputApplication(options, ["foo", "bar"]) try: app.get_password() except SystemExit, e: self.assertEqual(e.code, 1) else: self.fail("expected SystemExit") self.failUnless(self.stderr.getvalue()) self.failUnless(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_get_password_empty(self): # Make sure the empty password is ignored. options = self.createOptions() app = ControlledInputApplication(options, ["", "foo", "foo"]) pw = app.get_password() self.assertEqual(pw, "foo") self.failUnless(self.stderr.getvalue()) self.failUnless(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_get_password_disallows_whitespace(self): # Any password that contains spaces is disallowed. options = self.createOptions() app = ControlledInputApplication(options, [" ", "\t", "a b", " a", "b ", "foo", "foo"]) pw = app.get_password() self.assertEqual(pw, "foo") self.failUnless(self.stderr.getvalue()) self.failUnless(self.stdout.getvalue()) self.failUnless(app.all_input_consumed()) def test_can_rewrite_existing_instance(self): # Fill out the skeleton a little so we test more cases: os.mkdir(os.path.join(self.skeleton, "etc")) f = open(os.path.join(self.skeleton, "etc", "README.txt"), "w") f.write("Configuration goes here.\n") f.close() # Create an instance home: options = self.createOptions() options.destination = self.instance app = ControlledInputApplication(options, []) rc = app.process() self.assertEqual(rc, 0) self.failUnless(app.all_input_consumed()) self.failUnless(os.path.exists(os.path.join(self.instance, "etc"))) # Make sure we can do it again: options = self.createOptions() options.destination = self.instance app = ControlledInputApplication(options, []) rc = app.process() self.assertEqual(rc, 0) self.failUnless(app.all_input_consumed()) self.failUnless(os.path.exists(os.path.join(self.instance, "etc"))) def test_zope_namespace_package_doesnt_affect_software_home(self): # Make sure that a zope namespace package in a different # location won't affect SOFTWARE_HOME # let's mess with zope's __file__ import zope old_path = zope.__file__ zope.__file__ = os.path.join( *'and now for something completely different'.split()) # place a test file into the skeleton dir that'll be expanded # to SOFTWARE_HOME by mkzopeinstance f = file(os.path.join(self.skeleton, 'test.in'), 'w') f.write('<>') f.close() # run mkzopeinstance options = self.createOptions() options.destination = self.instance app = ControlledInputApplication(options, []) rc = app.process() # check for the expected output: mkzopeinstance should take # zope.app as an anchor for determining SOFTWARE_HOME import zope.app expected = os.path.dirname(os.path.dirname( os.path.dirname(zope.app.__file__))) self.assertEqual(file(os.path.join(self.instance, 'test')).read(), expected) # cleanup the fake 'zope' module zope.__file__ = old_path class ControlledInputApplication(mkzopeinstance.Application): def __init__(self, options, input_lines): mkzopeinstance.Application.__init__(self, options) self.__input = input_lines def read_input_line(self, prompt): return self.__input.pop(0) read_password = read_input_line def all_input_consumed(self): return not self.__input class Options(object): username = "[test-username]" password_manager = "Plain Text" password = "[test-password]" destination = None version = "[test-version]" program = "[test-program]" add_package_includes = False zserver = False def test_suite(): suite = unittest.makeSuite(ArgumentParsingTestCase) suite.addTest(unittest.makeSuite(InputCollectionTestCase)) return suite if __name__ == "__main__": unittest.main(defaultTest="test_suite") zope.app.server-3.6.0/src/zope/app/server/tests/test_server.py0000644000177100020040000000641211542403742024365 0ustar menesismenesis############################################################################## # # Copyright (c) 2005 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. # ############################################################################## """Tests for zope.app.server.server """ import unittest import doctest from zope.interface.verify import verifyObject from zope.component import provideUtility from zope.app.testing import setup def doctest_ServerFactory(): r"""Tests for ServerFactory Zope 3 has many server types -- HTTP, FTP, HTTP with postmortem debugging, etc. All of them are registered as IServerType utilities in ZCML. >>> setup.placelessSetUp() >>> from zope.interface import implements >>> from zope.app.server.servertype import IServerType >>> class MyServerType: ... implements(IServerType) ... def create(self, name, task_dispatcher, db, port='unknown', ... verbose='unspecified', ip=''): ... if not ip: ... ip = '*' # listen on all interfaces ... return ('%s server on %s:%d, registered with %s,\n' ... 'serving from %s, verbosity %s' ... % (name, ip, port, task_dispatcher, db, verbose)) >>> provideUtility(MyServerType(), IServerType, name='HTTP') >>> provideUtility(MyServerType(), IServerType, name='FTP') ServerFactory is used to hook into ZConfig and create instances of servers specified in zope.conf. It gets a `section` argument that contains settings specified in a ZConfig section. >>> class ServerSectionStub: ... type = 'HTTP' ... address = ('', 8080) ... verbose = False >>> my_section = ServerSectionStub() >>> from zope.app.server.server import ServerFactory >>> sf = ServerFactory(my_section) The server factory object knows how to create a server, given a task dispatcher (see IDispatcher from zope.server.interfaces) and a ZODB database object. >>> task_dispatcher = 'my task dispatcher' >>> db = 'my db' >>> print sf.create(task_dispatcher, db) HTTP server on *:8080, registered with my task dispatcher, serving from my db, verbosity False The settings actually work >>> my_section.type = 'FTP' >>> my_section.address = ('127.0.0.1', 8021) >>> my_section.verbose = True >>> sf = ServerFactory(my_section) >>> print sf.create(task_dispatcher, db) FTP server on 127.0.0.1:8021, registered with my task dispatcher, serving from my db, verbosity True That's it. >>> setup.placelessTearDown() """ def test_suite(): return unittest.TestSuite(( doctest.DocTestSuite(), )) if __name__ == '__main__': unittest.main(defaultTest='test_suite') zope.app.server-3.6.0/src/zope/app/server/tests/test_ftp.py0000644000177100020040000000236011542403742023646 0ustar menesismenesis############################################################################## # # Copyright (c) 2004 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. # ############################################################################## """Doc tests for the FTP server. """ import unittest class Tests(unittest.TestCase): def test_ftp(self): from ZODB.tests.util import DB from zope.app.server.ftp import FTPRequestFactory from cStringIO import StringIO db = DB() factory = FTPRequestFactory(db) request = factory(StringIO(''), {'credentials': None, 'path': '/'}) self.assertTrue(request.publication.db is db) db.close() def test_suite(): loader = unittest.TestLoader() return loader.loadTestsFromTestCase(Tests) if __name__ == '__main__': unittest.main(defaultTest='test_suite') zope.app.server-3.6.0/src/zope/app/server/tests/site.zcml0000644000177100020040000000006511542403742023277 0ustar menesismenesis zope.app.server-3.6.0/src/zope/app/server/tests/test_accesslog.py0000644000177100020040000000531611542403742025024 0ustar menesismenesis############################################################################## # # Copyright (c) 2004 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. # ############################################################################## """Tests for zope.app.server.accesslog. """ import logging import unittest from ZConfig.components.logger import loghandler from ZConfig.components.logger.tests import test_logger class TestAccessLogging(test_logger.LoggingTestBase): name = "accesslog" _schematext = """
""" def test_config_without_logger(self): conf = self.get_config("") self.assert_(conf.accesslog is None) def test_config_without_handlers(self): logger = self.check_simple_logger("") # Make sure there's a NullHandler, since a warning gets # printed if there are no handlers: self.assertEqual(len(logger.handlers), 1) self.assert_(isinstance(logger.handlers[0], loghandler.NullHandler)) def test_formatter(self): logger = self.check_simple_logger("\n" " \n" " level error\n" " facility local3\n" " format xyzzy\n" " \n" "") self.assertEqual(len(logger.handlers), 1) syslog = logger.handlers[0] self.assertEqual(syslog.level, logging.ERROR) self.assert_(isinstance(syslog, loghandler.SysLogHandler)) self.assertEqual(syslog.formatter._fmt, "%(message)s") def check_simple_logger(self, text): conf = self.get_config(text) self.assert_(conf.accesslog is not None) logger = conf.accesslog() self.assert_(isinstance(logger, logging.Logger)) self.assert_(not logger.propagate) self.assertEquals(logger.name, "accesslog") self.assertEquals(logger.level, logging.INFO) return logger def test_suite(): return unittest.makeSuite(TestAccessLogging) zope.app.server-3.6.0/src/zope/app/server/tests/test_servertype.py0000644000177100020040000001216111542403742025265 0ustar menesismenesis############################################################################## # # Copyright (c) 2005 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. # ############################################################################## """Tests for zope.app.server.servertype """ import unittest import doctest from zope.interface.verify import verifyObject def doctest_ServerType(): r"""Tests for ServerType Zope 3 has many server types -- HTTP, FTP, HTTP with postmortem debugging, etc. All of them are registered as IServerType utilities in ZCML. ServerType is an implementation of IServerType. The constructor of ServerType takes quite a few arguments, a number of which are factories. We will use stubs of those. The 'factory' argument specifies the server factory (e.g. PublisherHTTPServer from zope.server.http.httpserver) >>> def factory(request_factory, name, ip, port, ... task_dispatcher=None, hit_log=None, verbose=False): ... if ip == '': ... ip = '*' # listen on all network interfaces ... print "Starting a server (%s) on %s:%d" % (name, ip, port) ... print "This server will use %s to construct requests" % \ ... request_factory ... print "This server will use %s for hit logging" % hit_log ... if verbose: ... print "This server will be verbose" ... else: ... print "This server will not be verbose" ... print "This server will be managed by %s" % task_dispatcher The 'requestFactory' argument specifies a function that returns a factory for requests (e.g. HTTPPublicationRequestFactory from zope.server.http.publisherhttpserver). It is, in fact, a request factory factory. >>> def requestFactory(db): ... return 'my request factory for %s' % db The 'logFactory' argument specifies the factory for an access logger (e.g. CommonAccessLogger from zope.server.http.commonaccesslogger). >>> def logFactory(): ... return 'my logger' The 'defaultPort' argument specifies the default TCP port number for the server. The 'defaultVerbose' argument specifies the default verbosity. The 'defaultIP' argument specifies the network interface for listening on. You can specify the network interface IP address, or an empty string if you want to listen on all interfaces. >>> from zope.app.server.servertype import IServerType >>> from zope.app.server.servertype import ServerType >>> st = ServerType(factory, requestFactory, logFactory, ... defaultPort=8080, defaultVerbose=False) >>> verifyObject(IServerType, st) True A server type is then registered as a named utility. These utilities are used while interpreting sections of zope.conf to create instances of servers listening on a specific port. When you create an instance of a server, you need to tell it the task dispatcher (see IDispatcher in zope.server.interfaces), and the ZODB database object. The `name` argument to create is, as far as I can tell, purely informative. It is used to construct a server identifier that appears in log files and, for example, the 'Server' HTTP header. >>> dispatcher = 'my task dispatcher' >>> db = 'my database' >>> st.create('Sample Server', dispatcher, db) Starting a server (Sample Server) on *:8080 This server will use my request factory for my database to construct requests This server will use my logger for hit logging This server will not be verbose This server will be managed by my task dispatcher You can, of course, create multiple instances of the same server type, and bind them to different ports. >>> st.create('Sample Server 2', dispatcher, db, port=1234, verbose=True) Starting a server (Sample Server 2) on *:1234 This server will use my request factory for my database to construct requests This server will use my logger for hit logging This server will be verbose This server will be managed by my task dispatcher >>> st.create('Sample Server 3', dispatcher, db, port=9090, ... ip='127.0.0.1') Starting a server (Sample Server 3) on 127.0.0.1:9090 This server will use my request factory for my database to construct requests This server will use my logger for hit logging This server will not be verbose This server will be managed by my task dispatcher """ def test_suite(): return doctest.DocTestSuite() if __name__ == '__main__': unittest.main(defaultTest='test_suite') zope.app.server-3.6.0/src/zope/app/server/zopeskel/0000755000177100020040000000000011542403754022140 5ustar menesismenesiszope.app.server-3.6.0/src/zope/app/server/zopeskel/etc/0000755000177100020040000000000011542403754022713 5ustar menesismenesiszope.app.server-3.6.0/src/zope/app/server/zopeskel/etc/zope.conf.in0000644000177100020040000000367111542403742025150 0ustar menesismenesis# This is the configuration file for the Zope Application Server. %define INSTANCE <> %define CONFDIR $INSTANCE/etc %define DATADIR $INSTANCE/var %define LOGDIR $INSTANCE/log # identify the component configuration used to define the site: # site-definition $INSTANCE/etc/site.zcml # number of bytecode instructions to execute between checks for # interruptions (SIGINTR, thread switches): # interrupt-check-interval 200 type WSGI-HTTP address 8080 # For debugging purposes, you can use this publisher instead/as well # (obviously if it's as well, use a different port number). If there's # an exception, Zope will drop into pdb at the point of the exception. # # # type WSGI-PostmortemDebuggingHTTP # address 8080 # # uncomment this if you want the FTP server up and running # # type FTP # address 8021 # # Standard Filestorage path $DATADIR/Data.fs # uncomment this if you want to connect to a local ZEO server # instead: # # server localhost:9999 # 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 (access.log) and to standard # output (STDOUT). The "path" setting can be a relative or absolute # filesystem path or the tokens STDOUT or STDERR. path $LOGDIR/access.log path STDOUT # 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 $LOGDIR/z3.log path STDOUT # devmode # # Switches the Developer Mode on and off. # # Default: # devmode on # #devmode off zope.app.server-3.6.0/src/zope/app/server/zopeskel/bin/0000755000177100020040000000000011542403754022710 5ustar menesismenesiszope.app.server-3.6.0/src/zope/app/server/zopeskel/bin/debugzope.in0000755000177100020040000000304711542403742025230 0ustar menesismenesis#!<> -i ############################################################################## # # Copyright (c) 2004 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. # ############################################################################## """Script to run the Zope Application Server from the Python prompt. """ import os import sys SOFTWARE_HOME = r"<>" INSTANCE_HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) CONFIG_FILE = os.path.join(INSTANCE_HOME, "etc", "zope.conf") def startup(): # This removes the script directory from sys.path, which we do # since there are no modules here. # basepath = filter(None, sys.path) sys.path[:] = [os.path.join(INSTANCE_HOME, "lib", "python"), SOFTWARE_HOME] + basepath from zope.app.server.main import debug db = debug(["-C", CONFIG_FILE] + sys.argv[1:]) if "PYTHONSTARTUP" in os.environ: execfile(os.environ["PYTHONSTARTUP"]) return db if __name__ == '__main__': db = startup() del startup from zope.app.debug import Debugger debugger = app = Debugger.fromDatabase(db) del db del Debugger zope.app.server-3.6.0/src/zope/app/server/zopeskel/bin/runzope.in0000755000177100020040000000300011542403742024733 0ustar menesismenesis#!<> ############################################################################## # # Copyright (c) 2004 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. # ############################################################################## """Script to run the Zope Application Server in the foreground. """ import os import sys SOFTWARE_HOME = r"<>" INSTANCE_HOME = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) CONFIG_FILE = os.path.join(INSTANCE_HOME, "etc", "zope.conf") def run(): 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) # This removes the script directory from sys.path, which we do # since there are no modules here. # basepath = filter(None, sys.path) sys.path[:] = [os.path.join(INSTANCE_HOME, "lib", "python"), SOFTWARE_HOME] + basepath from zope.app.server.main import main main(["-C", CONFIG_FILE] + sys.argv[1:]) if __name__ == '__main__': run() zope.app.server-3.6.0/src/zope/app/server/schema.xml0000644000177100020040000000324011542403742022262 0ustar menesismenesis
Configuration for the access log.
Value passed to Python's sys.setcheckinterval() function. This integer value determines how often the interpreter checks for periodic things such as thread switches and signal handlers. Setting it to a larger value may increase performance for programs using threads. Setting it to a value <= 0 checks every virtual instruction, maximizing responsiveness as well as overhead. The number of threads which should be used to serve requests. The threads are placed in a pool and are used to serve requests received from the servers configured using <server> sections. This does not constrain the total number of threads used by the application server; additional threads may be used for internal purposes.
zope.app.server-3.6.0/buildout.cfg0000644000177100020040000000132411542403742016757 0ustar menesismenesis[buildout] develop = . parts = test zope [test] recipe = zc.recipe.testrunner eggs = zope.app.server [test] [app] servers = zserver recipe = zc.zope3recipes:application eggs = zope.app.zcmlfiles zope.app.server zope.app.securitypolicy site.zcml = [zope] recipe = zc.zope3recipes:instance application = app zope.conf =