[Zope3-dev] Re: adapter registration question

2006-11-17 Thread Chris Withers
Tres Seaver wrote: We were discussion a (notional) value adapter, whose factory would have the contract of returning an object of a specific concrete type, rather than on implementing an interface. Right, but the CA supports the use of classes instead of interfaces and that works just fine

Re: [Zope3-dev] Re: adapter registration question

2006-11-17 Thread Chris Withers
Dieter Maurer wrote: As Chris example demonstrates, it would have been better to call IZopeDublinCore(myobj) the IZopeDublinCore adaptation of myobj. Agreed, and would have saved me a lot of confusion. cheers, Chris -- Simplistix - Content Management, Zope Python Consulting -

[Zope3-dev] Re: adapter registration question

2006-11-17 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Chris Withers wrote: Tres Seaver wrote: We were discussion a (notional) value adapter, whose factory would have the contract of returning an object of a specific concrete type, rather than on implementing an interface. Right, but the CA

Re: [Zope3-dev] Re: adapter registration question

2006-11-16 Thread Chris Withers
Philipp von Weitershausen wrote: Not sure what official terminology glossary you're basing this on, but we often refer to IZopeDublinCore(myobj) as the IZopeDublinCore adapter of myobj. Whatever is called to instantiate that object we call the adapter factory or adapter implementation. The

Re: [Zope3-dev] Re: adapter registration question

2006-11-16 Thread Chris Withers
Philipp von Weitershausen wrote: IZopeDublinCore(obj) is a flexible version of ZDCAnnotatableAdapter(obj) Flexible, because a different implementation that ZDCAnnotatableAdapter might be used. That's dispatched through the adapter registry. Right, exactly. IZopeDublinCore(myobj)

Re: [Zope3-dev] Re: adapter registration question

2006-11-16 Thread Chris Withers
Jean-Marc Orliaguet wrote: once you have that utility / adapter you should be able to call it like: converter = getAdapterFor(123, type=IToStringConverter) strResult = converter.convert(123) Not quite, what I'm looking to do is more along the lines of: mystr = getAdapter(123,str) (where

Re: [Zope3-dev] Re: adapter registration question

2006-11-16 Thread Philipp von Weitershausen
Chris Withers wrote: Philipp von Weitershausen wrote: Not sure what official terminology glossary you're basing this on, but we often refer to IZopeDublinCore(myobj) as the IZopeDublinCore adapter of myobj. Whatever is called to instantiate that object we call the adapter factory or adapter

Re: [Zope3-dev] Re: adapter registration question

2006-11-16 Thread Dieter Maurer
Philipp von Weitershausen wrote at 2006-11-15 21:11 +0100: ... Not sure what official terminology glossary you're basing this on I am basing this on the meaning of english words. An adapter is something that adapts (and not something that is adapted). adapt is a transitive verb. It applies to

Re: [Zope3-dev] Re: adapter registration question

2006-11-16 Thread Dieter Maurer
Jean-Marc Orliaguet wrote at 2006-11-15 20:51 +0100: ... but what problem is all this supposed to solve? are you guys writing a PhD or something .-) ? Well chosen terminology is a key to understanding. Therefore, it is justified to discuss about it. -- Dieter

[Zope3-dev] Re: adapter registration question

2006-11-16 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Chris Withers wrote: Philipp von Weitershausen wrote: IZopeDublinCore(obj) is a flexible version of ZDCAnnotatableAdapter(obj) Flexible, because a different implementation that ZDCAnnotatableAdapter might be used. That's dispatched

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Chris Withers
Philipp von Weitershausen wrote: ...hence the quotes. It's a function in that I want to use it as an adapter that doesn't need to be instantiated by a factory before being used. All adapters need to be instantiated. Why? def myStrAdapter(something): return str(something) This

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Martin Aspeli
Chris Withers wrote: Philipp von Weitershausen wrote: ...hence the quotes. It's a function in that I want to use it as an adapter that doesn't need to be instantiated by a factory before being used. All adapters need to be instantiated. Why? def myStrAdapter(something):

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Philipp von Weitershausen
Chris Withers wrote: Philipp von Weitershausen wrote: ...hence the quotes. It's a function in that I want to use it as an adapter that doesn't need to be instantiated by a factory before being used. All adapters need to be instantiated. Why? def myStrAdapter(something): return

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Dieter Maurer
Philipp von Weitershausen wrote at 2006-11-15 15:08 +0100: ... def myStrAdapter(something): return str(something) It instantiates a 'str' object. The 'str' object is the adapter for 'something'. Huh? This would be a severe terminology abuse: An adapter should adapt something to

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Philipp von Weitershausen
Dieter Maurer wrote: Philipp von Weitershausen wrote at 2006-11-15 15:08 +0100: ... def myStrAdapter(something): return str(something) It instantiates a 'str' object. The 'str' object is the adapter for 'something'. Huh? This would be a severe terminology abuse: I agree, it's bending

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Dieter Maurer
Philipp von Weitershausen wrote at 2006-11-15 20:34 +0100: Dieter Maurer wrote: Philipp von Weitershausen wrote at 2006-11-15 15:08 +0100: ... def myStrAdapter(something): return str(something) It instantiates a 'str' object. The 'str' object is the adapter for 'something'. Huh? This

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Jean-Marc Orliaguet
Philipp von Weitershausen wrote: Dieter Maurer wrote: Philipp von Weitershausen wrote at 2006-11-15 15:08 +0100: ... def myStrAdapter(something): return str(something) It instantiates a 'str' object. The 'str' object is the adapter for 'something'. Huh? This would be a severe

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Philipp von Weitershausen
Dieter Maurer wrote: Philipp von Weitershausen wrote at 2006-11-15 20:34 +0100: Dieter Maurer wrote: Philipp von Weitershausen wrote at 2006-11-15 15:08 +0100: ... def myStrAdapter(something): return str(something) It instantiates a 'str' object. The 'str' object is the adapter for

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Jean-Marc Orliaguet
Philipp von Weitershausen wrote: Dieter Maurer wrote: Philipp von Weitershausen wrote at 2006-11-15 20:34 +0100: Dieter Maurer wrote: Philipp von Weitershausen wrote at 2006-11-15 15:08 +0100: ... def myStrAdapter(something): return str(something) It instantiates a 'str' object. The

