Skip to content

Commit

Permalink
Merge the Zope part of Zope/branches/jim-fix-zclasses.
Browse files Browse the repository at this point in the history
Two of the ZClasses tests are disabled here, because they
run afoul of Zope trunk's security machinery.  Jim needs to look
at them.  A blurb also needs to be added to CHANGES.txt.

Here are checkin msgs from the branch relating to Zope code
(the msgs relating to ZODB code were reproduced in the
ZODB 3.4 branch checkin):

    ------------------------------------------------------------------------
    r29869 | jim | 2005-04-04 07:04:21 -0400 (Mon, 04 Apr 2005) | 6 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.txt

    Added configuration of class factory.

    Use explicit tm for second connection rather than separate thread.

    Added copy test

    ------------------------------------------------------------------------
    r29868 | jim | 2005-04-04 07:03:57 -0400 (Mon, 04 Apr 2005) | 2 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.txt

    Added configuration of class factory.

    ------------------------------------------------------------------------
    r29776 | jim | 2005-04-01 06:24:31 -0500 (Fri, 01 Apr 2005) | 3 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/OFS/tests/testProductInit.py

    Added clean-up code to remove non-exixtent directoris from products
    path.

    ------------------------------------------------------------------------
    r29775 | jim | 2005-04-01 06:24:29 -0500 (Fri, 01 Apr 2005) | 2 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py

    Added missing abourt to tear-down code

    ------------------------------------------------------------------------
    r29772 | jim | 2005-04-01 06:24:22 -0500 (Fri, 01 Apr 2005) | 2 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/App/ApplicationManager.py
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/Basic.py
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.py
       M /Zope/branches/jim-fix-zclasses/lib/python/Zope2/App/startup.py

    Removed BoboPOS compatibility code.

    ------------------------------------------------------------------------
    r29201 | jim | 2005-02-18 07:18:05 -0500 (Fri, 18 Feb 2005) | 3 lines
    Changed paths:
       A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/27.fs
       A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/27.txt
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py

    Added a test for reading ZClasses and their instances from Zope 2.7
    databases.

    ------------------------------------------------------------------------
    r29149 | jim | 2005-02-15 07:24:49 -0500 (Tue, 15 Feb 2005) | 2 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.txt
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py

    Made the tests a bit more thorough.

    ------------------------------------------------------------------------
    r29148 | jim | 2005-02-15 07:24:44 -0500 (Tue, 15 Feb 2005) | 3 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/OFS/tests/testAppInitializer.py

    Made the test cleanup more robust by cleaning up any non-existent
    directories found in Products.__path__.

    ------------------------------------------------------------------------
    r29147 | jim | 2005-02-15 07:24:37 -0500 (Tue, 15 Feb 2005) | 3 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/ExtensionClass.h
       M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/_ExtensionClass.c

    Fixed code that assumed that there weren't subclasses of the
    ExtensionClass meta class.

    ------------------------------------------------------------------------
    r29136 | jim | 2005-02-13 11:37:33 -0500 (Sun, 13 Feb 2005) | 3 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.py
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.txt
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.py
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py

    Integrated persistent metaclass with ZClasses and got basic ZClass
    test to pass.

    ------------------------------------------------------------------------
    r29135 | jim | 2005-02-13 11:15:15 -0500 (Sun, 13 Feb 2005) | 3 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/_ExtensionClass.c
       M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/tests.py

    Fixed bug in Base __getattro__ that caused __of__ to be missed in
    instances of instances of subclasses (meta classes) of ExtensionClass.

    ------------------------------------------------------------------------
    r29072 | jim | 2005-02-07 07:36:07 -0500 (Mon, 07 Feb 2005) | 5 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/Property.py
       M /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.py

    Fixed some code for registering class changes to avoid the
    registration of data managers that are None.  This code will,
    eventually, go away, since new persistent classes will
    take care of their own registration.

    ------------------------------------------------------------------------
    r29070 | jim | 2005-02-07 07:36:03 -0500 (Mon, 07 Feb 2005) | 3 lines
    Changed paths:
       A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/ZClass.txt

    Created a basic ZClass test. It still isn't used, because the
    persistent meta class hasn't been integrated yet.

    ------------------------------------------------------------------------
    r29069 | jim | 2005-02-07 07:36:01 -0500 (Mon, 07 Feb 2005) | 3 lines
    Changed paths:
       A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.py
       A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/_pmc.txt
       A /Zope/branches/jim-fix-zclasses/lib/python/ZClasses/tests.py

    Created a meta class for persistent classes.  This is based very
    loosly on the experimental persistent class code from Zope 3.

    ------------------------------------------------------------------------
    r29068 | jim | 2005-02-07 07:35:58 -0500 (Mon, 07 Feb 2005) | 2 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/ExtensionClass/_ExtensionClass.c

    Made the ExtensionClass meta class subclassible.

    ------------------------------------------------------------------------
    r29065 | jim | 2005-02-07 07:35:52 -0500 (Mon, 07 Feb 2005) | 3 lines
    Changed paths:
       M /Zope/branches/jim-fix-zclasses/lib/python/OFS/tests/testAppInitializer.py

    Added missing cleanup code to return Products.__path__ to it's
    original state.
  • Loading branch information
