[Zope] Creating Linux DIR From Zope

Paul Winkler pw_lists@slinkp.com
Wed, 29 May 2002 12:05:34 -0400


On Wed, May 29, 2002 at 08:26:30AM -0700, Tran, Mike wrote:
> Good morning all,
> 
> Does anyone knows how to create a linux directory
> from Zope?

If you mean create a new empty directory on the filesystem,
you'll have to do it in a python Product or (easier) an External
Method. Through-the-web code such as DTML methods and Python Scripts
are not allowed to modify the filesystem; that's considered a security
hazard.

The relevant code in your product or method would be:

import os
os.mkdir("/full/path/to/new_directory_name", 0644)

(The octal mode is optional.)

One more note: If you do some processing on the path, it's better to use 
all the good stuff in the os.path library instead of just using
plain strings with hard-coded path separators. That way, if you
ever need to move to another system (e.g. some flavor of windows),
all your code will still work.

-- 

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