# # # add_file "file.psp" # content [2f443174ff5feb480d08a5e631599a6e3ea2f320] # # patch "monotone.py" # from [32bff5899bbea0917844c9985b7239ecf020c256] # to [3e1d8c9c725753c7b0fea0c32d7e3507c88dec90] # ============================================================ --- file.psp 2f443174ff5feb480d08a5e631599a6e3ea2f320 +++ file.psp 2f443174ff5feb480d08a5e631599a6e3ea2f320 @@ -0,0 +1,24 @@ +<% + +import config +import monotone +from monotone import Monotone + +reload(monotone) + +# +# file.psp +# output a particular file +# + +psp.set_error_page("error.psp") + +if not form.has_key('id'): + raise Exception("No file ID specified.") +id = form['id'] + +mt = Monotone(config.monotone, config.dbfile) + +req.write(mt.file(id)) + +%> ============================================================ --- monotone.py 32bff5899bbea0917844c9985b7239ecf020c256 +++ monotone.py 3e1d8c9c725753c7b0fea0c32d7e3507c88dec90 @@ -70,4 +70,10 @@ if not m: continue rv.append(m.groups()) return rv + def file(self, id): + result = utility.run_command(self.base_command + " cat file %s" % (pipes.quote(id))) + if result['exitcode'] != 0: + raise Exception("Unable to retrieve file: %s" % (result['childerr'])) + else: + return result['fromchild']