[Zope] AUTHENTICATED_USER considered harmfull :)

Hannu Krosing hannu@tm.ee
Wed, 22 Sep 1999 12:36:21 +0300


Michel Pelletier wrote:
> 
> Stuart Woolford wrote:
> >
> >
> > BTW, in another direction, has does anyone know why the default DTML
> > in Zope 2.0 atr formated in the old style, not the new <dtml-var > style? I
> > prefer the later a LOT, but cannot usually be bothered changing the default
> > contents (too busy adding great new bits ;)
> 
> Just didn't have time, sounds trivial but it didn't happen before the
> release did.
> 
> Perhaps you'd like to provide a set of patches?  This would be very
> helpful.  You might be surprised how much DTML shows up embeded in the
> Zope source code, but you could probably sniff it all  out with grep and
> Emacs.

It seems that running the following script in your Zope2 root does it

------8<------ cut here -------8<--------
#!/usr/bin/python

import os,string,re

rx_close = re.compile('<!--#[ \t]*(/|end)(.*?)-->',re.DOTALL)

rx_open = re.compile('<!--#(.*?)-->',re.DOTALL)

def visit(arg,dirname,names):
    py_files = filter(lambda x:x[-3:] == '.py',names)
    dtml_files = filter(lambda x:x[-5:] == '.dtml',names)
    for filename in py_files+dtml_files:
        newsyntax(dirname,filename)

def make_close(match): return '</dtml-%s>' % match.group(2)

def make_open(match): return '<dtml-%s>' % match.group(1)

def newsyntax(path,filename):
    fullpath = os.path.join(path,filename)
    data = open(fullpath).read()
    data1 = rx_close.sub(make_close,data)
    data1 = rx_open.sub(make_open,data1)
    if data != data1:
        print path,filename
        os.rename(fullpath,fullpath+'.orig')
        open(fullpath, 'w').write(data1)
        open(fullpath+'.new', 'w').write(data1)

os.path.walk('lib/python',visit,None)
------8<------ cut here -------8<--------

Hannu