Re: [Zope3-dev] Idea: Failure to lookup adapters

2007-01-17 Thread Chris Withers

Stephan Richter wrote:
My major concern is speed here. Any debug handling will make the registry 
slower; I am using adapters very heavily in my code and any slow-down of one 
lookup would be multiplied many times.


+ sys.maxint.

cheers,

Chris

--
Simplistix - Content Management, Zope  Python Consulting
   - http://www.simplistix.co.uk

___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Idea: Failure to lookup adapters

2007-01-16 Thread Stephan Richter
On Monday 15 January 2007 14:25, Sidnei da Silva wrote:
   'We've tried to look up an adapter for (ISomething, ITheOther) but
 none was found'
   'Found an adapter for IFoo, which is a base class for the IBar
 interface requested. No adapter has been found for the most-specific
 interface IBar'

 Comments?

My major concern is speed here. Any debug handling will make the registry 
slower; I am using adapters very heavily in my code and any slow-down of one 
lookup would be multiplied many times.

I wonder whether a different approach could be taken. The APIDOC code does 
already a registration analysis. Maybe we can use the registrations in a away 
that they simulate the adapter registry. Thus you could provide APIDOC (via 
the Web UI or Python) with a component or instance and it tells you how it 
tries to look up the adapter. Clearly that would be much slower, but okay for 
inspection.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Idea: Failure to lookup adapters

2007-01-16 Thread Marius Gedminas
On Tue, Jan 16, 2007 at 08:36:48AM +0100, Christian Theune wrote:
 Am Montag, den 15.01.2007, 17:25 -0200 schrieb Sidnei da Silva:
  One of the most common issues that I've faced, and watched several
  people struggle with, during Zope 3 development is to figure why a
  certain adapter is not found, or why a certain other adapter is found
  instead of the one you are expecting.
...
  One of the ideas that occurred me was that in debug mode we could
  create a wrapper around the to-be-returned adapter and stuff some
  trace information in there to help diagnose possible issues. Or maybe
  we could just use the logging framework to output some information.
  
  The kind of info I'm looking for is something along the lines:
  
'We've tried to look up an adapter for (ISomething, ITheOther) but
  none was found'
'Found an adapter for IFoo, which is a base class for the IBar
  interface requested. No adapter has been found for the most-specific
  interface IBar'

 Yes please. =)
 
 I'd love some debugging support for that as well. I like the idea of a
 log that gives you enough input to reason about what the CA did to
 derive its decision.

 In an advanced step, something interactive might be worthwhile to allow
 poking into the registrations conveniently.

Perhaps a useful question to ask here is why wasn't my adapter chosen?

  $ bin/debugzope
   from zope.component.introspection import explainAdapter
   from mypackage import MyAdaper, IMyDesiredInterface
   my_obj = app.root()['somefolder']['someobj']
   explainAdapter(my_obj, IMyDesiredInterface, desired_adapter=MyAdapter)
  'MyAdapter is registered for IFoo, but context does not provide IFoo.'

explainAdapter is probably a bad name for this.  Maybe the whole API is
bad.  Maybe it would be more useful to list all adapters that could
adapt your object to the desired interface, and list them in the order
of specificness:

   for reg in matchingAdapters(my_obj, IMyDesiredInterface):
  ... print reg.factory, reg.required
  class somemodule.SomeGenericAdapter (interface IFooBase, )
  class somemodule.MyAdapter (interface IFoo, )
  class somemodule.SomeEvilAdapter (interface IMoreSpecificFoo, )

Marius Gedminas
-- 
... Another nationwide organization's computer system crashed twice in less
than a year. The cause of each crash was a computer virus
-- Paul Mungo, Bryan Glough  _Approaching_Zero_
(in 1986 computer crashes were something out of the ordinary.  Win95 anyone?)


signature.asc
Description: Digital signature
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Idea: Failure to lookup adapters

2007-01-16 Thread Stephan Richter
On Tuesday 16 January 2007 08:23, Marius Gedminas wrote:
 explainAdapter is probably a bad name for this.  Maybe the whole API is
 bad.  Maybe it would be more useful to list all adapters that could
 adapt your object to the desired interface, and list them in the order
 of specificness:

You can do this already in APIDOC today.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Idea: Failure to lookup adapters

2007-01-16 Thread Dieter Maurer
Sidnei da Silva wrote at 2007-1-15 17:25 -0200:
 ...
The kind of info I'm looking for is something along the lines:

  'We've tried to look up an adapter for (ISomething, ITheOther) but
