예제 #1
0
 def login(self):
     if c.user:
         redirect(url(controller='account', action='index', id=None))
     else:
         c.error = request.params.get('error', '')
         form = render('account/openid_form.html')
         # /login_openid page need not exist -- request gets intercepted by openid plugin
         form = form.replace('FORM_ACTION', '/login_openid')
         return form
예제 #2
0
 def deliverance(self):
     from swiss.deliveranceproxy import create_deliverance_proxy
     # where we are proxying from
     proxy_base_url = config['deliverance.dest']
     theme_html = render('home/index.html')
     if not hasattr(self, '_deliverance'):
         self._deliverance = create_deliverance_proxy(
             proxy_base_url, theme_html)
         # self._deliverance = create_deliverance_proxy()
     return self._deliverance
예제 #3
0
    def index(self):
        cursor = handler.rdflib.store.cursor()
        q = """
PREFIX bibo: <http://purl.org/ontology/bibo/>
SELECT COUNT(?d) WHERE { ?d a bibo:Document }
"""
        for c.work_total, in handler.rdflib.query(q, cursor):
            pass
        cursor.close()
        return render('home/index.html')
예제 #4
0
 def view(self, username):
     ###
     ### should really use a lens (upgrade the bibo lens to
     ### understand about accounts and just display the
     ### account graph in here.
     ###
     ### *PARTICULARLY* because if we are asked for a
     ### content-type other than text/html we will want
     ### to give out an equivalent RDF description of the
     ### user. That is how users' activities on this site will
     ### get joined up to their activities on other sites.
     ###
     ### There should be no difference here from the
     ### graph controller. This is *NOT* a LAMP silo.
     ###
     c.is_myself = (username == c.user)
     c.account = model.Account.get_by_name(username)
     return render('account/view.html')
예제 #5
0
 def _get_graph(self):
     uri = self._uri()
     content_type, format = self._accept(uri)
     if uri.endswith("bibtex"):
         content_type = "text/x-bibtex"
         format = "bibtex"
         uri_str, _ = uri.rsplit(".", 1)
         uri = URIRef(uri_str)
     graph = handler.get(uri)
     if len(graph) == 0:
         graph.rollback()
         cursor = handler.rdflib.store.cursor()
         cursor.execute("SET result_timeout = 10000")
         q = construct_graph % {"agent": uri.n3()}
         graph = handler.rdflib.store.sparql_query(q, cursor=cursor)
         graph = Graph(graph.store,
                       identifier=graph.identifier)  # ordf extensions
         cursor.close()
         if len(graph) == 0:
             abort(404, "No such graph: %s" % uri)
     if format == "html":
         c.graph = graph
         c.model = model.Entry.get_by_uri(uri)
         response.content_type = str(content_type)
         # should really iterate through the potential views
         if URIRef("http://purl.org/ontology/bibo/Book") in list(
                 c.model.type):
             data = render("view_bibo_book.html")
         else:
             data = self._render_graph()
     elif format == "bibtex":
         b = Bibtex()
         b.load_from_graph(graph)
         data = b.to_bibtex()
         response.content_type = str(content_type)
         response.headers['Content-Location'] = "%s.bibtex" % b.uniquekey
         response.headers['Location'] = "%s.bibtex" % b.uniquekey
     else:
         data = graph.serialize(format=format)
         response.content_type = str(content_type)
     graph.rollback()
     #        log.warn("XXX cursor: %s" % handler.rdflib.store._cursor)
     return data
예제 #6
0
 def _render(self):
     # stuff other things in c
     return render('graph_fetch.html')
예제 #7
0
 def logout(self):
     if c.user:
         redirect('/logout_openid')
     c.user = None
     return render('account/logout.html')
예제 #8
0
 def index(self):
     c.accounts = [model.Account.get(id_) for id_ in model.Account.find()]
     return render('account/index.html')