[Zope-dev] can't register adapters for classes with metaclasses

2011-02-27 Thread Chris Withers

Hi All,

This is particularly problematic when using the common case of 
SQLAlchemy declaratively mapped model classes.


The attached unit test when run will fail with:

Error in test test_provideAdapter (test_sa.TestAdapter)
Traceback (most recent call last):
  File /usr/local/lib/python2.6/unittest.py, line 279, in run
testMethod()
  File test_sa.py, line 25, in test_provideAdapter
provideAdapter(MyAdapter,Model)
  File 
zope.component-3.10.0-py2.6.egg/zope/component/globalregistry.py, line 
72, in provideAdapter

base.registerAdapter(factory, adapts, provides, name, event=False)
  File zope.component-3.10.0-py2.6.egg/zope/component/registry.py, 
line 182, in registerAdapter

required = _getAdapterRequired(factory, required)
  File zope.component-3.10.0-py2.6.egg/zope/component/registry.py, 
line 414, in _getAdapterRequired

for r in required:
TypeError: 'DeclarativeMeta' object is not iterable

Why is that and how should I register an adapter against such a class?

cheers,

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
   - http://www.simplistix.co.uk
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.schema import Column
from sqlalchemy.types import Integer
from unittest import TestCase
from zope.component import provideAdapter
from zope.interface import implements,Interface


class TestAdapter(TestCase):

def test_provideAdapter(self):
# setup
Base = declarative_base()
class Model(Base):
__tablename__='model'
id = Column('id', Integer, primary_key=True)

class IMyInterface(Interface):
pass

class MyAdapter:
implements(IMyInterface)

provideAdapter(MyAdapter,Model)
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] string exceptions

2011-02-27 Thread Lennart Regebro
On Fri, Feb 25, 2011 at 12:05, Laurence Rowe l...@lrowe.co.uk wrote:
 I take that back, that documentation is incorrect, they have indeed
 stopped working.

You are allowed to catch them, but not raise them. This is so you can
have code that runs on old Pythons with old libraries still.

But in any case I think we safely can move them to ordinary exceptions.
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] Zope Tests: 68 OK, 23 Failed, 1 Unknown

2011-02-27 Thread Zope Tests Summarizer
Summary of messages to the zope-tests list.
Period Sat Feb 26 12:00:00 2011 UTC to Sun Feb 27 12:00:00 2011 UTC.
There were 92 messages: 8 from Zope Tests, 4 from buildbot at pov.lt, 31 from 
buildbot at winbot.zope.org, 11 from ccomb at free.fr, 5 from ct at gocept.com, 
33 from jdriessen at thehealthagency.com.


Test failures
-

Subject: FAILED : Zope Buildbot / zopetoolkit-1.1_win-py2.5 slave-win
From: jdriessen at thehealthagency.com
Date: Sat Feb 26 11:04:07 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033233.html

Subject: FAILED : Zope Buildbot / zope2.14-py2.6 slave-ubuntu32
From: jdriessen at thehealthagency.com
Date: Sat Feb 26 13:14:03 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033240.html

Subject: FAILED : ZTK 1.0 / Python2.5.5 Linux 64bit
From: ccomb at free.fr
Date: Sat Feb 26 19:48:24 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033267.html

Subject: FAILED : Total languishing bugs for zopeapp: 2
From: ct at gocept.com
Date: Sat Feb 26 20:30:49 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033269.html

Subject: FAILED : Total languishing bugs for zopetoolkit: 195
From: ct at gocept.com
Date: Sat Feb 26 20:37:10 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033270.html

Subject: FAILED : Total languishing bugs for zope: 49
From: ct at gocept.com
Date: Sat Feb 26 20:41:19 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033271.html

Subject: FAILED : Total languishing bugs for zope2: 2
From: ct at gocept.com
Date: Sat Feb 26 20:45:08 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033272.html

Subject: FAILED: Repository policy check found errors in 316 projects
From: ct at gocept.com
Date: Sat Feb 26 21:23:43 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033275.html

Subject: FAILED : ZTK 1.0dev / Python2.4.6 Linux 64bit
From: ccomb at free.fr
Date: Sat Feb 26 22:12:20 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033282.html

Subject: FAILED : ZTK 1.0dev / Python2.6.5 Linux 64bit
From: ccomb at free.fr
Date: Sat Feb 26 22:12:57 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033283.html

Subject: FAILED : ZTK 1.0dev / Python2.5.5 Linux 64bit
From: ccomb at free.fr
Date: Sat Feb 26 22:13:06 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033284.html

Subject: FAILED : winbot / z3c.form_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 22:30:54 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033285.html

Subject: FAILED : winbot / z3c.rml_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 22:55:57 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033286.html

Subject: FAILED : winbot / z3c.template_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:05:54 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033288.html

Subject: FAILED : winbot / z3c.layer.ready2go_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:11:16 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033289.html

Subject: FAILED : winbot / z3c.formui_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:12:35 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033290.html

Subject: FAILED : winbot / z3c.tabular_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:14:52 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033291.html

Subject: FAILED : winbot / z3c.contents_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:15:48 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033292.html