Re: [Zope3-dev] Re: adapter registration question

2006-11-15 Thread Philipp von Weitershausen
Jean-Marc Orliaguet wrote: str(123) has the same syntax as IZopeDublinCore(myobj), but semantically there is nothing in common between the two expressions. I disagree. IZopeDublinCore(obj) is a flexible version of ZDCAnnotatableAdapter(obj) Flexible, because a different

Re: [Zope3-dev] Re: adapter registration question

2006-11-14 Thread Chris Withers
Philipp von Weitershausen wrote: Chris Withers wrote: Christian Theune wrote: The problem you have is to provide a specification for the 'str' interface. There are a couple of problems here... 1. str is both a function and a class Nope. It's a class since Python 2.2. ...hence the

[Zope3-dev] Re: adapter registration question

2006-11-14 Thread Chris Withers
Tres Seaver wrote: Heh, in this case using 'IString' is really a trussed duck (duck typing with BD) ;) Python's duck typing breaks down with strings, because they can by quack tested like sequences, but you almost *never* want to treat them the same way as other sequences, so you end up with

Re: [Zope3-dev] Re: adapter registration question

2006-11-14 Thread Chris Withers
whit wrote: hello RuleDispatch... What's RuleDispatch? Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub:

Re: [Zope3-dev] Re: adapter registration question

2006-11-14 Thread Philipp von Weitershausen
Chris Withers wrote: Philipp von Weitershausen wrote: Chris Withers wrote: Christian Theune wrote: The problem you have is to provide a specification for the 'str' interface. There are a couple of problems here... 1. str is both a function and a class Nope. It's a class since Python 2.2.

Re: [Zope3-dev] Re: adapter registration question

2006-11-13 Thread Chris Withers
Christian Theune wrote: The problem you have is to provide a specification for the 'str' interface. There are a couple of problems here... 1. str is both a function and a class 2. I was to register the function str as an adapter for, say, the class int to the class str, so there's not

[Zope3-dev] Re: adapter registration question

2006-11-13 Thread Philipp von Weitershausen
Chris Withers wrote: Christian Theune wrote: The problem you have is to provide a specification for the 'str' interface. There are a couple of problems here... 1. str is both a function and a class Nope. It's a class since Python 2.2. 2. I was to register the function str as an adapter

[Zope3-dev] Re: adapter registration question

2006-11-13 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Philipp von Weitershausen wrote: Chris Withers wrote: Christian Theune wrote: The problem you have is to provide a specification for the 'str' interface. There are a couple of problems here... 1. str is both a function and a class Nope.

[Zope3-dev] Re: adapter registration question

2006-11-13 Thread Philipp von Weitershausen
Tres Seaver wrote: Philipp von Weitershausen wrote: Chris Withers wrote: Christian Theune wrote: The problem you have is to provide a specification for the 'str' interface. There are a couple of problems here... 1. str is both a function and a class Nope. It's a class since Python 2.2. 2.

[Zope3-dev] Re: adapter registration question

2006-11-13 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Philipp von Weitershausen wrote: Tres Seaver wrote: snip Thnk of cataloguing / indexing use cases: adapting the catalogued object to a string value (or tuple, or whatever) using named adapters is a very natural way to make indexing pluggable:

[Zope3-dev] Re: adapter registration question

2006-11-13 Thread whit
Tres Seaver wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Philipp von Weitershausen wrote: Tres Seaver wrote: snip Thnk of cataloguing / indexing use cases: adapting the catalogued object to a string value (or tuple, or whatever) using named adapters is a very natural way to make

[Zope3-dev] Re: adapter registration question

2006-11-10 Thread Rocky Burt
On Fri, 2006-10-11 at 08:00 +, Chris Withers wrote: This is a toy example, but I need to do something similar and can't seem to get the registration right... How can I register the str builtin as an adapter from python int objects to python str objects? I've personally found when I