Re: [Zope-dev] patch for dtml-foo:bar:baz;

2000-08-18 Thread Jon Franz

This may, or may not, break the alternate syntax patch/download @
http://www.zope.org/Members/Coventry/dtml_shortcut
I'll investigate and find out, and release a new dtml_shortcut if needbe.
(I specifically used a colon since it is valid xml) What about using a colon
as the separator, but explicitly give the tag the name dtml-root?
dtml-root foo:bar:childofbar

having a whole tag of type ':' seems weird (in addition to possibly breaking
current patches and such ;)

if we didn't want the root to be the default we could use something like
dtml-trans [path]:[path] with something like _root or __root being set
aside as a special name for starting at the root (otherwise it would start
in the current directory)...?



This patch changes lib/python/DocumentTemplate/DT_HTML.py so that you
can use paths for traversal in DTML entity syntax. The delimiter is ':',
as it is valid as part of an XML entity, but not valid as part of a Zope
object id.

You can use dtml-:foo:bar; to ensure that traversal occurs from the
root object.

This patch is against Zope 2.2.1b1. It relies on the
restrictedTraverse() api.

A 2.1.x version would be possible, but would be rather messy.


___
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] patch for dtml-foo:bar:baz;

2000-08-17 Thread Steve Alexander

This patch changes lib/python/DocumentTemplate/DT_HTML.py so that you
can use paths for traversal in DTML entity syntax. The delimiter is ':',
as it is valid as part of an XML entity, but not valid as part of a Zope
object id.

You can use dtml-:foo:bar; to ensure that traversal occurs from the
root object.

This patch is against Zope 2.2.1b1. It relies on the
restrictedTraverse() api.

A 2.1.x version would be possible, but would be rather messy.

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net

*** DT_HTML.py.old
--- DT_HTML.py
***
*** 98,104 
 end_match=regex.compile('[\0- ]*\(/\|end\)',
 regex.casefold).match,
 start_search=regex.compile('[]').search,
!ent_name=regex.compile('[-a-zA-Z0-9_.]+').match,
 find=find,
 strip=strip,
 replace=replace,
--- 98,104 
 end_match=regex.compile('[\0- ]*\(/\|end\)',
 regex.casefold).match,
 start_search=regex.compile('[]').search,
!ent_name=regex.compile('[-a-zA-Z0-9_.:]+').match,
 find=find,
 strip=strip,
 replace=replace,
***
*** 156,162 
  d[1]=d['end']=''
  d[2]=d['name']='var'
  d[0]=text[s:e+1]
! d[3]=d['args']=args+' html_quote'
  return s
  else:
  nn=find(args,'-')
--- 156,165 
  d[1]=d['end']=''
  d[2]=d['name']='var'
  d[0]=text[s:e+1]
! d[3]=d['args']=':' in args \
! and '"_.render(restrictedTraverse(\''+ \
! replace(args,':','/')+'\'))" html_quote' \
! or args+' html_quote'
  return s
  else:
  nn=find(args,'-')
***
*** 164,171 
  d[1]=d['end']=''
  d[2]=d['name']='var'
  d[0]=text[s:e+1]
! args=(args[nn+1:]+' '+
!   replace(args[:nn],'.',' '))
  d[3]=d['args']=args
  return s
  
--- 167,178 
  d[1]=d['end']=''
  d[2]=d['name']='var'
  d[0]=text[s:e+1]
! path=args[nn+1:]
! args=(':' in path 
! and  '"_.render(restrictedTraverse(\''+
! replace(path,':','/')+'\'))" ' 
! or path+' ') \
! +replace(args[:nn],'.',' ')
  d[3]=d['args']=args
  return s