Thank you very much, Christian, for your answer of a few days ago.

By putting a typo in the top configure.zcml file of collective.tin, I checked that all the zcml stuff was being loaded.

Then, by some debugging with pdb, I realized that in my case the directive involved wasn't
<adapter
   factory="sqlalchemy.orm.session.object_session"
   provides=".interfaces.ISession"
   for="*"
   />
but the folowing more specific one
<adapter
   factory=".utils.get_session_from_database_name"
   provides=".interfaces.ISession"
   for=".interfaces.IDatabaseFromParent"
   />

and that, in the body of get_session_from_database_name, the call
   getUtility(IDatabase, context.database_name)
wasn't returning the utility since the database_name wasn't correct.
Probably a more specific exception raised early in the code would have made easier to spot my error.

As to my "question 2"
How can I access the adapter registry where the adapters defined in the <adapter> directives are registered?
it seems that the related information is rooted in the code
siteinfo = SiteInfo()
inside the module zope/app/component/hooks.py

Now I made some progress in using collective.tin
Then I met another problem, but I'll mention it in another post.

Giovanni Toffoli

----- Original Message ----- From: "Christian Klinger" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, August 27, 2008 12:17 PM
Subject: [Product-Developers] Re: How to investigate a "could not adapt"problem


Giovanni Toffoli schrieb:
Hi all,

in developing a product above collective.lead and collective.tin, I get a TypeError such as: TypeError: ('Could not adapt', <PersonTitleFolder at /fulbright_db/fulbright/persontitlefolder.2008-08-16.9942504507>, ('Could not adapt', <PersonTitleFolder at /fulbright_db/fulbright/persontitlefolder.2008-08-16.9942504507>, <InterfaceClass collective.tin.interfaces.ISession>)

The configure.zclm file of collective.tin includes the following directive:
<adapter
   factory="sqlalchemy.orm.session.object_session"
   provides=".interfaces.ISession"
   for="*"
   />

On the other hand, using zopepy I can execute
from sqlalchemy.orm.session import object_session

I would like to investigate a little
- if and why the configure.zclm file of collective.tin hasn't been loaded

If you use buildout then you have to add collective.tin to the [zcml] of your buildout.cfg

And the suffix of configure should be zcml not zclm.


- if and why some directives inside it aren't effective in my case.

Thus I have 2 questions
1.
Is there a way of tracing (getting a log of) the loading of all the configure.zcml files, starting from site.zcml ?

I´m intrested in this as well.
Btw. you can make a typo in your configure. Then you will get an error on startup.

2.
How can I access the adapter registry where the adapters defined in the <adapter> directives are registered? In the documentation of the package zope.interface I find how to create and lookup directly (by interface) an adapter register, but I don't know which adapter register is used by my Zope/Plone site.

You can try with queryadapter from zope.component package.


Obviously I would also appreciate suggestions for other approaches of investigating the problem.

Thank you very much in advance, Giovanni Toffoli

HTH Christian


_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers




_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to