本文整理汇总了Python中opencontext_py.libs.rootpath.RootPath.get_baseurl方法的典型用法代码示例。如果您正苦于以下问题:Python RootPath.get_baseurl方法的具体用法?Python RootPath.get_baseurl怎么用?Python RootPath.get_baseurl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opencontext_py.libs.rootpath.RootPath
的用法示例。
在下文中一共展示了RootPath.get_baseurl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pub_view
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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)
示例2: html_view
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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
示例3: __init__
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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
示例4: terms_view
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
def terms_view(request):
""" Get the page about Terms """
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/terms',
'site_name': settings.CANONICAL_SITENAME,
'description': 'Terms and Conditions of Use, and '\
'Privacy Policies for Open Context',
'image': base_url + '/static/oc/images/index/oc-blue-square-logo.png',
'video': False
}
template = loader.get_template('about/terms.html')
context = {
'base_url': base_url,
'page_title': 'Open Context: About - Terms of Use and Privacy Policies',
'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)
示例5: field_types_more
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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
示例6: finalize
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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
示例7: services_view
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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)
示例8: field_entity_relations
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
def field_entity_relations(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()
if len(ip.fields) > 0:
ip.get_field_annotations()
ip.jsonify_field_annotations()
imnav = ImportNavigation()
ip.nav = imnav.set_nav('field-entity-relations',
ip.project_uuid,
source_id)
template = loader.get_template('imports/field-entity-relations.html')
context = RequestContext(request,
{'ip': ip,
'base_url': base_url})
return HttpResponse(template.render(context))
else:
redirect = '../../imports/field-types/' + source_id
return HttpResponseRedirect(redirect)
else:
raise Http404
示例9: index_view
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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)
示例10: estimate_view
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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)
示例11: __init__
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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
示例12: __init__
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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)
示例13: index
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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)
示例14: recipes_view
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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)
示例15: __init__
# 需要导入模块: from opencontext_py.libs.rootpath import RootPath [as 别名]
# 或者: from opencontext_py.libs.rootpath.RootPath import get_baseurl [as 别名]
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