Re: [Zope-dev] multiple monkeypatches

2002-06-06 Thread Jerome Alet

On Thu, Jun 06, 2002 at 09:24:58AM -0400, Casey Duncan wrote:
> 
> I am going to experiment with ExternalEditor to see if I can dynamically
> patch manage_main reliably rather than replacing it outright. If I work
> out a reliable scheme, I'll write a how-to on it. Then maybe other
> products can then use the same technique.
 
Couldn't there be a plugin mechanism for the management interface ?

I can see three sort of plugins :

   Top plugin :
   
   * will be displayed once at the top of the ZMI (below tabs)
 e.g. ZShell
 
   Line plugin :
  
   * will be displayed once for each object (on each line)
 e.g. ExternalEditor
   
   Bottom plugin :
   
   * will be displayed once on the buttons line
 e.g. Your_product_of_choice
   
Then every product would just have to register itself as a 
ZMITopPlugin, ZMILinePlugin, or ZMIBottomPlugin, or both. 

then the ZMI (main.dtml in fact) would just have to loop for each 
list of registered plugins whenever its needed : once at the top, 
once for each line listing objects, and once for the bottom. 

and if ZMILinePlugins could set a filter to be called only for some
metatypes this would be really cool !

Any comment ?

BTW Casey and others, if you need some help then I'd be pleased to 
do whatever I can, with a small amount of free time though...

> The problem is somewhat easier to solve for methods since you can detect
> whether they have already been replaced (with func_globals) and you can
> do the old "run my code and call the old one" trick. 

agreed, unfortunately...

bye,

Jerome Alet


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] multiple monkeypatches

2002-06-06 Thread Casey Duncan

I really think the only way to make this work is to design the products
with this in mind. Perhaps by developing a defacto standard for doing
monkey patches nicely. 

I am going to experiment with ExternalEditor to see if I can dynamically
patch manage_main reliably rather than replacing it outright. If I work
out a reliable scheme, I'll write a how-to on it. Then maybe other
products can then use the same technique.

The problem is somewhat easier to solve for methods since you can detect
whether they have already been replaced (with func_globals) and you can
do the old "run my code and call the old one" trick. 

-Casey


On Wed, 2002-06-05 at 18:37, Jim Penny wrote:
> On Wed, Jun 05, 2002 at 10:51:45PM +0100, Adrian Hungate wrote:
> > PatchKit handles this for you (If you ask it to).
> > 
> > :)
> > 
> > Adrian...
> 
> I am not sure that I understand.  I need to be able to do a 
> "cumulative monkey patch".  Suppose that there were two independent
> products which both modified manage_main (without loss of generality,
> say ExternalEditor and ZShell).  Most people use neither, some people
> use one, some use the other, and some use both.
> 
> It is the case of people using both that I am interested in.  To do
> this appears to me to require that I have access to the DTML form of
> any previous monkey patches to manage_main so that I can decide
> if I can safely patch the running version to meet the needs of both
> products.
> 
> Is this possible?
> 
> If both products were using PatchKit would it be possible?  How about
> if only one used PatchKit?
> 
> Thanks
> 
> Jim
> > 
> > --
> 
> 
> ___
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] multiple monkeypatches

2002-06-05 Thread Adrian Hungate

PatchKit allows the replacement of entire methods, with the ability to
backup the original when the first replacement is done - This means that the
patches are (Or at least can be) refreshable.

PatchKit does not allow for small changes to be made within a method (Such
as a DTML/HTML object) but there is a patch that puts the ZMI in the ZODB.

Adrian...

--
Adrian Hungate
EMail: [EMAIL PROTECTED]
Web: http://www.haqa.co.uk

Computers are like air conditioners
-- they stop working properly if you open WINDOWS
- Original Message -
From: "Jim Penny" <[EMAIL PROTECTED]>
To: "Adrian Hungate" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, June 05, 2002 11:37 PM
Subject: Re: [Zope-dev] multiple monkeypatches


