[Zope-CMF] Re: Tools as local utilities

Tres Seaver tseaver at palladion.com
Sun Nov 19 12:59:51 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rocky Burt wrote:
> On Sun, 2006-19-11 at 14:37 +0100, Jens Vagelpohl wrote:
>> Using just the ActionsTool right now in order to get that all set up  
>> and then move to the other tools, I've gotten almost always there,  
>> but there is one set of tests that refuse to run right now, the ones  
>> in CMFCore.exportimport.tests.test_actions which derive from class  
>> _ActionSetup.
>>
>> Here's the change I have made in the actions importer code so far:
> 
> <snipping some code...>
> 
>>       """Export actions tool.
>>       """
>>       site = context.getSite()
>> - -    tool = getToolByName(site, 'portal_actions', None)
>> +    tool = getUtility(IActionsTool, context=site)
> 
> This looks like it will be the new way of looking up CMF tools?  Looks
> great.

For the sake of backward compatibility, I'm thinking we should
re-implement 'getToolByName' to use a map of tool name to interface, and
call 'queryUtility' using that interface;  it can then fall back to an
acquired getattr and issue a deprecation warning if that fails (maybe
warn either way?)

>  But we shouldn't have to specify ``context=site`` should we?
> getUtility should automatically figure out what the nearest chain of
> sites should be and look for local utilities in each one of them
> automatically no?

That won't work unless the tests set up the thread-local site in the
same way that the publisher does.


Tres.
- --
===================================================================
Tres Seaver          +1 202-558-7113          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFYJuW+gerLs4ltQ4RAmDqAKCFt9ggbQenaF7/cVV82TGvLi7qPwCgwXml
9LBVwYnpq9znZw++xwPyhd0=
=yTg1
-----END PGP SIGNATURE-----



More information about the Zope-CMF mailing list