[Python-modules-commits] r10618 - in packages/pylibmc/trunk (33 files)

chaica-guest at users.alioth.debian.org chaica-guest at users.alioth.debian.org
Sat Nov 28 15:52:17 UTC 2009


    Date: Saturday, November 28, 2009 @ 15:52:16
  Author: chaica-guest
Revision: 10618

storing debian/

Added:
  packages/pylibmc/trunk/debian/
  packages/pylibmc/trunk/debian/changelog
  packages/pylibmc/trunk/debian/compat
  packages/pylibmc/trunk/debian/control
  packages/pylibmc/trunk/debian/copyright
  packages/pylibmc/trunk/debian/files
  packages/pylibmc/trunk/debian/python-pylibmc.debhelper.log
  packages/pylibmc/trunk/debian/python-pylibmc.postinst.debhelper
  packages/pylibmc/trunk/debian/python-pylibmc.prerm.debhelper
  packages/pylibmc/trunk/debian/python-pylibmc.substvars
  packages/pylibmc/trunk/debian/python-pylibmc/
  packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/
  packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/control
  packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/md5sums
  packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/postinst
  packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/prerm
  packages/pylibmc/trunk/debian/python-pylibmc/usr/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/lib/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/lib/pyshared/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/lib/pyshared/python2.4/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/lib/pyshared/python2.5/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/doc/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/doc/python-pylibmc/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/doc/python-pylibmc/changelog.Debian.gz
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/doc/python-pylibmc/copyright
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/pyshared/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/pyshared/pylibmc-0.9.2.egg-info
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/pyshared/pylibmc.py
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/python-support/
  packages/pylibmc/trunk/debian/python-pylibmc/usr/share/python-support/python-pylibmc.public
  packages/pylibmc/trunk/debian/rules
  packages/pylibmc/trunk/debian/watch


Property changes on: packages/pylibmc/trunk/debian
___________________________________________________________________
Added: mergeWithUpstream
   + 1