Subject: FAILED : winbot / z3c.ptcompat_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:34:02 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033293.html

Subject: FAILED : winbot / z3c.pdftemplate_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:38:10 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033294.html

Subject: FAILED : winbot / z3c.coverage_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:39:33 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033295.html

Subject: FAILED : winbot / z3c.macro_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:40:21 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033296.html

Subject: FAILED : winbot / z3c.pagelet_py_265_32
From: buildbot at winbot.zope.org
Date: Sat Feb 26 23:44:34 EST 2011
URL: http://mail.zope.org/pipermail/zope-tests/2011-February/033297.html


Unknown
---

Subject: UNKNOWN : Zope Buildbot / zopetoolkit-1.0_win-py2.6 slave-win
From: jdriessen at thehealthagency.com
Date: Sat Feb 26 10:57:07 EST 2011
URL: 

Re: [Zope-dev] can't register adapters for classes with metaclasses

2011-02-27 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 02/27/2011 06:24 AM, Chris Withers wrote:

 This is particularly problematic when using the common case of 
 SQLAlchemy declaratively mapped model classes.
 
 The attached unit test when run will fail with:
 
 Error in test test_provideAdapter (test_sa.TestAdapter)
 Traceback (most recent call last):
File /usr/local/lib/python2.6/unittest.py, line 279, in run
  testMethod()
File test_sa.py, line 25, in test_provideAdapter
  provideAdapter(MyAdapter,Model)
File 
 zope.component-3.10.0-py2.6.egg/zope/component/globalregistry.py, line 
 72, in provideAdapter
  base.registerAdapter(factory, adapts, provides, name, event=False)
File zope.component-3.10.0-py2.6.egg/zope/component/registry.py, 
 line 182, in registerAdapter
  required = _getAdapterRequired(factory, required)
File zope.component-3.10.0-py2.6.egg/zope/component/registry.py, 
 line 414, in _getAdapterRequired
  for r in required:
 TypeError: 'DeclarativeMeta' object is not iterable
 
 Why is that and how should I register an adapter against such a class?

UTSL:  the 'required' argument passed to 'registerAdapter' is supposed
to be a sequence of interfaces or classes, not a single interface or
class.  If a class, then it must be something which can be passed to
'implementedBy'.


Tres.
- -- 
===
Tres Seaver  +1 540-429-0999  tsea...@palladion.com
Palladion Software   Excellence by Designhttp://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1qiD0ACgkQ+gerLs4ltQ57FgCgqFiGvQ9c3A8q8QYo1JmUR4UY
3PsAoLZxrDy9Q56hedSAD1v4saHtXVhf
=2veh
-END PGP SIGNATURE-

___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] can't register adapters for classes with metaclasses

2011-02-27 Thread Chris Withers
On 27/02/2011 17:22, Tres Seaver wrote:
 TypeError: 'DeclarativeMeta' object is not iterable

 Why is that and how should I register an adapter against such a class?

 UTSL:  the 'required' argument passed to 'registerAdapter' is supposed
 to be a sequence of interfaces or classes, not a single interface or
 class.  If a class, then it must be something which can be passed to
 'implementedBy'.

Thanks. I blame mcdonc, got used to having actual docs for everything ;-)

Chris

-- 
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk
___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] Acquisition wrapped objects do not behave well on unicode call

2011-02-27 Thread Christian Zagrodnick
On 2011-02-25 21:56:49 +0100, David Glick said:

 On 2/20/11 1:32 AM, Christian Zagrodnick wrote:
 On 2011-02-19 17:17:44 +0100, Hanno Schlichting said:
 
 On Thu, Feb 17, 2011 at 8:27 AM, Christian Zagrodnickc...@gocept.com  
 wrote:
 On 2011-02-16 22:22:53 +0100, Hanno Schlichting said:
 svn+ssh://svn.zope.org/repos/main/Acquisition/branches/zagy-unicode-should-be-called
Sure.
I'll 
 
 review, merge and release. Should be sometime this week,
 cannot promise a day.
 Branch reviewed, merged and released in Acquisition 2.13.6.
 
 Could you remove the merged branch once you updated your buildout config?
 Done.
 
 Thanks for releasing!
 This change introduces a regression when calling unicode on wrapped
 objects that implement __str__ but not __unicode__. Essentially it is
 now doing the equivalent of str(aq_base(obj)) ... __str__ used to get a
 wrapped object as 'self', but now it is unwrapped.
 
 Here's a failing test that can be added to Acquisition's TestUnicode
 test case to demonstrate the issue:
 
  def test_str_fallback_is_still_wrapped(self):
  class A(Acquisition.Implicit):
  def __str__(self):
  return str(len(Acquisition.aq_chain(self)))
  wrapped = A().__of__(A())
  self.assertEqual(u'2', unicode(wrapped))
 
 This is currently causing some regressions in Plone tests.

I'll have a look at it. Thanks for spotting that.


-- 
Christian Zagrodnick · c...@gocept.com
gocept gmbh  co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 4 · fax +49 345 1229889 1
Zope and Plone consulting and development


___
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )