~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-22 22:28:27 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:266
Added Publishing feature. This feature is complete except it currently isn't
available in the JavaScript interface.

fileservice: Added new JSON property "published", for each file under revision
control. Added new actions svnpublish and svnunpublish.
common/studpath: Added "published" function (to check if a file is published),
and "authorize_public" to authorize in public mode.
server: Now calls studpath.authorize_public for public mode (instead of just
authorizing everything).

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
#
108
116
# action=svncommit: Commit a file(s) or directory(s) to the repository.
109
117
#       path:   The path to the file or directory to be committed. Can be
110
118
#               specified multiple times. Directories are committed
430
438
    except pysvn.ClientError:
431
439
        raise ActionError("One or more files could not be reverted")
432
440
 
 
441
def action_svnpublish(req, fields):
 
442
    """Sets svn property "ivle:published" on each file specified.
 
443
 
 
444
    Reads fields: 'path'
 
445
    """
 
446
    paths = fields.getlist('path')
 
447
    paths = map(lambda path: actionpath_to_local(req, path), paths)
 
448
 
 
449
    try:
 
450
        for path in paths:
 
451
            # Note: Property value doesn't matter
 
452
            svnclient.propset("ivle:published", "", path, recurse=False)
 
453
    except pysvn.ClientError:
 
454
        raise ActionError("One or more files could not be updated")
 
455
 
 
456
def action_svnunpublish(req, fields):
 
457
    """Deletes svn property "ivle:published" on each file specified.
 
458
 
 
459
    Reads fields: 'path'
 
460
    """
 
461
    paths = fields.getlist('path')
 
462
    paths = map(lambda path: actionpath_to_local(req, path), paths)
 
463
 
 
464
    try:
 
465
        for path in paths:
 
466
            svnclient.propdel("ivle:published", path, recurse=False)
 
467
    except pysvn.ClientError:
 
468
        raise ActionError("One or more files could not be updated")
 
469
 
433
470
def action_svncommit(req, fields):
434
471
    """Performs a "svn commit" to each file specified.
435
472
 
460
497
    "svnadd" : action_svnadd,
461
498
    "svnupdate" : action_svnupdate,
462
499
    "svnrevert" : action_svnrevert,
 
500
    "svnpublish" : action_svnpublish,
 
501
    "svnunpublish" : action_svnunpublish,
463
502
    "svncommit" : action_svncommit,
464
503
}