none was found'
  'Found an adapter for IFoo, which is a base class for the IBar
interface requested. No adapter has been found for the most-specific
interface IBar'

Comments?

In Zope 2, I would use __traceback_info__ or (more likely)
__traceback_supplement__ and the traceback formatting
facilities in zExceptions.ExceptionFormatter.
This is a very efficient way to analyse all problems that
result in an exception -- far better than log entries.



-- 
Dieter
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Idea: Failure to lookup adapters

2007-01-16 Thread Christian Theune
Hi,

Am Dienstag, den 16.01.2007, 20:28 +0100 schrieb Dieter Maurer:
 Sidnei da Silva wrote at 2007-1-15 17:25 -0200:
  ...
 The kind of info I'm looking for is something along the lines:
 
   'We've tried to look up an adapter for (ISomething, ITheOther) but
 none was found'
   'Found an adapter for IFoo, which is a base class for the IBar
 interface requested. No adapter has been found for the most-specific
 interface IBar'
 
 Comments?
 
 In Zope 2, I would use __traceback_info__ or (more likely)
 __traceback_supplement__ and the traceback formatting
 facilities in zExceptions.ExceptionFormatter.
 This is a very efficient way to analyse all problems that
 result in an exception -- far better than log entries.

Zope 3 has that as well. However, this only gives you the information of
the stack. It doesn't give you information created during the run of
e.g. loops, which I imagine would be interesting to create a trail of
what did you do? information. 


-- 
gocept gmbh  co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - [EMAIL PROTECTED] - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Idea: Failure to lookup adapters

2007-01-16 Thread Sidnei da Silva

Zope 3 has that as well. However, this only gives you the information of
the stack. It doesn't give you information created during the run of
e.g. loops, which I imagine would be interesting to create a trail of
what did you do? information.


Well, you could set a list into __traceback_info__ and append to it
during each loop, instead of assigning.

Anyway, that would only be seen in the case of an exception. Unless we
could expose a view that shows the stack without having an exception.

--
Sidnei da Silva
Enfold Systemshttp://enfoldsystems.com
Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



[Zope3-dev] Idea: Failure to lookup adapters

2007-01-15 Thread Sidnei da Silva

One of the most common issues that I've faced, and watched several
people struggle with, during Zope 3 development is to figure why a
certain adapter is not found, or why a certain other adapter is found
instead of the one you are expecting.

I was wondering if there is something that could be done to help
pinpoint this kind of issue, since adapters are really a key part of
the component architecture.

One of the ideas that occurred me was that in debug mode we could
create a wrapper around the to-be-returned adapter and stuff some
trace information in there to help diagnose possible issues. Or maybe
we could just use the logging framework to output some information.

The kind of info I'm looking for is something along the lines:

 'We've tried to look up an adapter for (ISomething, ITheOther) but
none was found'
 'Found an adapter for IFoo, which is a base class for the IBar
interface requested. No adapter has been found for the most-specific
interface IBar'

Comments?

--
Sidnei da Silva
Enfold Systemshttp://enfoldsystems.com
Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



Re: [Zope3-dev] Idea: Failure to lookup adapters

2007-01-15 Thread Christian Theune
Am Montag, den 15.01.2007, 17:25 -0200 schrieb Sidnei da Silva:
 One of the most common issues that I've faced, and watched several
 people struggle with, during Zope 3 development is to figure why a
 certain adapter is not found, or why a certain other adapter is found
 instead of the one you are expecting.
 
 I was wondering if there is something that could be done to help
 pinpoint this kind of issue, since adapters are really a key part of
 the component architecture.
 
 One of the ideas that occurred me was that in debug mode we could
 create a wrapper around the to-be-returned adapter and stuff some
 trace information in there to help diagnose possible issues. Or maybe
 we could just use the logging framework to output some information.
 
 The kind of info I'm looking for is something along the lines:
 
   'We've tried to look up an adapter for (ISomething, ITheOther) but
 none was found'
   'Found an adapter for IFoo, which is a base class for the IBar
 interface requested. No adapter has been found for the most-specific
 interface IBar'


 
 Comments?

Yes please. =)

I'd love some debugging support for that as well. I like the idea of a
log that gives you enough input to reason about what the CA did to
derive its decision.

In an advanced step, something interactive might be worthwhile to allow
poking into the registrations conveniently.

Christian

-- 
gocept gmbh  co. kg - forsterstraße 29 - 06112 halle/saale - germany
www.gocept.com - [EMAIL PROTECTED] - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development


signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com