Is this a good use of __metaclass__?

bruno at modulix onurb at xiludom.gro
Tue May 9 04:15:44 EDT 2006


Joel.Hedlund at gmail.com wrote:
> Hi!
> 
> Thank you for a quick and informative response!
> 
> 
>>I'd go for 'manually decorating' anyway. Metaclasses can be really handy
>>for framework-like stuff, but for the use case you describe, I think the
>>explicit decorator option is much more, well, explicit - and also more
>>flexible - than metaclass black magic.
> 
> 
> Yes, point taken.
> 
> 
>>This may also help you distinguish 'published' API from implementation (which is what > CherryPy do)
> 
> 
> Hmm... I'm not sure I understand how manually decorating would help me
> do that? With SimpleXMLRPCServer.register_instance(obj) all public
> methods of obj are published for XMLRPC, decorated or not.

So it's effectively useless (disclaimer : I've never used
SimpleXMLRPCServer).

(snip)
> 
>>You would then have a 'server' class that just provides common
>>services and dispatch to specialized objects.
>  
> Neat. It won't play nice with dir() or SimpleXMLRPCServer's
> introspection functions though (system.listMethods(),
> system.methodHelp()). That may be a showstopper, or do you know of any
> fixes?

Nope - well, at least not without digging into SimpleXMLRPCServer's
internals, but if it (-> the solution I suggested) makes things more
complicated, it's a bad idea anyway.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list