443
443
# XXX errorfiles contains a list of files that couldn't be pasted.
444
444
# we currently do nothing with this.
446
def action_publish(req,fields):
447
"""Marks the folder as published by adding a '.published' file to the
448
directory and ensuring that the parent directory permissions are correct
452
paths = fields.getlist('path')
453
user = studpath.url_to_local(req.path)[0]
454
homedir = "/home/%s" % user
456
paths = map(lambda path: actionpath_to_local(req, path), paths)
458
paths = [studpath.url_to_jailpaths(req.path)[2]]
460
# Set all the dirs in home dir world browsable (o+r,o+x)
461
#FIXME: Should really only do those in the direct path not all of the
462
# folders in a students home directory
463
for root,dirs,files in os.walk(homedir):
464
os.chmod(root, os.stat(root).st_mode|0005)
468
if os.path.isdir(path):
469
pubfile = open(os.path.join(path,'.published'),'w')
470
pubfile.write("This directory is published\n")
473
raise ActionError("Can only publish directories")
475
raise ActionError("Directory could not be published")
477
def action_unpublish(req,fields):
478
"""Marks the folder as unpublished by removing a '.published' file in the
479
directory (if it exits). It does not change the permissions of the parent
484
paths = fields.getlist('path')
486
paths = map(lambda path: actionpath_to_local(req, path), paths)
488
paths = [studpath.url_to_jailpaths(req.path)[2]]
492
if os.path.isdir(path):
493
pubfile = os.path.join(path,'.published')
494
if os.path.isfile(pubfile):
497
raise ActionError("Can only unpublish directories")
499
raise ActionError("Directory could not be unpublished")
446
502
def action_svnadd(req, fields):
447
503
"""Performs a "svn add" to each file specified.
559
615
"putfile" : action_putfile,
560
616
"putfiles" : action_putfiles,
561
617
"paste" : action_paste,
618
"publish" : action_publish,
619
"unpublish" : action_unpublish,
563
621
"svnadd" : action_svnadd,
564
622
"svnupdate" : action_svnupdate,