[z3-checkins] Re: r10172 - z3/Five/branch/regebro-standard_macros
Philipp von Weitershausen
philipp at weitershausen.de
Thu Mar 31 12:05:38 MEST 2005
Lennart Regebro wrote:
> Philipp von Weitershausen wrote:
>
>> Well, Five has its own StandardMacros view in Five.browser which is
>> registered as 'standardmacros'. From what I see in the code, this view
>> implementation looks nearly identical to the one defined in basicskin
>> (except for new-style classing and the 'five_template' macro page).
>>
>> So, from ZPT we should be all set.
>
>
> Yes, but the registering of macros in Zope3, for obvious reasons, do not
> use that StandardMacro implementation. It uses Zope 3s implementation,
> which is a new-style class, and hence desn't work.
>
> So, I monkey patch Zope3, by replacing zope3s StandardMacros with Fives
> StandardMacros, and hey presto! It works.
Of course, that works. But I don't think it's an appropriate solution
because the problem is nearly non-existant.
>>> Last week I reached a new level of Zen on this issue, and I realized
>>> that it wasn't that hard to fix it. Monkey patching this is not
>>> strictly necessary. We can do copy-pasting ov every usage of
>>> StandardMacros and use our own StandardMacros instead. But that
>>> causes code duplication...
>>
>>
>> What code duplication are we talking about? Skins based on
>> zope.app.basicskin.standardmacros.StandardMacros? I don't think we
>> want to reuse them too soon in Five.
>
> I think we do. Without them skins made for Five can't be used in Zope3
> and skins in Zope3 can't be used in Five.
Well, that's because Zope 3 browser views can't be used in Five and Five
browser views can't be used in Zope 3. That's just the way it is, for
Zope 2.7 at least. You know, we're not monkey-replacing
zope.app.publisher.BrowserView with our Five.browser.BrowserView either...
(As for skin reuse, I think for current Five integrations into Zope 2
apps (most are CMF or Silva based anyway), we won't need Zope 3 skins.
There only are Rotterdam (and neglected ZopeTop) right now...)
>> Even if so, the code duplication is
>> minimal (a two liner for inheriting from StandardMacros and then
>> another two liner for the ZCML).
>
> No, we have to re-register the macros, and since we don't know where the
> actual macro files are located, we can't refer to them, so we must copy
> them from Zope3 to Five.
We don't have to reregister macros. You only have to reregister the
StandardMacros class since those are new-style classes in their Z3
equivalent. Page Template macros can be registered with Five's
browser:page directive handler just fine...
So, for example, if you want to reuse the Rotterdam skin, you have to
"reimplement" Rotterdam's StandardMacros class::
from Products.Five.browser import StandardMacros as BaseMacros
class StandardMacros(BaseMacros):
macro_pages = ('skin_macros', 'view_macros', 'dialog_macros',
'navigation_macros')
and register it via ZCML in the rotterdam layer::
<browser:page
for="*"
name="standard_macros"
permission="zope2.View"
class=".standardmacros.StandardMacros"
layer="rotterdam"
allowed_interface="zope.interface.common.mapping.IItemMapping"
/>
Voila... I think this little amount of code duplication doesn't justify
a monkey patch in Zope 3...
Philipp
More information about the z3-checkins
mailing list