zope.hookable-3.4.1/0000755000175000017500000000000011166144740014167 5ustar tseavertseaverzope.hookable-3.4.1/README.txt0000644000175000017500000000101511153575332015663 0ustar tseavertseaverzope.hookable Package Readme ============================ Overview -------- Hookable object support. Support the efficient creation of hookable objects, which are callable objects that are meant to be replaced by other callables, at least optionally. The idea is you create a function that does some default thing and make it hookable. Later, someone can modify what it does by calling its sethook method and changing its implementation. All users of the function, including those that imported it, will see the change. zope.hookable-3.4.1/CHANGES.txt0000644000175000017500000000037111166144555016005 0ustar tseavertseaverCHANGES ======= 3.4.1 (2009-04-05) ------------------ - Updated tests for compatibility with Python 2.6 traceback formats. - Use Jython-compatible ``bootstrap.py``. 3.4.0 (2007-07-20) ------------------ - Initial release as a separate project. zope.hookable-3.4.1/src/0000755000175000017500000000000011166144740014756 5ustar tseavertseaverzope.hookable-3.4.1/src/zope.hookable.egg-info/0000755000175000017500000000000011166144740021210 5ustar tseavertseaverzope.hookable-3.4.1/src/zope.hookable.egg-info/namespace_packages.txt0000644000175000017500000000000511166144740025536 0ustar tseavertseaverzope zope.hookable-3.4.1/src/zope.hookable.egg-info/dependency_links.txt0000644000175000017500000000000111166144740025256 0ustar tseavertseaver zope.hookable-3.4.1/src/zope.hookable.egg-info/SOURCES.txt0000644000175000017500000000110111166144740023065 0ustar tseavertseaverCHANGES.txt README.txt bootstrap.py buildout.cfg setup.py src/zope/__init__.py src/zope.hookable.egg-info/PKG-INFO src/zope.hookable.egg-info/SOURCES.txt src/zope.hookable.egg-info/dependency_links.txt src/zope.hookable.egg-info/namespace_packages.txt src/zope.hookable.egg-info/not-zip-safe src/zope.hookable.egg-info/requires.txt src/zope.hookable.egg-info/top_level.txt src/zope/hookable/DEPENDENCIES.cfg src/zope/hookable/SETUP.cfg src/zope/hookable/__init__.py src/zope/hookable/_zope_hookable.c src/zope/hookable/tests/__init__.py src/zope/hookable/tests/test_hookable.pyzope.hookable-3.4.1/src/zope.hookable.egg-info/top_level.txt0000644000175000017500000000000511166144740023735 0ustar tseavertseaverzope zope.hookable-3.4.1/src/zope.hookable.egg-info/not-zip-safe0000644000175000017500000000000111153577604023443 0ustar tseavertseaver zope.hookable-3.4.1/src/zope.hookable.egg-info/requires.txt0000644000175000017500000000003711166144740023610 0ustar tseavertseaversetuptools [test] zope.testingzope.hookable-3.4.1/src/zope.hookable.egg-info/PKG-INFO0000644000175000017500000000042111166144740022302 0ustar tseavertseaverMetadata-Version: 1.0 Name: zope.hookable Version: 3.4.1 Summary: Zope hookable Home-page: http://svn.zope.org/zope.hookable Author: Zope Corporation and Contributors Author-email: zope3-dev@zope.org License: ZPL 2.1 Description: Hookable object support. Platform: UNKNOWN zope.hookable-3.4.1/src/zope/0000755000175000017500000000000011166144740015733 5ustar tseavertseaverzope.hookable-3.4.1/src/zope/__init__.py0000644000175000017500000000007011166144353020041 0ustar tseavertseaver__import__('pkg_resources').declare_namespace(__name__) zope.hookable-3.4.1/src/zope/hookable/0000755000175000017500000000000011166144740017517 5ustar tseavertseaverzope.hookable-3.4.1/src/zope/hookable/DEPENDENCIES.cfg0000644000175000017500000000001511153575332022023 0ustar tseavertseaverzope.testing zope.hookable-3.4.1/src/zope/hookable/_zope_hookable.c0000644000175000017500000001423311153575332022647 0ustar tseavertseaver/*############################################################################ # # Copyright (c) 2003 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. # ############################################################################*/ #define _ZOPE_HOOKABLE_C "$Id: _zope_hookable.c 25177 2004-06-02 13:17:31Z jim $\n" /* _zope_hookable.c Provide an efficient implementation for hookable objects */ #include "Python.h" #include "structmember.h" typedef struct { PyObject_HEAD PyObject *old; PyObject *implementation; } hookable; static int hookable_init(hookable *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"implementation", NULL}; PyObject *implementation; if (! PyArg_ParseTupleAndKeywords(args, kwds, "O:hookable", kwlist, &implementation)) return -1; Py_INCREF(implementation); Py_INCREF(implementation); Py_XDECREF(self->old); self->old = implementation; Py_XDECREF(self->implementation); self->implementation = implementation; return 0; } static int hookable_traverse(hookable *self, visitproc visit, void *arg) { if (self->implementation != NULL && visit(self->implementation, arg) < 0) return -1; if (self->old != NULL && self->old != self->implementation && visit(self->old, arg) < 0 ) return -1; return 0; } static int hookable_clear(hookable *self) { Py_XDECREF(self->old); self->old = NULL; Py_XDECREF(self->implementation); self->implementation = NULL; return 0; } static void hookable_dealloc(hookable *self) { PyObject_GC_UnTrack((PyObject *)self); Py_XDECREF(self->old); Py_XDECREF(self->implementation); self->ob_type->tp_free((PyObject*)self); } static PyObject * hookable_sethook(hookable *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"implementation:sethook", NULL}; PyObject *implementation, *old; if (! PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &implementation)) return NULL; old = self->implementation; Py_INCREF(implementation); self->implementation = implementation; if (old == NULL) { Py_INCREF(Py_None); return Py_None; } return old; } static PyObject * hookable_reset(hookable *self) { Py_XINCREF(self->old); Py_XDECREF(self->implementation); self->implementation = self->old; Py_INCREF(Py_None); return Py_None; } static struct PyMethodDef hookable_methods[] = { {"sethook", (PyCFunction)hookable_sethook, METH_KEYWORDS, "Set the hook implementation for the hookable object"}, {"reset", (PyCFunction)hookable_reset, METH_NOARGS, "Reset the hook to the original value"}, {NULL, NULL} /* sentinel */ }; static PyObject * hookable_call(hookable *self, PyObject *args, PyObject *kw) { if (self->implementation != NULL) return PyObject_Call(self->implementation, args, kw); PyErr_SetString(PyExc_TypeError, "Hookable has no implementation"); return NULL; } static PyMemberDef hookable_members[] = { { "original", T_OBJECT_EX, offsetof(hookable, old), RO }, { "implementation", T_OBJECT_EX, offsetof(hookable, implementation), RO }, {NULL} /* Sentinel */ }; static char Hookabletype__doc__[] = "Callable objects that support being overridden" ; static PyTypeObject hookabletype = { PyObject_HEAD_INIT(NULL) /* ob_size */ 0, /* tp_name */ "zope.hookable." "hookable", /* tp_basicsize */ sizeof(hookable), /* tp_itemsize */ 0, /* tp_dealloc */ (destructor)&hookable_dealloc, /* tp_print */ (printfunc)0, /* tp_getattr */ (getattrfunc)0, /* tp_setattr */ (setattrfunc)0, /* tp_compare */ (cmpfunc)0, /* tp_repr */ (reprfunc)0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ (hashfunc)0, /* tp_call */ (ternaryfunc)hookable_call, /* tp_str */ (reprfunc)0, /* tp_getattro */ (getattrofunc)0, /* tp_setattro */ (setattrofunc)0, /* tp_as_buffer */ 0, /* tp_flags */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_doc */ Hookabletype__doc__, /* tp_traverse */ (traverseproc)hookable_traverse, /* tp_clear */ (inquiry)hookable_clear, /* tp_richcompare */ (richcmpfunc)0, /* tp_weaklistoffset */ (long)0, /* tp_iter */ (getiterfunc)0, /* tp_iternext */ (iternextfunc)0, /* tp_methods */ hookable_methods, /* tp_members */ hookable_members, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* internal use */ /* tp_descr_get */ (descrgetfunc)0, /* tp_descr_set */ (descrsetfunc)0, /* tp_dictoffset */ 0, /* tp_init */ (initproc)hookable_init, /* tp_alloc */ (allocfunc)0, /* tp_new */ (newfunc)0 /*PyType_GenericNew*/, /* tp_free */ 0/*_PyObject_GC_Del*/, }; static struct PyMethodDef zch_methods[] = { {NULL, (PyCFunction)NULL, 0, NULL} /* sentinel */ }; #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ #define PyMODINIT_FUNC void #endif PyMODINIT_FUNC init_zope_hookable(void) { PyObject *m; hookabletype.tp_new = PyType_GenericNew; hookabletype.tp_free = _PyObject_GC_Del; if (PyType_Ready(&hookabletype) < 0) return; m = Py_InitModule3("_zope_hookable", zch_methods, "Provide an efficient implementation for hookable objects" ); if (m == NULL) return; if (PyModule_AddObject(m, "hookable", (PyObject *)&hookabletype) < 0) return; } zope.hookable-3.4.1/src/zope/hookable/__init__.py0000644000175000017500000000467711153607347021651 0ustar tseavertseaver############################################################################## # # Copyright (c) 2003 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. # ############################################################################## """Hookable object support Support the efficient creation of hookable objects, which are callable objects that are meant to be replaced by other callables, at least optionally. The idea is you create a function that does some default thing and make it hookable. Later, someone can modify what it does by calling its sethook method and changing its implementation. All users of the function, including those that imported it, will see the change. >>> def f41(): ... return 41 >>> f = hookable(f41) >>> int(f.implementation is f.original) 1 >>> f() 41 >>> old = f.sethook(lambda: 42) >>> int(f.implementation is f.original) 0 >>> int(old is f41) 1 >>> f() 42 >>> f.original() 41 >>> f.implementation() 42 >>> f.reset() >>> f() 41 >>> del f.original Traceback (most recent call last): ... TypeError: readonly attribute >>> del f.implementation Traceback (most recent call last): ... TypeError: readonly attribute Some error cases. >>> g = hookable() # not enough args Traceback (most recent call last): ... TypeError: hookable() takes exactly 1 argument (0 given) >>> g = hookable(f, f) # too many args Traceback (most recent call last): ... TypeError: hookable() takes exactly 1 argument (2 given) >>> g = hookable(implementation=f) # OK, but not advertised >>> g = hookable(f, madeupkeywordname=f) # bad kw name Traceback (most recent call last): ... TypeError: 'madeupkeywordname' is an invalid keyword argument for this function $Id: __init__.py 70897 2006-10-24 08:21:55Z flox $ """ __docformat__ = 'restructuredtext' from _zope_hookable import * # DocTest: if __name__ == "__main__": import doctest, __main__ doctest.testmod(__main__, isprivate=lambda *a: False) zope.hookable-3.4.1/src/zope/hookable/SETUP.cfg0000644000175000017500000000014511153575332021101 0ustar tseavertseaver# Extension information for zpkg. source _zope_hookable.c zope.hookable-3.4.1/src/zope/hookable/tests/0000755000175000017500000000000011166144740020661 5ustar tseavertseaverzope.hookable-3.4.1/src/zope/hookable/tests/__init__.py0000644000175000017500000000005711153575332022775 0ustar tseavertseaver# This line required to prevent an empty file. zope.hookable-3.4.1/src/zope/hookable/tests/test_hookable.py0000644000175000017500000000213111153643170024050 0ustar tseavertseaver############################################################################## # # Copyright (c) 2003 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. # ############################################################################## """Test the hookable support Extension $Id: test_hookable.py 97509 2009-03-05 03:26:48Z tseaver $ """ from zope.testing.doctest import ELLIPSIS from zope.testing.doctest import IGNORE_EXCEPTION_DETAIL from zope.testing.doctestunit import DocTestSuite def test_suite(): return DocTestSuite('zope.hookable', optionflags=ELLIPSIS|IGNORE_EXCEPTION_DETAIL, ) if __name__ == '__main__': import unittest unittest.main() zope.hookable-3.4.1/setup.cfg0000644000175000017500000000007311166144740016010 0ustar tseavertseaver[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 zope.hookable-3.4.1/bootstrap.py0000644000175000017500000000426311153575332016564 0ustar tseavertseaver############################################################################## # # Copyright (c) 2006 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. # ############################################################################## """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. $Id: bootstrap.py 90495 2008-08-27 23:21:30Z georgyberdyshev $ """ 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 is_jython = sys.platform.startswith('java') if is_jython: import subprocess 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 if is_jython: assert subprocess.Popen( [sys.executable] + ['-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout'], env = dict(os.environ, PYTHONPATH = ws.find(pkg_resources.Requirement.parse('setuptools')).location ), ).wait() == 0 else: 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.hookable-3.4.1/PKG-INFO0000644000175000017500000000042111166144740015261 0ustar tseavertseaverMetadata-Version: 1.0 Name: zope.hookable Version: 3.4.1 Summary: Zope hookable Home-page: http://svn.zope.org/zope.hookable Author: Zope Corporation and Contributors Author-email: zope3-dev@zope.org License: ZPL 2.1 Description: Hookable object support. Platform: UNKNOWN zope.hookable-3.4.1/setup.py0000644000175000017500000000311411166144713015700 0ustar tseavertseaver############################################################################## # # Copyright (c) 2006 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. # ############################################################################## """Setup for zope.hookable package $Id: setup.py 98877 2009-04-05 15:10:06Z tseaver $ """ import os from setuptools import setup, find_packages, Extension setup(name='zope.hookable', version = '3.4.1', url='http://svn.zope.org/zope.hookable', license='ZPL 2.1', description='Zope hookable', author='Zope Corporation and Contributors', author_email='zope3-dev@zope.org', long_description="Hookable object support.", packages=find_packages('src'), package_dir = {'': 'src'}, ext_modules=[Extension("zope.hookable._zope_hookable", [os.path.join('src', 'zope', 'hookable', "_zope_hookable.c") ]), ], namespace_packages=['zope',], extras_require=dict(test=['zope.testing']), install_requires=['setuptools'], include_package_data = True, zip_safe = False, ) zope.hookable-3.4.1/buildout.cfg0000644000175000017500000000013711153575332016501 0ustar tseavertseaver[buildout] develop = . parts = test [test] recipe = zc.recipe.testrunner eggs = zope.hookable