Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/content.py
Show All 28 Lines | |||||
@browse_route(r'content/(?P<query_string>[0-9a-z_:]*[0-9a-f]+.)/raw/', | @browse_route(r'content/(?P<query_string>[0-9a-z_:]*[0-9a-f]+.)/raw/', | ||||
view_name='browse-content-raw', | view_name='browse-content-raw', | ||||
checksum_args=['query_string']) | checksum_args=['query_string']) | ||||
def content_raw(request, query_string): | def content_raw(request, query_string): | ||||
"""Django view that produces a raw display of a content identified | """Django view that produces a raw display of a content identified | ||||
by its hash value. | by its hash value. | ||||
The url that points to it is :http:get:`/browse/content/[(algo_hash):](hash)/raw/` | The url that points to it is | ||||
""" # noqa | :http:get:`/browse/content/[(algo_hash):](hash)/raw/` | ||||
""" | |||||
try: | try: | ||||
reencode = bool(strtobool(request.GET.get('reencode', 'false'))) | reencode = bool(strtobool(request.GET.get('reencode', 'false'))) | ||||
algo, checksum = query.parse_hash(query_string) | algo, checksum = query.parse_hash(query_string) | ||||
checksum = hash_to_hex(checksum) | checksum = hash_to_hex(checksum) | ||||
content_data = request_content(query_string, max_size=None, | content_data = request_content(query_string, max_size=None, | ||||
reencode=reencode) | reencode=reencode) | ||||
except Exception as exc: | except Exception as exc: | ||||
return handle_view_exception(request, exc) | return handle_view_exception(request, exc) | ||||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | |||||
@browse_route(r'content/(?P<query_string>[0-9a-z_:]*[0-9a-f]+.)/', | @browse_route(r'content/(?P<query_string>[0-9a-z_:]*[0-9a-f]+.)/', | ||||
view_name='browse-content', | view_name='browse-content', | ||||
checksum_args=['query_string']) | checksum_args=['query_string']) | ||||
def content_display(request, query_string): | def content_display(request, query_string): | ||||
"""Django view that produces an HTML display of a content identified | """Django view that produces an HTML display of a content identified | ||||
by its hash value. | by its hash value. | ||||
The url that points to it is :http:get:`/browse/content/[(algo_hash):](hash)/` | The url that points to it is | ||||
""" # noqa | :http:get:`/browse/content/[(algo_hash):](hash)/` | ||||
""" | |||||
try: | try: | ||||
algo, checksum = query.parse_hash(query_string) | algo, checksum = query.parse_hash(query_string) | ||||
checksum = hash_to_hex(checksum) | checksum = hash_to_hex(checksum) | ||||
content_data = request_content(query_string, | content_data = request_content(query_string, | ||||
raise_if_unavailable=False) | raise_if_unavailable=False) | ||||
origin_type = request.GET.get('origin_type', None) | origin_type = request.GET.get('origin_type', None) | ||||
origin_url = request.GET.get('origin_url', None) | origin_url = request.GET.get('origin_url', None) | ||||
if not origin_url: | if not origin_url: | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |