[Product-Developers] Re: collective.monkeypatcher -- awkward names
Martin Aspeli
optilude+lists at gmail.com
Tue Feb 9 14:41:10 UTC 2010
Jean Jordaan wrote:
> Hi there
>
> I find this a very awkward way to say "I want to add a new function to a
> module"::
>
> <monkey:patch
> description="Add XML-RPC capability to SomeModule"
> module="Products.SomeProduct.SomeModule"
> original="readRemoteProject"
> ignoreOriginal="True"
> replacement=".SomeModule.readRemoteProject"
> />
>
> Because there is no original, and if there were, I'm not ignoring the
> original, I'm ignoring its *absence*.
>
> Better would be::
>
> <monkey:patch
> description="Add XML-RPC capability to SomeModule"
> module="Products.SomeProduct.SomeModule"
> checkOriginal="False"
> patch=".SomeModule.readRemoteProject"
> />
+1
I'm not sure what ignoreOriginal is doing in this case; I'd probably
just ignore it.
> If I simply want to replace an existing function of the same name,
> checking for the original::
>
> <monkey:patch
> description="Add XML-RPC capability to SomeModule"
> module="Products.SomeProduct.SomeModule"
> patch=".SomeModule.readRemoteProject"
> />
-1
I think you should have to explicitly say what you're patching. Just
looking for something with the same name is too magical. The whole point
of collective.monkeypatcher is to make everything very explicit.
> If I'm replacing an existing function, and for some reason the
> 'description' attribute is insufficient to describe what I'm doing and I
> want to name my method something different::
>
> <monkey:patch
> description="Add XML-RPC capability to SomeModule"
> module="Products.SomeProduct.SomeModule"
> original="readRemoteProject"
> patch=".SomeModule.readRemoteProject_myownspecialweirdname"
> />
This is the current basic syntax, no? I think this is the appropriate
way still for both this and the case above where the patch function and
the original function happened to have the same name.
> Just a suggestion for the future .. if people aren't averse, I may
> implement it if I find time.
Feel free. :)
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Product-Developers
mailing list