~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/apps/fileservice/action.py

  • Committer: mattgiuca
  • Date: 2008-01-14 01:40:49 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:220
browser: Removed 3 buttons which didn't do anything.
    Split editor handler into editor.js.

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
#       path:   The path to the file to be updated. Only one file may be
106
106
#               specified.
107
107
#
108
 
# action=svnpublish: Set the "published" flag on a file to True.
109
 
#       path:   The path to the file to be published. Can be specified
110
 
#               multiple times.
111
 
#
112
 
# action=svnunpublish: Set the "published" flag on a file to False.
113
 
#       path:   The path to the file to be unpublished. Can be specified
114
 
#               multiple times.
115
 
#
116
108
# action=svncommit: Commit a file(s) or directory(s) to the repository.
117
109
#       path:   The path to the file or directory to be committed. Can be
118
110
#               specified multiple times. Directories are committed
288
280
 
289
281
    Reads fields: 'path', 'data' (file upload)
290
282
    """
291
 
    # Important: Data is "None" if the file submitted is empty.
292
283
    path = fields.getfirst('path')
293
284
    data = fields.getfirst('data')
294
 
    if path is None:
 
285
    if path is None or data is None:
295
286
        raise ActionError("Required field missing")
296
287
    path = actionpath_to_local(req, path)
297
 
    if data is not None:
298
 
        data = data.file
 
288
    data = data.file
299
289
 
300
290
    # Copy the contents of file object 'data' to the path 'path'
301
291
    try:
302
292
        dest = open(path, 'wb')
303
 
        if data is not None:
304
 
            shutil.copyfileobj(data, dest)
 
293
        shutil.copyfileobj(data, dest)
305
294
    except OSError:
306
295
        raise ActionError("Could not write to target file")
307
296
 
438
427
    except pysvn.ClientError:
439
428
        raise ActionError("One or more files could not be reverted")
440
429
 
441
 
def action_svnpublish(req, fields):
442
 
    """Sets svn property "ivle:published" on each file specified.
443
 
    Should only be called on directories (only effective on directories
444
 
    anyway).
445
 
 
446
 
    Reads fields: 'path'
447
 
    """
448
 
    paths = fields.getlist('path')
449
 
    paths = map(lambda path: actionpath_to_local(req, path), paths)
450
 
 
451
 
    try:
452
 
        for path in paths:
453
 
            # Note: Property value doesn't matter
454
 
            svnclient.propset("ivle:published", "", path, recurse=False)
455
 
    except pysvn.ClientError:
456
 
        raise ActionError("One or more files could not be updated")
457
 
 
458
 
def action_svnunpublish(req, fields):
459
 
    """Deletes svn property "ivle:published" on each file specified.
460
 
 
461
 
    Reads fields: 'path'
462
 
    """
463
 
    paths = fields.getlist('path')
464
 
    paths = map(lambda path: actionpath_to_local(req, path), paths)
465
 
 
466
 
    try:
467
 
        for path in paths:
468
 
            svnclient.propdel("ivle:published", path, recurse=False)
469
 
    except pysvn.ClientError:
470
 
        raise ActionError("One or more files could not be updated")
471
 
 
472
430
def action_svncommit(req, fields):
473
431
    """Performs a "svn commit" to each file specified.
474
432
 
499
457
    "svnadd" : action_svnadd,
500
458
    "svnupdate" : action_svnupdate,
501
459
    "svnrevert" : action_svnrevert,
502
 
    "svnpublish" : action_svnpublish,
503
 
    "svnunpublish" : action_svnunpublish,
504
460
    "svncommit" : action_svncommit,
505
461
}