[Zope] Feature request for metal - default macros?
KevinL
darius@obsidian.com.au
10 Aug 2002 21:21:58 +1000
On Sat, 2002-08-10 at 20:40, Chris Withers wrote:
> make language a python script:
>
> language = "a string containing your language, got from wherever you get
> it from"
> if context.skins.helpfile.macros.has_key(language):
> return language
> else:
> reutnr 'english'
Stefan Holek wrote:
> http://www.zopelabs.com/cookbook/1014285275
(which lists a way to use pythonscripts to return the actual macro,
rather than the word)
I combined the two, with a method in my local python product, to give:
def getHelptext(self):
"""
Returns the actual text for the help block on a page
"""
request = getattr(self,'REQUEST')
baseUrl = self.baseUrl()
ptl_name = request['URL0'].replace(baseUrl,'')[1:]
language = self.getLanguage()
skin = self.getSkin()
subSkin = self.getSubSkin()
ptl_page = self.restrictedTraverse('%s/skins/%s/%s/help/%s'
% (self.realm(),skin,subSkin,ptl_name))
if ptl_page.macros.has_key(language):
return ptl_page.macros[language]
else:
return ptl_page.macros['english']
(baseUrl, getLanguage, getSkin, etc are all my own methods)
and the call in the page is
<metal:block use-macro="here/getHelptext"></metal:block>
Doesn't get much simpler.
Thanks heaps for the quick responses from people - one of Zope's many
assets :)
KJL