Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/views/api.py
Show First 20 Lines • Show All 501 Lines • ▼ Show 20 Lines | return _api_lookup( | ||||
ts), | ts), | ||||
utils.enrich_revision, | utils.enrich_revision, | ||||
branch_name, | branch_name, | ||||
ts) | ts) | ||||
@app.route('/api/1/revision/') | @app.route('/api/1/revision/') | ||||
@app.route('/api/1/revision/<string:sha1_git>/') | @app.route('/api/1/revision/<string:sha1_git>/') | ||||
def api_revision(sha1_git): | @app.route('/api/1/revision/<string:sha1_git>/prev/<path:context>/') | ||||
def api_revision(sha1_git, context=None): | |||||
"""Return information about revision with id sha1_git. | """Return information about revision with id sha1_git. | ||||
Args: | Args: | ||||
sha1_git: the revision's hash. | sha1_git: the revision's hash. | ||||
Returns: | Returns: | ||||
Information on the revision if found. | Information on the revision if found. | ||||
Raises: | Raises: | ||||
BadInputExc in case of unknown algo_hash or bad hash. | BadInputExc in case of unknown algo_hash or bad hash. | ||||
NotFoundExc if the revision is not found. | NotFoundExc if the revision is not found. | ||||
Example: | Example: | ||||
GET /api/1/revision/baf18f9fc50a0b6fef50460a76c33b2ddc57486e | GET /api/1/revision/baf18f9fc50a0b6fef50460a76c33b2ddc57486e | ||||
""" | """ | ||||
return _api_lookup( | |||||
sha1_git, | revision = service.lookup_revision(sha1_git) | ||||
lookup_fn=service.lookup_revision, | if not revision: | ||||
error_msg_if_not_found='Revision with sha1_git %s not' | error_msg = 'Revision with sha1_git %s not found.' % sha1_git | ||||
' found.' % sha1_git, | raise NotFoundExc(error_msg) | ||||
ardumont: ahhhh, we are missing currying here... (as in ocaml or haskell ^^)
You could actually have… | |||||
enrich_fn=utils.enrich_revision) | return utils.enrich_revision(revision, context=context) | ||||
@app.route('/api/1/revision/<string:sha1_git>/raw/') | @app.route('/api/1/revision/<string:sha1_git>/raw/') | ||||
def api_revision_raw_message(sha1_git): | def api_revision_raw_message(sha1_git): | ||||
"""Return the raw data of the revision's message | """Return the raw data of the revision's message | ||||
Args: | Args: | ||||
sha1_git: the revision's hash | sha1_git: the revision's hash | ||||
▲ Show 20 Lines • Show All 416 Lines • Show Last 20 Lines |
ahhhh, we are missing currying here... (as in ocaml or haskell ^^)
You could actually have defined a closure lambda passing the context.
Something like (not tested):