[Zope] Am I doing right?

Paul Winkler pw_lists@slinkp.com
Fri, 13 Dec 2002 10:14:47 -0800


On Fri, Dec 13, 2002 at 05:31:38PM +0100, Jerome Alet wrote:
> create a Script (Python) object named itemcode in your root which 
> contains only :
> 
>         return context.getId().split('.')[-1]

that'll break the first time somebody uploads
a file named "foo.bar.baz.html" ...

instead try (untested):
 
   import string 
   name = context.getId()
   splitname = id.split('.')
   splitname.pop()  # get rid of the extension
   name = string.join(splitname, '.')  # reassemble the string
   return name
         
-- 

Paul Winkler
http://www.slinkp.com
"Welcome to Muppet Labs, where the future is made - today!"