Re: [Zope3-dev] wildcard adapter

2007-01-19 Thread Chris Withers

Marius Gedminas wrote:

There's a slight difference, I think.  In the Zope 3 world, there's
usually one style that is considered to be the best way of doing stuff.
Only it varies with time and with individual Zope 3 developers. ;-)


I do wish it would stop varying...


If you pass the adapts/provides arguments to provideAdapter (or the ZCML
directive), the values you specify override the defaults declared by the
adapter itself.


Right, so provideAdapter is still king? ;-)

Does your favoured methodology actually register the adapter?

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] wildcard adapter

2007-01-18 Thread Chris Withers

Marius Gedminas wrote:
BTW passing interfaces to provideAdapter/adapts is out of fashion. 


This stuff is getting almost perl-ish in it's there's many ways to do 
it, pick the style you like nature..



I
prefer using zope.component.adapts and zope.interface.implements (or
zope.component.adapter and zope.interface.implementer, when my adapter
is a function rather than a class).


I often register the same adapter factory for several different types or 
objects / interfaces. How would I do that with your favoured spelling?


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] wildcard adapter

2007-01-18 Thread Marius Gedminas
On Thu, Jan 18, 2007 at 08:55:17AM +, Chris Withers wrote:
 Marius Gedminas wrote:
 BTW passing interfaces to provideAdapter/adapts is out of fashion. 
 
 This stuff is getting almost perl-ish in it's there's many ways to do 
 it, pick the style you like nature..

There's a slight difference, I think.  In the Zope 3 world, there's
usually one style that is considered to be the best way of doing stuff.
Only it varies with time and with individual Zope 3 developers. ;-)

 I
 prefer using zope.component.adapts and zope.interface.implements (or
 zope.component.adapter and zope.interface.implementer, when my adapter
 is a function rather than a class).
 
 I often register the same adapter factory for several different types or 
 objects / interfaces. How would I do that with your favoured spelling?

If you pass the adapts/provides arguments to provideAdapter (or the ZCML
directive), the values you specify override the defaults declared by the
adapter itself.

Marius Gedminas
-- 
Some people have told me they don't think a fat penguin really embodies the
grace of Linux, which just tells me they have never seen a angry penguin
charging at them in excess of 100mph. They'd be a lot more careful about what
they say if they had.
-- Linus Torvalds, announcing Linux v2.0


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



[Zope3-dev] wildcard adapter

2007-01-17 Thread Chris Withers

Hi All,

I was wondering if someone could give me a definitive explanation of 
what the following means:


adapter
for=* ISomething *
...

...means?

Is the following equivalent:

provideAdapter(...,adapts=(None,ISomething,None),...)

?

If it is, then which of the following should I use to register a generic 
adapter for any single object to an interface:


provideAdapter(...,adapts=(None,),...)
provideAdapter(...,adapts=None,...)

I'm not having a lot of joy registering generic adapters so I thought 
I'd come and check my understanding here ;-)


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] wildcard adapter

2007-01-17 Thread Martin Aspeli



Chris Withers wrote:
 
 Hi All,
 
 I was wondering if someone could give me a definitive explanation of 
 what the following means:
 
 adapter
  for=* ISomething *
  ...
 
 ...means?
 
 Is the following equivalent:
 
 provideAdapter(...,adapts=(None,ISomething,None),...)
 

No, but this is:

provideAdapter(...,adapts=(Interface, ISomething, Interface),...)



 If it is, then which of the following should I use to register a generic 
 adapter for any single object to an interface:
 
 provideAdapter(...,adapts=(None,),...)
 provideAdapter(...,adapts=None,...)
 
 I'm not having a lot of joy registering generic adapters so I thought 
 I'd come and check my understanding here ;-)
 

provideAdapter(adapts=(Interface,), ...)

Martin

-- 
View this message in context: 
http://www.nabble.com/wildcard-adapter-tf3027563.html#a8411297
Sent from the Zope3 - dev mailing list archive at Nabble.com.

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



Re: [Zope3-dev] wildcard adapter

2007-01-17 Thread Marius Gedminas
On Wed, Jan 17, 2007 at 06:37:52AM -0800, Martin Aspeli wrote:
 Chris Withers wrote:
  I was wondering if someone could give me a definitive explanation of 
  what the following means:
  
  adapter
   for=* ISomething *
   ...
  
  ...means?
  
  Is the following equivalent:
  
  provideAdapter(...,adapts=(None,ISomething,None),...)
 
 No, but this is:
 
 provideAdapter(...,adapts=(Interface, ISomething, Interface),...)

As far as I know provideAdapter treats None the same way as Interface.
I've used this pattern a few times:

from zope.adapter import adapts, provideAdapter
from zope.interface import implements
...
class SomeAdapter(object):
adapts(None)
implements(IFoo)
...

provideAdapter(SomeAdapter)

BTW passing interfaces to provideAdapter/adapts is out of fashion.  I
prefer using zope.component.adapts and zope.interface.implements (or
zope.component.adapter and zope.interface.implementer, when my adapter
is a function rather than a class).

Marius Gedminas
-- 
America and England are two countries separated by a common language.


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