Tim Peters committed Apr 7, 2005
1 parent a3c0172 commit e4174d3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ExtensionClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ static struct ExtensionClassCAPIstruct {

/* The following macro checks whether a type is an extension class: */
#define PyExtensionClass_Check(TYPE) \
(((PyObject*)(TYPE))->ob_type == ECExtensionClassType)
PyObject_TypeCheck((PyObject*)(TYPE), ECExtensionClassType)

/* The following macro checks whether an instance is an extension instance: */
#define PyExtensionInstance_Check(INST) \
(((PyObject*)(INST))->ob_type->ob_type == ECExtensionClassType)
PyObject_TypeCheck(((PyObject*)(INST))->ob_type, ECExtensionClassType)

#define CHECK_FOR_ERRORS(MESS)

Expand Down Expand Up @@ -213,7 +213,7 @@ static PyExtensionClass NAME ## Type = { PyObject_HEAD_INIT(NULL) 0, # NAME, \

/* Check whether an object has an __of__ method for returning itself
in the context of it's container. */
#define has__of__(O) ((O)->ob_type->ob_type == ECExtensionClassType \
#define has__of__(O) (PyObject_TypeCheck((O)->ob_type, ECExtensionClassType) \
&& (O)->ob_type->tp_descr_get != NULL)

/* The following macros are used to check whether an instance
Expand Down
4 changes: 3 additions & 1 deletion _ExtensionClass.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ Base_getattro(PyObject *obj, PyObject *name)
If the tp_descr_get of res is of_get,
then call it. */

if (res->ob_type->ob_type == &ExtensionClassType
if (PyObject_TypeCheck(res->ob_type,
&ExtensionClassType)
&& res->ob_type->tp_descr_get != NULL)
res = res->ob_type->tp_descr_get(
res, obj,
Expand Down Expand Up @@ -603,6 +604,7 @@ static PyTypeObject ExtensionClassType = {
/* tp_as_buffer */ 0,
/* tp_flags */ Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_HAVE_GC
| Py_TPFLAGS_BASETYPE
,
/* tp_doc */ "Meta-class for extension classes",
/* tp_traverse */ (traverseproc)0,
Expand Down
30 changes: 29 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,35 @@ def test_inheriting___doc__():
"""

from doctest import DocTestSuite
def test___of___w_metaclass_instance():
"""When looking for extension class instances, need to handle meta classes
>>> class C(Base):
... pass
>>> class O(Base):
... def __of__(self, parent):
... print '__of__ called on an O'
>>> class M(ExtensionClass):
... pass
>>> class X:
... __metaclass__ = M
...
>>> class S(X, O):
... pass
>>> c = C()
>>> c.s = S()
>>> c.s
__of__ called on an O
"""


from zope.testing.doctest import DocTestSuite
import unittest

def test_suite():
Expand Down

0 comments on commit e4174d3

Please sign in to comment.