> On Wed, Jun 05, 2002 at 10:51:45PM +0100, Adrian Hungate wrote:
> > PatchKit handles this for you (If you ask it to).
> >
> > :)
> >
> > Adrian...
>
> I am not sure that I understand.  I need to be able to do a
> "cumulative monkey patch".  Suppose that there were two independent
> products which both modified manage_main (without loss of generality,
> say ExternalEditor and ZShell).  Most people use neither, some people
> use one, some use the other, and some use both.
>
> It is the case of people using both that I am interested in.  To do
> this appears to me to require that I have access to the DTML form of
> any previous monkey patches to manage_main so that I can decide
> if I can safely patch the running version to meet the needs of both
> products.
>
> Is this possible?
>
> If both products were using PatchKit would it be possible?  How about
> if only one used PatchKit?
>
> Thanks
>
> Jim
> >
> > --
>



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] multiple monkeypatches

2002-06-05 Thread Jim Penny

On Wed, Jun 05, 2002 at 10:51:45PM +0100, Adrian Hungate wrote:
> PatchKit handles this for you (If you ask it to).
> 
> :)
> 
> Adrian...

I am not sure that I understand.  I need to be able to do a 
"cumulative monkey patch".  Suppose that there were two independent
products which both modified manage_main (without loss of generality,
say ExternalEditor and ZShell).  Most people use neither, some people
use one, some use the other, and some use both.

It is the case of people using both that I am interested in.  To do
this appears to me to require that I have access to the DTML form of
any previous monkey patches to manage_main so that I can decide
if I can safely patch the running version to meet the needs of both
products.

Is this possible?

If both products were using PatchKit would it be possible?  How about
if only one used PatchKit?

Thanks

Jim
> 
> --


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] multiple monkeypatches

2002-06-05 Thread Adrian Hungate

PatchKit handles this for you (If you ask it to).

:)

Adrian...

--
Adrian Hungate
EMail: [EMAIL PROTECTED]
Web: http://www.haqa.co.uk

Computers are like air conditioners
-- they stop working properly if you open WINDOWS
- Original Message - 
From: "Florent Guillaume" <[EMAIL PROTECTED]>
Newsgroups: local.lists.zope.zope-dev
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 05, 2002 6:15 PM
Subject: Re: [Zope-dev] multiple monkeypatches


> Jim Penny  <[EMAIL PROTECTED]> wrote:
> > Is there a safe way to handle multiple monkeypatches?
> 
> Without an existing framework (I haven't looked at Adrian's PatchKit),
> it's the same old problem as "intercepting interrupts" on good old 8-bit
> computers. You just have to save and call the previous one.
> 
> What I do is this:
> 
> # 1. define my method
> def manage_main(...):
> # ...
> ...
> res = self._myproduct_old_manage_main(...)
> ...
> return res
> # 2. put the old version in a private variable
> ObjectManager._myproduct_old_manage_main = ObjectManager.manage_main
> # 3. patch
> ObjectManager.manage_main = manage_main
> 
> If you want to play nice with refresh, you have to be a bit more
> careful, because then you don't want to do step 2. A simple test for
> absence of the _myproduct_old_manage_main attribute before doing it is
> enough.
> 
> Florent
> 
> -- 
> Florent Guillaume, Nuxeo (Paris, France)
> +33 1 40 33 79 87  http://nuxeo.com  mailto:[EMAIL PROTECTED]
> 
> 
> ___
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
> 



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] multiple monkeypatches

2002-06-05 Thread Adrian Hungate

Hmm there is a patch for the PatchKit that puts the ZMI in the ZODB, is that
what you need? :)

>From the Doc String:-

"""
Zope Management Interface Style Sheet Patch
 == = = = =

The patch adds a ZStyleSheet to the root of your Zope
with its contents set to the contents of the standard
manage_page_style.css and points the ZMI at it.

It also adds two DTML Methods initially containing the
default ZMI header and ZMI menu.

Everything can then be modified using the ZMI.
"""
# $Id: ZMImanagePatch.py,v 1.1.1.1 2002/02/03 17:07:16 root Exp $

If this is not in the PatchKit you have, you can get it from my CVS at
http://cvs.haqa.co.uk/viewcvs/Products/PatchKit (there is a tarball option
there to, which should work).

Adrian...

--
Adrian Hungate
EMail: [EMAIL PROTECTED]
Web: http://www.haqa.co.uk

Computers are like air conditioners
-- they stop working properly if you open WINDOWS
- Original Message -
From: "Jerome Alet" <[EMAIL PROTECTED]>
To: "Florent Guillaume" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, June 05, 2002 8:02 PM
Subject: Re: [Zope-dev] multiple monkeypatches


