Exemplo n.º 1
0
 def get_doc(self, key):
     if key.startswith("/subjects/"):
         s = worksearch.get_subject(key)
         if s.work_count > 0:
             return s
         else:
             return None
     else:
         return web.ctx.site.get(key)
Exemplo n.º 2
0
 def get_doc(self, key):
     if key.startswith("/subjects/"):
         s = worksearch.get_subject(key)
         if s.work_count > 0:
             return s
         else:
             return None
     else:
         return web.ctx.site.get(key)
Exemplo n.º 3
0
 def GET(self, path):
     if path.startswith("/subjects/"):
         doc = worksearch.get_subject(path)
     else:
         doc = web.ctx.site.get(path)
     if not doc:
         raise web.notfound()
         
     i = web.input(offset=0, limit=50)
     i.offset = h.safeint(i.offset, 0)
     i.limit = h.safeint(i.limit, 50)
     
     i.limit = min(i.limit, 100)
     i.offset = max(i.offset, 0)
     
     lists = self.get_lists(doc, limit=i.limit, offset=i.offset)
     return delegate.RawText(self.dumps(lists))
Exemplo n.º 4
0
    def GET(self, path):
        if path.startswith("/subjects/"):
            doc = worksearch.get_subject(path)
        else:
            doc = web.ctx.site.get(path)
        if not doc:
            raise web.notfound()

        i = web.input(offset=0, limit=50)
        i.offset = h.safeint(i.offset, 0)
        i.limit = h.safeint(i.limit, 50)

        i.limit = min(i.limit, 100)
        i.offset = max(i.offset, 0)

        lists = self.get_lists(doc, limit=i.limit, offset=i.offset)
        return delegate.RawText(self.dumps(lists))
Exemplo n.º 5
0
def get_subject(key):
    global worksearch
    if worksearch is None:
        from openlibrary.plugins.worksearch import code as worksearch
    return worksearch.get_subject(key)
Exemplo n.º 6
0
def get_subject(key):
    global worksearch
    if worksearch is None:
        from openlibrary.plugins.worksearch import code as worksearch
    return worksearch.get_subject(key)