def get(self):
     if request.args.get('action') == 'search':
         return {'books': [b.dict() for b in search(api.Book)]}
     return {
         'books': [book.dict() for book in 
                  api.Book.all()]
     }
 def get(self, cls, _id=None):
     if not graph.core.models.get(cls) or cls in PRIVATE_ENDPOINTS:
         return {"error": "Invalid endpoint"}
     if request.args.get('action') == 'search':
         return {cls: [r.dict() for r in search(graph.core.models[cls])]}
     if _id:
         return graph.core.models[cls].get(_id).dict(minimal=False)
     return {cls: [v.dict(minimal=True) for v in graph.core.models[cls].all()]}
Beispiel #3
0
def app(environ, start_response):
    status = '200 OK'
    response_headers = [
        ('Content-type', 'html'),
    ]

    start_response(status, response_headers)

    # ROUTING
    if environ["PATH_INFO"] == "/search":
        return [search(environ).encode("utf-8")]
    if environ["PATH_INFO"] == "/teambuilder":
        return [teamBuilder(environ).encode("utf-8")]
    if environ["PATH_INFO"] == "/":
        return [frontpage(environ).encode("utf-8")]
    #else not found
    return [notFound(environ).encode("utf-8")]
 def get(self):
     if request.args.get('action') == 'search':
         return {'books': [b.dict() for b in search(api.Book)]}
     return {'books': [book.dict() for book in api.Book.all()]}
Beispiel #5
0
 def get(self, cls):
     if request.args.get('action') == 'search':
         return search(graph.core.models[cls])
     return graph.db.query(graph.core.models[cls])
Beispiel #6
0
 def get(self, cls):
     if request.args.get("action") == "search":
         return search(graph.core.models[cls])
     return graph.db.query(graph.core.models[cls])
Beispiel #7
0
 def get(self, cls, _id=None):
     if request.args.get('action') == 'search':
         return {cls: [r.dict() for r in search(todo.core.models[cls])]}
     if _id:
         return todo.core.models[cls].get(_id).dict()
     return {cls: [v.dict() for v in todo.core.models[cls].all()]}
Beispiel #8
0
 def test_api_search_failure(self):
     from api import APIException
     from views import search
     search_result = lambda : search('test', 'Wrong access token')
     self.assertRaises(APIException, search_result)
Beispiel #9
0
 def test_api_search(self):
     from views import search
     access_token = u'AAAAAAAAAAAAAAAAAAAAAEtYdwAAAAAAmsMTQS0s7IMdYRKSxLenW%2BR2%2Fq4%3DbjQjzkdJD6ESKHMMXkTRMlhXlXqu3zpW0HRFNwadoVyE0tqn9l'
     search_result = search('test', access_token)
     self.assertEqual(len(search_result), 15)