> On Wed, Jun 05, 2002 at 05:15:10PM +, Florent Guillaume wrote:
> > Jim Penny  <[EMAIL PROTECTED]> wrote:
> > > Is there a safe way to handle multiple monkeypatches?
> >
> > Without an existing framework (I haven't looked at Adrian's PatchKit),
> > it's the same old problem as "intercepting interrupts" on good old 8-bit
> > computers. You just have to save and call the previous one.
> >
> > What I do is this:
> >
> > # 1. define my method
> > def manage_main(...):
> > # ...
> > ...
> > res = self._myproduct_old_manage_main(...)
>
> Yes, I remember ;-)
>
> except that what we want to patch there is the user interface
> HTML code itself. I think parsing the HTML code to insert
> some tags where needed would do it, but this seems
> somewhat complicated to do for a simple thing like that.
>
> Would be fine if the main.dtml file would allow a plugin system...
>
> bye,
>
> Jerome Alet
>
>
>
>
> ___
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] multiple monkeypatches

2002-06-05 Thread Jerome Alet

On Wed, Jun 05, 2002 at 05:15:10PM +, Florent Guillaume wrote:
> Jim Penny  <[EMAIL PROTECTED]> wrote:
> > Is there a safe way to handle multiple monkeypatches?
> 
> Without an existing framework (I haven't looked at Adrian's PatchKit),
> it's the same old problem as "intercepting interrupts" on good old 8-bit
> computers. You just have to save and call the previous one.
> 
> What I do is this:
> 
> # 1. define my method
> def manage_main(...):
> # ...
> ...
> res = self._myproduct_old_manage_main(...)

Yes, I remember ;-)

except that what we want to patch there is the user interface
HTML code itself. I think parsing the HTML code to insert 
some tags where needed would do it, but this seems 
somewhat complicated to do for a simple thing like that.

Would be fine if the main.dtml file would allow a plugin system...

bye,

Jerome Alet




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] multiple monkeypatches

2002-06-05 Thread Florent Guillaume

Jim Penny  <[EMAIL PROTECTED]> wrote:
> Is there a safe way to handle multiple monkeypatches?

Without an existing framework (I haven't looked at Adrian's PatchKit),
it's the same old problem as "intercepting interrupts" on good old 8-bit
computers. You just have to save and call the previous one.

What I do is this:

# 1. define my method
def manage_main(...):
# ...
...
res = self._myproduct_old_manage_main(...)
...
return res
# 2. put the old version in a private variable
ObjectManager._myproduct_old_manage_main = ObjectManager.manage_main
# 3. patch
ObjectManager.manage_main = manage_main

If you want to play nice with refresh, you have to be a bit more
careful, because then you don't want to do step 2. A simple test for
absence of the _myproduct_old_manage_main attribute before doing it is
enough.

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:[EMAIL PROTECTED]


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] multiple monkeypatches

2002-06-04 Thread Adrian Hungate

Look at my PatchKit product. It provides a framework that allows multiple
patches to be applied to any combination of products.

Drop me a line if you need the api clarified.

Adrian...

--
Adrian Hungate
EMail: [EMAIL PROTECTED]
Web: http://www.haqa.co.uk

Computers are like air conditioners
-- they stop working properly if you open WINDOWS
- Original Message -
From: "Jim Penny" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 04, 2002 10:09 PM
Subject: [Zope-dev] multiple monkeypatches


> Is there a safe way to handle multiple monkeypatches?
>
> Here is the problem.  External editor monkeypatches
> ObjectManager.manage_main.  There are some other products that also
> need to monkeypatch this object.
>
> For example, if Jerome Alet's Zshell were turned into a python product,
> it would be natural for it to monkeypatch this same object.
>
> But, if it does so, whichever monkeypatch is applied last will destroy
> the previous.  Any ideas on a reasonably simple way to solve this
> problem.
>
> Thanks
>
> Jim Penny
>
>
> ___
> Zope-Dev maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] multiple monkeypatches

2002-06-04 Thread Jim Penny

Is there a safe way to handle multiple monkeypatches?

Here is the problem.  External editor monkeypatches
ObjectManager.manage_main.  There are some other products that also
need to monkeypatch this object.

For example, if Jerome Alet's Zshell were turned into a python product,
it would be natural for it to monkeypatch this same object.

But, if it does so, whichever monkeypatch is applied last will destroy
the previous.  Any ideas on a reasonably simple way to solve this
problem.

Thanks

Jim Penny


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )