本文整理汇总了Python中opencontext_py.libs.rootpath.RootPath类的典型用法代码示例。如果您正苦于以下问题:Python RootPath类的具体用法?Python RootPath怎么用?Python RootPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RootPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
def index(request):
""" Get the search context JSON-LD """
rp = RootPath()
base_url = rp.get_baseurl()
req_neg = RequestNegotiation("text/html")
old_view = False
template = loader.get_template("index/view.html")
if "test" in request.GET:
template = loader.get_template("index/view-initial-minimal.html")
old_view = True
context = RequestContext(
request,
{
"base_url": base_url,
"old_view": old_view,
"page_title": "Open Context: Publisher of Research Data",
"act_nav": "home",
"nav_items": settings.NAV_ITEMS,
},
)
if "HTTP_ACCEPT" in request.META:
req_neg.check_request_support(request.META["HTTP_ACCEPT"])
if req_neg.supported:
# requester wanted a mimetype we DO support
return HttpResponse(template.render(context))
else:
# client wanted a mimetype we don't support
return HttpResponse(template.render(context), status=415)
示例2: pub_view
def pub_view(request):
""" Get publishing overview page """
request = RequestNegotiation().anonymize_request(request)
rp = RootPath()
base_url = rp.get_baseurl()
req_neg = RequestNegotiation('text/html')
if 'HTTP_ACCEPT' in request.META:
req_neg.check_request_support(request.META['HTTP_ACCEPT'])
if req_neg.supported:
# requester wanted a mimetype we DO support
open_graph = {
'twitter_site': settings.TWITTER_SITE,
'type': 'website',
'url': base_url + '/about/publishing',
'site_name': settings.CANONICAL_SITENAME,
'description': 'How to publish archaeological research data '\
'with Open Context',
'image': base_url + '/static/oc/images/index/oc-blue-square-logo.png',
'video': False
}
template = loader.get_template('about/publishing.html')
context = {
'base_url': base_url,
'page_title': 'Open Context: About - Publishing',
'act_nav': 'about',
'og': open_graph,
'nav_items': settings.NAV_ITEMS
}
return HttpResponse(template.render(context, request))
else:
# client wanted a mimetype we don't support
return HttpResponse(req_neg.error_message,
status=415)
示例3: html_view
def html_view(request, uuid):
ocitem = OCitem()
ocitem.get_item(uuid, True)
if(ocitem.manifest is not False):
rp = RootPath()
base_url = rp.get_baseurl()
temp_item = TemplateItem()
temp_item.read_jsonld_dict(ocitem.json_ld)
template = loader.get_template('projects/view.html')
req_neg = RequestNegotiation('text/html')
req_neg.supported_types = ['application/json',
'application/ld+json']
if 'HTTP_ACCEPT' in request.META:
req_neg.check_request_support(request.META['HTTP_ACCEPT'])
if req_neg.supported:
if 'json' in req_neg.use_response_type:
# content negotiation requested JSON or JSON-LD
return HttpResponse(json.dumps(ocitem.json_ld,
ensure_ascii=False, indent=4),
content_type=req_neg.use_response_type + "; charset=utf8")
else:
context = RequestContext(request,
{'item': temp_item,
'base_url': base_url})
return HttpResponse(template.render(context))
else:
# client wanted a mimetype we don't support
return HttpResponse(req_neg.error_message,
content_type=req_neg.use_response_type + "; charset=utf8",
status=415)
else:
raise Http404
示例4: finalize
def finalize(request, source_id):
""" Show HTML form to change relationships for entities
to be created / or updated from an import table
"""
if not request.user.is_superuser:
return HttpResponse('Unauthorized', status=401)
else:
rp = RootPath()
base_url = rp.get_baseurl()
ip = ImportProfile(source_id)
if ip.project_uuid is not False:
ip.get_fields()
imnav = ImportNavigation()
ip.nav = imnav.set_nav('finalize',
ip.project_uuid,
source_id)
template = loader.get_template('imports/finalize.html')
context = {
'ip': ip,
'base_url': base_url,
'user': request.user
}
return HttpResponse(template.render(context, request))
else:
raise Http404
示例5: __init__
def __init__(self):
self.proj_context_json_ld = None
self.project_uuid = None
self.manifest = None
self.assertion_hashes = False
self.assertions = None
self.mediafiles = None
self.link_annotations = None
self.stable_ids = None
self.obs_list = []
self.item_pred_objs = {} # predicate entity objects, with uuid as a key
self.string_obj_dict = {} # OCstring objects, in a dict, with uuid as key
self.manifest_obj_dict = {} # manifest objects, in a dict with uuid as key
self.assertion_author_uuids = {
# uuids of DC contribuors (persons/orgs) found in item assertions
ItemKeys.PREDICATES_DCTERMS_CONTRIBUTOR: [],
# uuids of DC creators (persons/orgs) found in item assertions
ItemKeys.PREDICATES_DCTERMS_CREATOR: []
}
self.dc_assertions = {} # dublin core assertions. We add these last, just for aesthetics
self.dc_title = None # dublin core title attribute, to use if not via default programatic way
dc_terms_obj = DCterms()
self.dc_metadata_preds = dc_terms_obj.get_dc_terms_list()
self.dc_author_preds = dc_terms_obj.get_dc_authors_list()
self.dc_inherit_preds = [ # these are dc-terms predicates items can inherit from a project
ItemKeys.PREDICATES_DCTERMS_CONTRIBUTOR,
ItemKeys.PREDICATES_DCTERMS_CREATOR,
ItemKeys.PREDICATES_DCTERMS_TEMPORAL,
ItemKeys.PREDICATES_DCTERMS_LICENSE
]
self.item_gen_cache = ItemGenerationCache()
rp = RootPath()
self.base_url = rp.get_baseurl()
self.class_uri_list = [] # uris of item classes used in this item
self.parent_context_list = [] # list of parent context labels, used for making a dc-terms:Title
示例6: profile_edit
def profile_edit(request, profile_uuid):
""" Handles JSON requests for a profile
"""
ipt = InputProfileTemplating()
exists = ipt.check_exists(profile_uuid)
if exists:
# now check to see if the we have edit permissions
proj_inp = ProjectInputs(ipt.project_uuid, request)
if proj_inp.edit_permitted or request.user.is_superuser:
rp = RootPath()
base_url = rp.get_baseurl()
temp_item = {'uuid': ipt.uuid,
'label': ipt.inp_prof.label,
'project_uuid': ipt.project_uuid,
'project': ipt.project,
'context': False,
'act_nav': 'profiles'}
template = loader.get_template('edit/profiles/profile-edit.html')
context = RequestContext(request,
{'item': temp_item,
'super_user': request.user.is_superuser,
'icons': ItemBasicEdit.UI_ICONS,
'field_group_vis': InputFieldGroup.GROUP_VIS,
'base_url': base_url})
return HttpResponse(template.render(context))
else:
json_output = json.dumps({'error': 'edit permission required'},
indent=4,
ensure_ascii=False)
return HttpResponse(json_output,
content_type='application/json; charset=utf8',
status=401)
else:
raise Http404
示例7: field_types_more
def field_types_more(request, source_id):
""" Show HTML form further classifying subject fields """
if not request.user.is_superuser:
return HttpResponse('Unauthorized', status=401)
else:
rp = RootPath()
base_url = rp.get_baseurl()
ip = ImportProfile(source_id)
if ip.project_uuid is not False:
ip.get_subject_type_fields()
imnav = ImportNavigation()
ip.nav = imnav.set_nav('field-types-more',
ip.project_uuid,
source_id)
if len(ip.fields) > 0:
template = loader.get_template('imports/field-types-more.html')
context = {
'ip': ip,
'base_url': base_url,
'user': request.user
}
return HttpResponse(template.render(context, request))
else:
redirect = '../../imports/field-types/' + source_id
return HttpResponseRedirect(redirect)
else:
raise Http404
示例8: services_view
def services_view(request):
""" Get page documenting the API """
request = RequestNegotiation().anonymize_request(request)
rp = RootPath()
base_url = rp.get_baseurl()
req_neg = RequestNegotiation('text/html')
if 'HTTP_ACCEPT' in request.META:
req_neg.check_request_support(request.META['HTTP_ACCEPT'])
if req_neg.supported:
# requester wanted a mimetype we DO support
open_graph = {
'twitter_site': settings.TWITTER_SITE,
'type': 'website',
'url': base_url + '/about/technology',
'site_name': settings.CANONICAL_SITENAME,
'description': 'Overview of the APIs (machine-readable data) '\
'offered by Open Context to promote '\
'interoperability and new uses of data',
'image': base_url + '/static/oc/images/index/oc-blue-square-logo.png',
'video': False
}
template = loader.get_template('about/services.html')
context = {
'base_url': base_url,
'page_title': 'Open Context: About - Web Services and APIs',
'og': open_graph,
'act_nav': 'about',
'nav_items': settings.NAV_ITEMS
}
return HttpResponse(template.render(context))
else:
# client wanted a mimetype we don't support
return HttpResponse(req_neg.error_message,
status=415)
示例9: recipes_view
def recipes_view(request):
""" Get page about recipes using the API """
request = RequestNegotiation().anonymize_request(request)
rp = RootPath()
base_url = rp.get_baseurl()
req_neg = RequestNegotiation('text/html')
if 'HTTP_ACCEPT' in request.META:
req_neg.check_request_support(request.META['HTTP_ACCEPT'])
if req_neg.supported:
# requester wanted a mimetype we DO support
open_graph = {
'twitter_site': settings.TWITTER_SITE,
'type': 'website',
'url': base_url + '/about/recipes',
'site_name': settings.CANONICAL_SITENAME,
'description': 'Specific guidance on the use of Open Context APIs '\
'(machine-readable data) to meet certain data '\
'management needs',
'image': base_url + '/static/oc/images/index/oc-blue-square-logo.png',
'video': False
}
template = loader.get_template('about/recipes.html')
context = {
'base_url': base_url,
'page_title': 'Open Context: About - API Cookbook',
'og': open_graph,
'act_nav': 'about',
'nav_items': settings.NAV_ITEMS
}
return HttpResponse(template.render(context))
else:
# client wanted a mimetype we don't support
return HttpResponse(req_neg.error_message,
status=415)
示例10: index_view
def index_view(request):
""" Get the search context JSON-LD """
request = RequestNegotiation().anonymize_request(request)
rp = RootPath()
base_url = rp.get_baseurl()
req_neg = RequestNegotiation('text/html')
if 'HTTP_ACCEPT' in request.META:
req_neg.check_request_support(request.META['HTTP_ACCEPT'])
if req_neg.supported:
# requester wanted a mimetype we DO support
open_graph = {
'twitter_site': settings.TWITTER_SITE,
'type': 'website',
'url': base_url + '/about/',
'site_name': settings.CANONICAL_SITENAME,
'description': 'Video and introduction to Open Context, an open-access '
'data publication service for archaeology ',
'image': base_url + '/static/oc/images/index/oc-blue-square-logo.png',
'video': 'https://opencontext.wistia.com/medias/s0g0fsyqkz'
}
template = loader.get_template('about/index.html')
context = {
'base_url': base_url,
'page_title': 'Open Context: About',
'act_nav': 'about',
'og': open_graph,
'nav_items': settings.NAV_ITEMS
}
return HttpResponse(template.render(context, request))
else:
# client wanted a mimetype we don't support
return HttpResponse(req_neg.error_message,
status=415)
示例11: estimate_view
def estimate_view(request):
""" Get page with publication project cost estimation """
rp = RootPath()
base_url = rp.get_baseurl()
req_neg = RequestNegotiation('text/html')
if 'HTTP_ACCEPT' in request.META:
req_neg.check_request_support(request.META['HTTP_ACCEPT'])
if req_neg.supported:
# requester wanted a mimetype we DO support
open_graph = {
'twitter_site': settings.TWITTER_SITE,
'type': 'website',
'url': base_url + '/about/estimate',
'site_name': settings.CANONICAL_SITENAME,
'description': 'Estimate data publication and archiving '\
'costs with Open Context to help budget for '\
'grant data management plans',
'image': base_url + '/static/oc/images/index/oc-blue-square-logo.png',
'video': False
}
template = loader.get_template('about/estimate.html')
context = {
'base_url': base_url,
'page_title': 'Open Context: About - Cost Estimate',
'og': open_graph,
'act_nav': 'about',
'nav_items': settings.NAV_ITEMS
}
return HttpResponse(template.render(context, request))
else:
# client wanted a mimetype we don't support
return HttpResponse(req_neg.error_message,
status=415)
示例12: __init__
def __init__(self, id_href=True):
self.id = self.DOI # DOI for this
rp = RootPath()
base_url = rp.get_baseurl()
self.href = base_url + '/contexts/search.json' # URL for this
if id_href:
self.id = self.href
item_context_obj = ItemContext()
context = item_context_obj.context
self.geo_json_context = GeneralContext.GEO_JSON_CONTEXT_URI # link to geojson
context['opensearch'] = 'http://a9.com/-/spec/opensearch/1.1/'
context['totalResults'] = {'@id': 'opensearch:totalResults', '@type': 'xsd:integer'}
context['startIndex'] = {'@id': 'opensearch:startIndex', '@type': 'xsd:integer'}
context['itemsPerPage'] = {'@id': 'opensearch:itemsPerPage', '@type': 'xsd:integer'}
context['oc-api'] = 'http://opencontext.org/vocabularies/oc-api/'
context['oai-pmh'] = 'http://www.openarchives.org/OAI/2.0/'
context['rdfs:isDefinedBy'] = {'@type': '@id'}
context['first'] = {'@id': 'oc-api:first', '@type': '@id'}
context['previous'] = {'@id': 'oc-api:previous', '@type': '@id'}
context['next'] = {'@id': 'oc-api:next', '@type': '@id'}
context['last'] = {'@id': 'oc-api:last', '@type': '@id'}
context['first-json'] = {'@id': 'oc-api:first', '@type': '@id'}
context['previous-json'] = {'@id': 'oc-api:previous', '@type': '@id'}
context['next-json'] = {'@id': 'oc-api:next', '@type': '@id'}
context['last-json'] = {'@id': 'oc-api:last', '@type': '@id'}
context['count'] = {'@id': 'oc-api:count', '@type': 'xsd:integer'}
self.context = context
示例13: __init__
def __init__(self, uuid=None, request=None):
self.id_href = False # if True, use the local href as the Context's ID,
self.context_path = '/contexts/projects/' # path for the ID of the context resource
self.uuid = uuid
rp = RootPath()
self.base_url = rp.get_baseurl()
self.manifest = False
self.project_obj = False
self.edit_status = 0
self.edit_permitted = False
self.view_permitted = True
self.assertion_hashes = False
self.id = False
self.href = False
self.cannonical_href = False
self.json_ld = False
self.errors = []
self.pred_sql_dict_list = None
self.most_recent_date = None
self.refresh_cache = False
if uuid is not None:
if uuid is False or uuid == '0' or uuid == 'open-context':
self.uuid = '0'
self.manifest = Manifest()
self.manifest.uuid = '0'
self.manifest.project_uuid = '0'
self.manifest.label = 'Open Context (General)'
self.manifest.item_type = 'projects'
else:
self.dereference_uuid_or_slug(uuid)
self.set_uri_urls(self.uuid)
if request is not None:
self.check_permissions(request)
示例14: __init__
def __init__(self, id_href=True):
self.id = self.DOI # DOI for this
rp = RootPath()
base_url = rp.get_baseurl()
self.href = base_url + '/contexts/item.json' # URL for this
if id_href:
self.id = self.href
context = LastUpdatedOrderedDict()
context['rdf'] = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
context['rdfs'] = 'http://www.w3.org/2000/01/rdf-schema#'
context['xsd'] = 'http://www.w3.org/2001/XMLSchema#'
context['skos'] = 'http://www.w3.org/2004/02/skos/core#'
context['owl'] = 'http://www.w3.org/2002/07/owl#'
context['dc-terms'] = 'http://purl.org/dc/terms/'
context['dcmi'] = 'http://dublincore.org/documents/dcmi-terms/'
context['bibo'] = 'http://purl.org/ontology/bibo/'
context['foaf'] = 'http://xmlns.com/foaf/0.1/'
context['cidoc-crm'] = 'http://erlangen-crm.org/current/'
context['dcat'] = 'http://www.w3.org/ns/dcat#'
context['geojson'] = 'http://ld.geojson.org/vocab#'
context['cc'] = 'http://creativecommons.org/ns#'
context['oc-gen'] = 'http://opencontext.org/vocabularies/oc-general/'
context['oc-pred'] = 'http://opencontext.org/predicates/'
context['id'] = '@id'
context['label'] = 'rdfs:label'
context['uuid'] = 'dc-terms:identifier'
context['slug'] = 'oc-gen:slug'
context['type'] = '@type'
context['category'] = {'@id': 'oc-gen:category', '@type': '@id'}
context['Feature'] = 'geojson:Feature'
context['FeatureCollection'] = 'geojson:FeatureCollection'
context['GeometryCollection'] = 'geojson:GeometryCollection'
context['Instant'] = 'http://www.w3.org/2006/time#Instant'
context['Interval'] = 'http://www.w3.org/2006/time#Interval'
context['LineString'] = 'geojson:LineString'
context['MultiLineString'] = 'geojson:MultiLineString'
context['MultiPoint'] = 'geojson:MultiPoint'
context['MultiPolygon'] = 'geojson:MultiPolygon'
context['Point'] = 'geojson:Point'
context['Polygon'] = 'geojson:Polygon'
context['bbox'] = {'@id': 'geojson:bbox', '@container': '@list'}
context['circa'] = 'geojson:circa'
context['coordinates'] = 'geojson:coordinates'
context['datetime'] = 'http://www.w3.org/2006/time#inXSDDateTime'
context['description'] = 'dc-terms:description'
context['features'] = {'@id': 'geojson:features', '@container': '@set'}
context['geometry'] = 'geojson:geometry'
context['properties'] = 'geojson:properties'
context['start'] = 'http://www.w3.org/2006/time#hasBeginning'
context['stop'] = 'http://www.w3.org/2006/time#hasEnding'
context['title'] = 'dc-terms:title'
context['when'] = 'geojson:when'
context['reference-type'] = {'@id': 'oc-gen:reference-type', '@type': '@id'}
context['inferred'] = 'oc-gen:inferred'
context['specified'] = 'oc-gen:specified'
context['reference-uri'] = 'oc-gen:reference-uri'
context['reference-label'] = 'oc-gen:reference-label'
context['location-precision'] = 'oc-gen:location-precision'
context['location-note'] = 'oc-gen:location-note'
self.context = context
示例15: bibliography_view
def bibliography_view(request):
""" Get page about bibliography / publications """
request = RequestNegotiation().anonymize_request(request)
rp = RootPath()
base_url = rp.get_baseurl()
req_neg = RequestNegotiation('text/html')
if 'HTTP_ACCEPT' in request.META:
req_neg.check_request_support(request.META['HTTP_ACCEPT'])
if req_neg.supported:
# requester wanted a mimetype we DO support
open_graph = {
'twitter_site': settings.TWITTER_SITE,
'type': 'website',
'url': base_url + '/about/bibliography',
'site_name': settings.CANONICAL_SITENAME,
'description': 'Publications related to Open Context and its '\
'contributions to research data management, '\
'archaeological ethics, scholarly communications, and '\
'professional practice',
'image': base_url + '/static/oc/images/index/oc-blue-square-logo.png',
'video': False
}
template = loader.get_template('about/bibliography.html')
context = {
'base_url': base_url,
'page_title': 'Open Context: About - Bibliography',
'og': open_graph,
'act_nav': 'about',
'nav_items': settings.NAV_ITEMS
}
return HttpResponse(template.render(context, request))
else:
# client wanted a mimetype we don't support
return HttpResponse(req_neg.error_message,
status=415)