Added: packages/pylibmc/trunk/debian/changelog
===================================================================
--- packages/pylibmc/trunk/debian/changelog	                        (rev 0)
+++ packages/pylibmc/trunk/debian/changelog	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,5 @@
+pylibmc (0.9.2-1) unstable; urgency=low
+
+  * Initial release. (Closes: #556901)
+
+ -- Carl Chenet <chaica at ohmytux.com>  Sat, 28 Nov 2009 16:33:10 +0100

Added: packages/pylibmc/trunk/debian/compat
===================================================================
--- packages/pylibmc/trunk/debian/compat	                        (rev 0)
+++ packages/pylibmc/trunk/debian/compat	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1 @@
+7

Added: packages/pylibmc/trunk/debian/control
===================================================================
--- packages/pylibmc/trunk/debian/control	                        (rev 0)
+++ packages/pylibmc/trunk/debian/control	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,22 @@
+Source: pylibmc
+Section: python
+Priority: optional
+XS-Python-Version: all
+Maintainer: Carl Chenet <chaica at ohmytux.com>
+Uploaders: Debian Python Modules Team <python-modules-team at lists.alioth.debian.org>
+Build-Depends: debhelper (>= 7), libmemcached-dev
+Build-Depends-Indep: python, python-support, python-all-dev
+Standards-Version: 3.8.3
+Homepage: http://pypi.python.org/pypi/pylibmc/
+Vcs-Svn: svn://svn.debian.org/python-modules/packages/pylibmc/trunk
+Vcs-Browser: http://svn.debian.org/viewsvn/python-modules/packages/pylibmc/trunk/
+
+Package: python-pylibmc
+Architecture: any
+Depends: ${misc:Depends}, ${python:Depends}, ${shlibs:Depends}
+Suggests: memcached
+Description: libmemcached wrapper
+ Pylibmc is a Python wrapper around the accompanying C Python
+ extension _pylibmc, which is a wrapper around libmemcached
+ from TangentOrg. It also manages pooling in a multi-threading
+ environment.

Added: packages/pylibmc/trunk/debian/copyright
===================================================================
--- packages/pylibmc/trunk/debian/copyright	                        (rev 0)
+++ packages/pylibmc/trunk/debian/copyright	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,47 @@
+This package was debianized by Chenet Carl <chaica at ohmytux.com> on
+Fri, 13 Feb 2009 11:58:58 +0100.
+
+It was downloaded from http://www.ohmytux.com/belier
+
+Upstream Author: 
+
+    Ludvig Ericson <ludvig at lericson.se>
+
+Copyright: 
+
+    Copyright © 2008 Ludvig Ericson <ludvig at lericson.se>
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+ - Neither the name of the author nor the names of the contributors may
+   be used to endorse or promote products derived from this software without
+   specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS 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 OWNER OR CONTRIBUTORS 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.
+
+The Debian packaging is © 2009, Chenet Carl <chaica at ohmytux.com> and
+is licensed under the GPL-3 or any later version.
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL-3'.
+
+

Added: packages/pylibmc/trunk/debian/files
===================================================================
--- packages/pylibmc/trunk/debian/files	                        (rev 0)
+++ packages/pylibmc/trunk/debian/files	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1 @@
+python-pylibmc_0.9.2-1_i386.deb python optional

Added: packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/control
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/control	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/control	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,16 @@
+Package: python-pylibmc
+Source: pylibmc
+Version: 0.9.2-1
+Architecture: i386
+Maintainer: Carl Chenet <chaica at ohmytux.com>
+Installed-Size: 132
+Depends: python (<< 2.6), python (>= 2.4), python-support (>= 0.90.0), libc6 (>= 2.3.6-6~), libmemcached3 (>= 0.33)
+Suggests: memcached
+Section: python
+Priority: optional
+Homepage: http://pypi.python.org/pypi/pylibmc/
+Description: libmemcached wrapper
+ Pylibmc is a Python wrapper around the accompanying C Python
+ extension _pylibmc, which is a wrapper around libmemcached
+ from TangentOrg. It also manages pooling in a multi-threading
+ environment.

Added: packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/md5sums
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/md5sums	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/md5sums	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,7 @@
+66f69b26fb9d3f849c6ee5a858df29da  usr/lib/pyshared/python2.5/_pylibmc.so
+3c4dbcb55335eae168c06b616f92ef42  usr/lib/pyshared/python2.4/_pylibmc.so
+9b172caa7a4bbbd8163dfb397471cb9b  usr/share/pyshared/pylibmc.py
+1de4dc18a7b8ff2783d504b04fcb3390  usr/share/pyshared/pylibmc-0.9.2.egg-info
+7e32f21355c8f4502ba6d22034185299  usr/share/python-support/python-pylibmc.public
+57b1dcf662981daa5d315ddd50d3dbac  usr/share/doc/python-pylibmc/changelog.Debian.gz
+173ec9286cc6c2d292a33a744a2ded1b  usr/share/doc/python-pylibmc/copyright

Added: packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/postinst
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/postinst	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/postinst	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,7 @@
+#!/bin/sh
+set -e
+# Automatically added by dh_pysupport
+if which update-python-modules >/dev/null 2>&1; then
+	update-python-modules  python-pylibmc.public
+fi
+# End automatically added section


Property changes on: packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/postinst
___________________________________________________________________
Added: svn:executable
   + *

Added: packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/prerm
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/prerm	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/prerm	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,7 @@
+#!/bin/sh
+set -e
+# Automatically added by dh_pysupport
+if which update-python-modules >/dev/null 2>&1; then
+	update-python-modules -c  python-pylibmc.public
+fi
+# End automatically added section


Property changes on: packages/pylibmc/trunk/debian/python-pylibmc/DEBIAN/prerm
___________________________________________________________________
Added: svn:executable
   + *

Added: packages/pylibmc/trunk/debian/python-pylibmc/usr/share/doc/python-pylibmc/changelog.Debian.gz
===================================================================
(Binary files differ)


Property changes on: packages/pylibmc/trunk/debian/python-pylibmc/usr/share/doc/python-pylibmc/changelog.Debian.gz
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: packages/pylibmc/trunk/debian/python-pylibmc/usr/share/doc/python-pylibmc/copyright
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc/usr/share/doc/python-pylibmc/copyright	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc/usr/share/doc/python-pylibmc/copyright	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,47 @@
+This package was debianized by Chenet Carl <chaica at ohmytux.com> on
+Fri, 13 Feb 2009 11:58:58 +0100.
+
+It was downloaded from http://www.ohmytux.com/belier
+
+Upstream Author: 
+
+    Ludvig Ericson <ludvig at lericson.se>
+
+Copyright: 
+
+    Copyright © 2008 Ludvig Ericson <ludvig at lericson.se>
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ - Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright notice,
+   this list of conditions and the following disclaimer in the documentation
+   and/or other materials provided with the distribution.
+
+ - Neither the name of the author nor the names of the contributors may
+   be used to endorse or promote products derived from this software without
+   specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS 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 OWNER OR CONTRIBUTORS 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.
+
+The Debian packaging is © 2009, Chenet Carl <chaica at ohmytux.com> and
+is licensed under the GPL-3 or any later version.
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL-3'.
+
+

Added: packages/pylibmc/trunk/debian/python-pylibmc/usr/share/pyshared/pylibmc-0.9.2.egg-info
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc/usr/share/pyshared/pylibmc-0.9.2.egg-info	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc/usr/share/pyshared/pylibmc-0.9.2.egg-info	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,147 @@
+Metadata-Version: 1.0
+Name: pylibmc
+Version: 0.9.2
+Summary: libmemcached wrapper
+Home-page: http://lericson.blogg.se/code/category/pylibmc.html
+Author: Ludvig Ericson
+Author-email: ludvig at lericson.se
+License: 3-clause BSD <http://www.opensource.org/licenses/bsd-license.php>
+Description: `pylibmc` is a Python wrapper around the accompanying C Python extension
+        `_pylibmc`, which is a wrapper around `libmemcached` from TangentOrg.
+        
+        You have to install `libmemcached` separately, and have your compiler and
+        linker find the include files and libraries.
+        
+        With `libmemcached` installed and this package set up, the following basic
+        usage example should work::
+        
+        >>> import pylibmc
+        >>> mc = pylibmc.Client(["127.0.0.1:11211"])
+        >>> mc.set("foo", "Hello world!")
+        True
+        >>> mc.get("foo")
+        'Hello world!'
+        
+        The API is pretty much `python-memcached`. Some parts of `libmemcached` aren't
+        exposed yet. I think.
+        
+        There's also support for some other features not present in other Python
+        libraries, for example, the binary protocol::
+        
+        >>> mc = pylibmc.Client(["127.0.0.1"], binary=True)
+        
+        That's it, the binary protocol will be used for that instance.
+        
+        Behaviors
+        =========
+        
+        `libmemcached` has ways of telling it how to behave. You'll have to refer to
+        its documentation on what the different behaviors do.
+        
+        To change behaviors, quite simply::
+        
+        >>> mc.behaviors["hash"] = "fnv1a_32"
+        
+        For a list of the defined behavior key names, see what the keys of a client is.
+        For example::
+        
+        >>> mc.behaviors.keys()  # doctest: +NORMALIZE_WHITESPACE
+        ['hash', 'connect timeout', 'cache lookups', 'buffer requests',
+        'verify key', 'support cas', 'poll timeout', 'no block', 'tcp nodelay',
+        'distribution', 'sort hosts']
+        
+        The ``hash`` and ``distribution`` keys are mapped by the Python module to constant
+        integer values used by `libmemcached`. See ``pylibmc.hashers`` and
+        ``pylibmc.distributions``.
+        
+        Pooling
+        =======
+        
+        In multithreaded environments, accessing the same memcached client object is
+        both unsafe and counter-productive in terms of performance. `libmemcached`'s
+        take on this is to introduce pooling on C level, which is correspondingly
+        mapped to pooling on Python level in `pylibmc`::
+        
+        >>> mc = pylibmc.Client(["127.0.0.1"])
+        >>> pool = pylibmc.ThreadMappedPool(mc)
+        >>> # (in a thread...)
+        >>> with pool.reserve() as mc:
+        ...     mc.set("hello", "world")
+        
+        For more information on pooling, see `my two`__ `long posts`__ about it.
+        
+        __ http://lericson.blogg.se/code/2009/september/draft-sept-20-2009.html
+        __ http://lericson.blogg.se/code/2009/september/pooling-with-pylibmc-pt-2.html
+        
+        Comparison to other libraries
+        =============================
+        
+        Why use `pylibmc`? Because it's fast.
+        
+        `See this (a bit old) speed comparison`__, or `amix.dk's comparison`__.
+        
+        __ http://lericson.blogg.se/code/2008/november/pylibmc-051.html
+        __ http://amix.dk/blog/viewEntry/19471
+        
+        IRC
+        ===
+        
+        ``#sendapatch`` on ``chat.freenode.net``.
+        
+        Change Log
+        ==========
+        
+        New in version 0.9
+        ------------------
+        
+        - Added a ``get_stats`` method, which behaves exactly like
+        `python-memcached`'s equivalent.
+        - Gives the empty string for empty memcached values like `python-memcached`
+        does.
+        - Added exceptions for most `libmemcached` return codes.
+        - Fixed an issue with ``Client.behaviors.update``.
+        
+        New in version 0.8
+        ------------------
+        
+        - Pooling helpers are now available. See ``pooling.rst`` in the distribution.
+        - The binary protocol is now properly exposed, simply pass ``binary=True`` to
+        the constructor and there you go.
+        - Call signatures now match `libmemcached` 0.32, but should work with older
+        versions. Remember to run the tests!
+        
+        New in version 0.7
+        ------------------
+        
+        - Restructured some of the code, which should yield better performance (if not
+        for that, it reads better.)
+        - Fixed some memory leaks.
+        - Integrated changes from `amix.dk`, which should make pylibmc work under
+        Snow Leopard.
+        - Add support for the boolean datatype.
+        - Improved test-runner -- now tests ``build/lib.*/_pylibmc.so`` if available,
+        and reports some version information.
+        - Support for x86_64 should now work completely.
+        - Builds with Python 2.4, tests run fine, but not officially supported.
+        - Fixed critical bugs in behavior manipulation.
+        
+        New in version 0.6
+        ------------------
+        
+        - Added compatibility with `libmemcached` 0.26, WRT error return codes.
+        - Added `flush_all` and `disconnect_all` methods.
+        - Now using the latest pickling protocol.
+        
+        New in version 0.5
+        ------------------
+        
+        - Fixed lots of memory leaks, and added support for `libmemcached` 0.23.
+        - Also made the code tighter in terms of compiler pedantics.
+        
+        New in version 0.4
+        ------------------
+        
+        - Renamed the C module to `_pylibmc`, and added lots of `libmemcached` constants
+        to it, as well as implemented behaviors.
+        
+Platform: UNKNOWN

Added: packages/pylibmc/trunk/debian/python-pylibmc/usr/share/pyshared/pylibmc.py
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc/usr/share/pyshared/pylibmc.py	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc/usr/share/pyshared/pylibmc.py	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,212 @@
+"""`python-memcached`-compatible wrapper around `_pylibmc`.
+
+The interface is pretty much exactly the same as python-memcached, with some
+minor differences. If you should happen to spot any, file a bug!
+
+>>> import pylibmc
+>>> mc = pylibmc.Client(["127.0.0.1"])
+>>> b = mc.behaviors
+>>> ks = list(sorted(k for k in b.keys() if not k.startswith("_")))
+>>> ks  # doctest: +NORMALIZE_WHITESPACE
+['buffer_requests', 'cache_lookups', 'connect_timeout', 'distribution', 'hash',
+ 'ketama', 'ketama_hash', 'ketama_weighted', 'no block', 'poll_timeout',
+ 'rcv_timeout', 'retry_timeout', 'server_failure_limit', 'snd_timeout',
+ 'socket recv size', 'socket send size', 'sort_hosts', 'support_cas',
+ 'tcp_nodelay', 'verify_key']
+>>> b["hash"]
+'default'
+>>> b["hash"] = 'fnv1a_32'
+>>> mc.behaviors["hash"]
+'fnv1a_32'
+>>> super(pylibmc.Client, mc).get_behaviors()["hash"]
+6
+"""
+
+import _pylibmc
+
+__all__ = ["hashers", "distributions", "Client"]
+__version__ = _pylibmc.__version__
+
+errors = tuple(e for (n, e) in _pylibmc.exceptions)
+# *Cough* Uhm, not the prettiest of things but this unpacks all exception
+# objects and sets them on the very module object currently constructed.
+import sys
+modself = sys.modules[__name__]
+for name, exc in _pylibmc.exceptions:
+    setattr(modself, name, exc)
+
+hashers, hashers_rvs = {}, {}
+distributions, distributions_rvs = {}, {}
+# Not the prettiest way of doing things, but works well.
+for name in dir(_pylibmc):
+    if name.startswith("hash_"):
+        key, value = name[5:], getattr(_pylibmc, name)
+        hashers[key] = value
+        hashers_rvs[value] = key
+    elif name.startswith("distribution_"):
+        key, value = name[13:].replace("_", " "), getattr(_pylibmc, name)
+        distributions[key] = value
+        distributions_rvs[value] = key
+
+class BehaviorDict(dict):
+    def __init__(self, client, *args, **kwds):
+        super(BehaviorDict, self).__init__(*args, **kwds)
+        self.client = client
+
+    def __setitem__(self, name, value):
+        super(BehaviorDict, self).__setitem__(name, value)
+        self.client.set_behaviors({name: value})
+
+    def update(self, d):
+        super(BehaviorDict, self).update(d)
+        self.client.set_behaviors(d.copy())
+
+class Client(_pylibmc.client):
+    def __init__(self, servers, binary=False):
+        """Initialize a memcached client instance.
+
+        This connects to the servers in *servers*, which will default to being
+        TCP servers. If it looks like a filesystem path, a UNIX socket. If
+        prefixed with `udp:`, a UDP connection.
+
+        If *binary* is True, the binary memcached protocol is used.
+        """
+        addr_tups = []
+        for server in servers:
+            addr = server
+            port = 11211
+            if server.startswith("udp:"):
+                stype = _pylibmc.server_type_udp
+                addr = addr[4:]
+                if ":" in server:
+                    (addr, port) = addr.split(":", 1)
+                    port = int(port)
+            elif ":" in server:
+                stype = _pylibmc.server_type_tcp
+                (addr, port) = server.split(":", 1)
+                port = int(port)
+            elif "/" in server:
+                stype = _pylibmc.server_type_unix
+                port = 0
+            else:
+                stype = _pylibmc.server_type_tcp
+            addr_tups.append((stype, addr, port))
+        super(Client, self).__init__(servers=addr_tups, binary=binary)
+
+    def get_behaviors(self):
+        """Gets the behaviors from the underlying C client instance.
+
+        Reverses the integer constants for `hash` and `distribution` into more
+        understandable string values. See *set_behaviors* for info.
+        """
+        behaviors = super(Client, self).get_behaviors()
+        behaviors["hash"] = hashers_rvs[behaviors["hash"]]
+        behaviors["distribution"] = distributions_rvs[behaviors["distribution"]]
+        return BehaviorDict(self, behaviors)
+
+    def set_behaviors(self, behaviors):
+        """Sets the behaviors on the underlying C client instance.
+
+        Takes care of morphing the `hash` key, if specified, into the
+        corresponding integer constant (which the C client expects.) If,
+        however, an unknown value is specified, it's passed on to the C client
+        (where it most surely will error out.)
+
+        This also happens for `distribution`.
+        """
+        behaviors = behaviors.copy()
+        if behaviors.get("hash") is not None:
+            behaviors["hash"] = hashers[behaviors["hash"]]
+        if behaviors.get("distribution") is not None:
+            behaviors["distribution"] = distributions[behaviors["distribution"]]
+        return super(Client, self).set_behaviors(behaviors)
+
+    behaviors = property(get_behaviors, set_behaviors)
+
+from contextlib import contextmanager
+
+class ClientPool(list):
+    """Client pooling helper.
+
+    This is mostly useful in threaded environments, because a client isn't
+    thread-safe at all. Instead, what you want to do is have each thread use
+    its own client, but you don't want to reconnect these all the time.
+
+    The solution is a pool, and this class is a helper for that.
+
+    >>> mc = Client(["127.0.0.1"])
+    >>> pool = ClientPool()
+    >>> pool.fill(mc, 4)
+    >>> with pool.reserve() as mc:
+    ...     mc.set("hi", "ho")
+    ...     mc.delete("hi")
+    ... 
+    True
+    True
+    """
+
+    @contextmanager
+    def reserve(self):
+        """Reserve a client, and put it back into the pool when done."""
+        mc = self.pop()
+        try:
+            yield mc
+        finally:
+            self.append(mc)
+
+    def fill(self, mc, n_slots):
+        """Fill *n_slots* of the pool with clones of *mc*."""
+        for i in xrange(n_slots):
+            self.append(mc.clone())
+
+class ThreadMappedPool(dict):
+    """Much like the *ClientPool*, helps you with pooling.
+
+    In a threaded environment, you'd most likely want to have a client per
+    thread. And there'd be no harm in one thread keeping the same client at all
+    times. So, why not map threads to clients? That's what this class does.
+
+    If a client is reserved, this class checks for a key based on the current
+    thread, and if none exists, clones the master client and inserts that key.
+
+    >>> mc = Client(["127.0.0.1"])
+    >>> pool = ThreadMappedPool(mc)
+    >>> with pool.reserve() as mc:
+    ...     mc.set("hi", "ho")
+    ...     mc.delete("hi")
+    ... 
+    True
+    True
+    """
+
+    def __new__(cls, master):
+        return super(ThreadMappedPool, cls).__new__(cls)
+
+    def __init__(self, master):
+        self.master = master
+
+    @contextmanager
+    def reserve(self):
+        """Reserve a client.
+
+        Creates a new client based on the master client if none exists for the
+        current thread.
+        """
+        key = thread.get_ident()
+        mc = self.pop(key, None)
+        if mc is None:
+            mc = self.master.clone()
+        try:
+            yield mc
+        finally:
+            self[key] = mc
+
+# This makes sure ThreadMappedPool doesn't exist with non-thread Pythons.
+try:
+    import thread
+except ImportError:
+    del ThreadMappedPool
+
+if __name__ == "__main__":
+    import doctest
+    doctest.testmod()

Added: packages/pylibmc/trunk/debian/python-pylibmc/usr/share/python-support/python-pylibmc.public
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc/usr/share/python-support/python-pylibmc.public	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc/usr/share/python-support/python-pylibmc.public	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,6 @@
+pyversions=2.4,2.5
+
+/usr/lib/pyshared/python2.4/_pylibmc.so
+/usr/lib/pyshared/python2.5/_pylibmc.so
+/usr/share/pyshared/pylibmc-0.9.2.egg-info
+/usr/share/pyshared/pylibmc.py

Added: packages/pylibmc/trunk/debian/python-pylibmc.debhelper.log
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc.debhelper.log	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc.debhelper.log	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,45 @@
+dh_auto_configure
+dh_auto_build
+dh_auto_test
+dh_prep
+dh_installdirs
+dh_auto_install
+dh_install
+dh_installdocs
+dh_installchangelogs
+dh_installexamples
+dh_installman
+dh_installcatalogs
+dh_installcron
+dh_installdebconf
+dh_installemacsen
+dh_installifupdown
+dh_installinfo
+dh_pysupport
+dh_installinit
+dh_installmenu
+dh_installmime
+dh_installmodules
+dh_installlogcheck
+dh_installlogrotate
+dh_installpam
+dh_installppp
+dh_installudev
+dh_installwm
+dh_installxfonts
+dh_bugfiles
+dh_lintian
+dh_gconf
+dh_icons
+dh_perl
+dh_usrlocal
+dh_link
+dh_compress
+dh_fixperms
+dh_strip
+dh_makeshlibs
+dh_shlibdeps
+dh_installdeb
+dh_gencontrol
+dh_md5sums
+dh_builddeb

Added: packages/pylibmc/trunk/debian/python-pylibmc.postinst.debhelper
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc.postinst.debhelper	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc.postinst.debhelper	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,5 @@
+# Automatically added by dh_pysupport
+if which update-python-modules >/dev/null 2>&1; then
+	update-python-modules  python-pylibmc.public
+fi
+# End automatically added section

Added: packages/pylibmc/trunk/debian/python-pylibmc.prerm.debhelper
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc.prerm.debhelper	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc.prerm.debhelper	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,5 @@
+# Automatically added by dh_pysupport
+if which update-python-modules >/dev/null 2>&1; then
+	update-python-modules -c  python-pylibmc.public
+fi
+# End automatically added section

Added: packages/pylibmc/trunk/debian/python-pylibmc.substvars
===================================================================
--- packages/pylibmc/trunk/debian/python-pylibmc.substvars	                        (rev 0)
+++ packages/pylibmc/trunk/debian/python-pylibmc.substvars	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,5 @@
+python:Versions=2.4, 2.5
+python:Provides=python2.4-pylibmc, python2.5-pylibmc
+python:Depends=python (<< 2.6), python (>= 2.4), python-support (>= 0.90.0)
+shlibs:Depends=libc6 (>= 2.1.3), libc6 (>= 2.3.6-6~), libmemcached3 (>= 0.33)
+misc:Depends=

Added: packages/pylibmc/trunk/debian/rules
===================================================================
--- packages/pylibmc/trunk/debian/rules	                        (rev 0)
+++ packages/pylibmc/trunk/debian/rules	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,5 @@
+#!/usr/bin/make -f
+
+%:
+	dh $@
+


Property changes on: packages/pylibmc/trunk/debian/rules
___________________________________________________________________
Added: svn:executable
   + *

Added: packages/pylibmc/trunk/debian/watch
===================================================================
--- packages/pylibmc/trunk/debian/watch	                        (rev 0)
+++ packages/pylibmc/trunk/debian/watch	2009-11-28 15:52:16 UTC (rev 10618)
@@ -0,0 +1,4 @@
+version=3
+http://pypi.python.org/packages/source/p/pylibmc/ pylibmc-(.*)\.tar\.gz
+
+




More information about the Python-modules-commits mailing list