[Zope] stripping .html ending in an id

Jaroslav Lukesh lsh@wo.cz
Tue, 10 Jun 2003 08:46:34 +0200


: Odesílatel: Chris Beaven <chris@d-designz.co.nz>
 
: There is no attribute in dtml-var that can do _title_ capitalization 
: unfortunately. Here's a newer and better script (no where near the best 

and what about CSS capitalizimg? Browser handles more precise national
characters than script you provide.

But from general point of view very nice script.

Regards JL.

: it could be but should suffice for you) that I just wrote up. It does 
: the extention stripping, spacifying and title capitalizing now:
: 
: ## Script (Python) "niceid"
: ##bind container=container
: ##bind context=context
: ##bind namespace=
: ##bind script=script
: ##bind subpath=traverse_subpath
: ##parameters=id
: ##title=
: ##
: # strip the extention
: dot = id.rfind('.')
: if dot != -1:
:   id = id[:dot]
: 
: # turn underscores into spaces
: id = id.replace('_', ' ')
: 
: # title capitalization
: alphabet = list('abcdefghijklmnopqrstuvwxyz')
: caps = 1
: oldid = id
: id = ''
: for i in range(len(oldid)):
:   char = oldid[i].lower()
:   if caps:
:     id += char.upper()
:   else:
:     id += char
:   caps = char not in alphabet
: 
: return id
: 
: 
: 
: Chris Beaven wrote:
: 
: >Try a python script, something like this:
: >
: >## Script (Python) "niceid"
: >##bind container=container
: >##bind context=context
: >##bind namespace=
: >##bind script=script
: >##bind subpath=traverse_subpath
: >##parameters=id
: >##title=
: >##
: >dot = id.rfind('.')
: >if dot != -1:
: >  id = id[:dot]
: >id = id.replace('_', ' ')
: >return id
: >
: >
: >
: >Michael Paul Robertson wrote:
: >
: >  
: >
: >>Hi, I have a quick question to someone out there. It seems that there's
: >>no
: >>easy way to do this (although I'm rather new to zope (~a week), so I
: >>could
: >>be wrong). What I need to do is take the ID variable of a page in a
: >>    
: >>
: >dtml
: >  
: >
: >>method call and remove the .html suffix in order to use it as the title
: >>of
: >>a page. 
: >>
: >>Here's the content: 
: >>
: >><title><!--#var id spacify capitalize--></title>
: >>
: >>what it returns for a page call "mission_statement.html" that includes
: >>the
: >>method as a header is 
: >>
: >><title>Mission statement.html</title>
: >>
: >>It would be ideal if I could capitalize and strip the .html suffix to
: >>give
: >>
: >><title>Mission Statement</title>
: >>
: >>Sorry for the primitive question, but how can I do this? 
: >>
: >>Thanks for your help.
: >>
: >>Mike
: >>
: >>+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-
: >>Mike Robertson    
: >>PO Box 11224         mikerobe@stanford.edu
: >>Stanford CA 94309             650.269.4896
: >>+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-+:-
: >>
: >>``He's done so for 12 years,'' he added. ``So the idea of destroying a
: >>rocket, or two rockets, or however many he's going to destroy, says to
: >>me
: >>he's got a lot more weapons to destroy, and why isn't he destroying
: >>    
: >>
: >them
: >  
: >
: >>yet?'' 
: >> -- The unbeatable logic of Bush number 42
: >>
: >>
: >>_______________________________________________
: >>Zope maillist  -  Zope@zope.org
: >>http://mail.zope.org/mailman/listinfo/zope
: >>**   No cross posts or HTML encoding!  **
: >>(Related lists - 
: >>http://mail.zope.org/mailman/listinfo/zope-announce
: >>http://mail.zope.org/mailman/listinfo/zope-dev )
: >>
: >> 
: >>
: >>    
: >>
: >
: >
: >_______________________________________________
: >Zope maillist  -  Zope@zope.org
: >http://mail.zope.org/mailman/listinfo/zope
: >**   No cross posts or HTML encoding!  **
: >(Related lists - 
: > http://mail.zope.org/mailman/listinfo/zope-announce
: > http://mail.zope.org/mailman/listinfo/zope-dev )
: >
: >  
: >
: 
: 
: _______________________________________________
: Zope maillist  -  Zope@zope.org
: http://mail.zope.org/mailman/listinfo/zope
: **   No cross posts or HTML encoding!  **
: (Related lists - 
:  http://mail.zope.org/mailman/listinfo/zope-announce
:  http://mail.zope.org/mailman/listinfo/zope-dev )