vendor/zasync/1.1

changeset 48:790ced9e1fe8 1.1-nux

Works with Zope2.9.x now
author rspivak
date Fri, 15 Feb 2008 00:05:04 +0000
parents 94f6fc3359b5
children 4448a058c260
files CHANGES bucketqueue.py client/zasync/config.py client/zasync/schema.xml
diffstat 4 files changed, 83 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/CHANGES
     1.2 +++ b/CHANGES
     1.3 @@ -3,7 +3,7 @@
     1.4  -
     1.5  New features:
     1.6  ~~~~~~~~~~~~~
     1.7 --
     1.8 +- Works with Zope2.9.x now
     1.9  Bug fixes:
    1.10  ~~~~~~~~~~
    1.11  - Added the missing "instancehome" configuration directive and better
     2.1 --- a/bucketqueue.py
     2.2 +++ b/bucketqueue.py
     2.3 @@ -6,6 +6,7 @@
     2.4  
     2.5  from time import time as _time, sleep as _sleep
     2.6  import sets
     2.7 +import sys
     2.8  try:
     2.9      import thread
    2.10  except ImportError:
    2.11 @@ -20,12 +21,17 @@
    2.12      unblocked buckets, order is also honored.
    2.13      """
    2.14      def __init__(self, maxsize=0):
    2.15 +        Queue.__init__(self, maxsize)
    2.16 +        self._bucketsema = {} # bucket name to bucket semaphore
    2.17 +        self._threadbucket = {} # thread id to bucket name
    2.18          # in Queue, fsema presumably stands for (not) full semaphore, and esema
    2.19          # stands for (not) empty semaphore.  For us, esema will mean "primed"
    2.20          # or "available" semaphore.
    2.21 -        Queue.__init__(self, maxsize)
    2.22 -        self._bucketsema = {} # bucket name to bucket semaphore
    2.23 -        self._threadbucket = {} # thread id to bucket name
    2.24 +        # Handle change in Queue.py module
    2.25 +        if sys.version_info[:2] >= (2, 4):
    2.26 +            self.fsema = thread.allocate_lock()
    2.27 +            self.esema = thread.allocate_lock()
    2.28 +            self.esema.acquire()
    2.29  
    2.30      def primed(self):
    2.31          """Return True if the queue is primed, False otherwise (not reliable!).
     3.1 --- a/client/zasync/config.py
     3.2 +++ b/client/zasync/config.py
     3.3 @@ -20,6 +20,12 @@
     3.4  
     3.5  specified_version = None
     3.6  
     3.7 +try:
     3.8 +    # Zope-2.9.x
     3.9 +    from Zope2.Startup.handlers import *
    3.10 +except ImportError:
    3.11 +    pass
    3.12 +
    3.13  def root_handler(config):
    3.14      """Set up the environment and generally do almost everything;
    3.15      this was combined from datatypes and configs in Zope gradually as
    3.16 @@ -229,7 +235,14 @@
    3.17                  raise ConfigurationError(dup_err % (mount_points[point],
    3.18                                                      name, point))
    3.19              mount_points[point] = name
    3.20 -    from DBTab.DBTab import DBTab
    3.21 +
    3.22 +    try:
    3.23 +        # Zope-2.9.x
    3.24 +        from Zope2.Startup.datatypes import DBTab
    3.25 +    except ImportError:
    3.26 +        # <= Zope-2.8.x
    3.27 +        from DBTab.DBTab import DBTab
    3.28 +
    3.29      section.dbtab = DBTab(mount_factories, mount_points)
    3.30  
    3.31      s = sets.Set()
    3.32 @@ -288,12 +301,15 @@
    3.33      # I don't think we can sniff the Zope version safely yet.  If I were not in
    3.34      # a rush, I might try, but an explicit version argument will do the trick.
    3.35      global specified_version
    3.36 -    if version < 2.7 or version >= 2.9:
    3.37 -        raise RuntimeError('zasync only supports Zope 2.7.x and Zope 2.8.x')
    3.38 +    if version < 2.7 or version > 2.9:
    3.39 +        raise RuntimeError('zasync only supports Zope 2.7.x, 2.8.x and 2.9.x')
    3.40 +
    3.41      mydir = os.path.dirname(__file__)
    3.42      specified_version = version
    3.43      if version < 2.8:
    3.44          schema = 'schema27.xml'
    3.45 +    elif version == 2.8:
    3.46 +        schema = 'schema28.xml'
    3.47      else:
    3.48          schema = 'schema.xml'
    3.49      try:
    3.50 @@ -305,5 +321,11 @@
    3.51          raise
    3.52      if conffile is None: conffile = sys.argv[1]
    3.53      conf, handler = ZConfig.loadConfig(schema, conffile)
    3.54 -    handler({'root_handler':root_handler})
    3.55 +    handlers = {'root_handler':root_handler}
    3.56 +    if version == 2.9:
    3.57 +        handlers['rest_output_encoding'] =  rest_output_encoding
    3.58 +        handlers['rest_input_encoding'] = rest_input_encoding
    3.59 +        handlers['rest_header_level'] = rest_header_level
    3.60 +        handlers['rest_language_code'] = rest_language_code
    3.61 +    handler(handlers)
    3.62      return conf
     4.1 --- a/client/zasync/schema.xml
     4.2 +++ b/client/zasync/schema.xml
     4.3 @@ -20,6 +20,9 @@
     4.4    <import package="ZODB"/>
     4.5    <import package="tempstorage" />
     4.6  
     4.7 +  <!-- for Zope 2.9 -->
     4.8 +
     4.9 +
    4.10    <sectiontype name="plugin" datatype="zasync.config.plugin">
    4.11      <description>
    4.12      Register zasync plugins.
    4.13 @@ -110,7 +113,9 @@
    4.14                datatype=".mount_point">
    4.15        <description>
    4.16         The mount point is the slash-separated path to which this database
    4.17 -       will be mounted within the Zope application server.
    4.18 +       will be mounted within the Zope application server. If the path
    4.19 +       on the ZEO server is different from the path of the mount point then
    4.20 +       you can use a notation "path_on_client:path_on_zeo_server".
    4.21        </description>
    4.22      </multikey>
    4.23  
    4.24 @@ -123,7 +128,7 @@
    4.25      </key>
    4.26  
    4.27     <key name="class-factory" datatype=".importable_name"
    4.28 -        default="DBTab.ClassFactories.autoClassFactory">
    4.29 +        default="Zope2.Startup.datatypes.zopeClassFactory">
    4.30        <description>
    4.31         Change the class factory function a database uses on a
    4.32         per-database basis to support different class factory policy.
    4.33 @@ -141,6 +146,7 @@
    4.34  
    4.35    </sectiontype>
    4.36  
    4.37 +
    4.38    <!-- end sectiontype defs, begin section and key defs -->
    4.39  
    4.40    <section type="environment" attribute="environment" name="*">
    4.41 @@ -253,6 +259,45 @@
    4.42       <metadefault>off</metadefault>
    4.43    </key>
    4.44  
    4.45 +  <!-- For Zope-2.9 -->
    4.46 +
    4.47 +  <key name="rest-output-encoding" handler="rest_output_encoding">
    4.48 +    <description>
    4.49 +    Specifies the output encoding of re-StructuredText documents
    4.50 +    (e.g. 'utf-8', 'iso-8859' or any other valid encoding recognized
    4.51 +    by Python).  The default is your Python's default encoding.
    4.52 +    </description>
    4.53 +    <metadefault>unset</metadefault>
    4.54 +  </key>
    4.55 +  <key name="rest-input-encoding" handler="rest_input_encoding">
    4.56 +    <description>
    4.57 +      Specifies the input encoding of re-StructuredText documents
    4.58 +      (e.g. 'utf-8', 'iso-8859' or any other valid encoding recognized
    4.59 +      by Python).  The default is your Python's default encoding.
    4.60 +    </description>
    4.61 +    <metadefault>unset</metadefault>
    4.62 +  </key>
    4.63 +   <key name="rest-header-level" datatype="integer" default="3"
    4.64 +       handler="rest_header_level">
    4.65 +    <description>
    4.66 +     Set the default starting HTML header level for restructured text
    4.67 +     documents. The default is 3, which implies that top-level headers
    4.68 +     will be created with an H3 HTML tag.
    4.69 +    </description>
    4.70 +    <metadefault>3</metadefault>
    4.71 +  </key>
    4.72 +  <key name="rest-language-code" handler="rest_language_code" default="en">
    4.73 +    <description>
    4.74 +     Language code used for some internal translations inside of the docutils
    4.75 +     package and for DTD bibliographic elements mapping. See
    4.76 +     lib/python/docutils/languages/ for a list of supported language codes.
    4.77 +    </description>
    4.78 +    <metadefault>en</metadefault>
    4.79 +  </key>
    4.80 +
    4.81 +  <!-- End for Zope-2.9 -->
    4.82 +
    4.83 +
    4.84    <multisection type="ZODB.Database" name="+" attribute="databases">
    4.85      <description>
    4.86         Zope ZODB databases must have a name, and they are required to be