Exemplo n.º 1
0
def get(context, request, resource=None, uid=None):
    """Get Plone contents, e.g.

    <Plonesite>/@@API/plone/api/1.0/folder -> returns all folders
    <Plonesite>/@@API/plone/api/1.0/folder/4711 -> returns the folder with UID 4711
    """

    # We have a UID, return the record
    if uid and not resource:
        return api.get_record(uid)

    # we have a UID as resource, return the record
    if api.is_uid(resource):
        return api.get_record(resource)

    # BBB
    if resource == "get":
        logger.warn(
            "The /get route is obsolete and will be removed in 1.0.0. Please use /<UID> instead"
        )
        return api.get_record(uid)

    portal_type = api.resource_to_portal_type(resource)
    if portal_type is None:
        raise APIError(404, "Not Found")
    return api.get_batched(portal_type=portal_type,
                           uid=uid,
                           endpoint="plone.jsonapi.routes.get")
Exemplo n.º 2
0
def search(context, request):
    """Generic search route

    <Plonesite>/@@API/plone/api/1.0/search -> returns all contents of the portal
    <Plonesite>/@@API/plone/api/1.0/search?portal_type=Folder -> returns only folders
    ...
    """
    return api.get_batched()
Exemplo n.º 3
0
def search(context, request):
    """Generic search route

    <Plonesite>/@@API/plone/api/1.0/search -> returns all contents of the portal
    <Plonesite>/@@API/plone/api/1.0/search?portal_type=Folder -> returns only folders
    ...
    """
    return api.get_batched()
Exemplo n.º 4
0
def get(context, request, resource=None, uid=None):
    """Get Plone contents, e.g.

    <Plonesite>/@@API/plone/api/1.0/folder -> returns all folders
    <Plonesite>/@@API/plone/api/1.0/folder/4711 -> returns the folder with UID 4711
    """

    # We have a UID, return the record
    if uid and not resource:
        return api.get_record(uid)

    # we have a UID as resource, return the record
    if api.is_uid(resource):
        return api.get_record(resource)

    # BBB
    if resource == "get":
        logger.warn("The /get route is obsolete and will be removed in 1.0.0. Please use /<UID> instead")
        return api.get_record(uid)

    portal_type = api.resource_to_portal_type(resource)
    if portal_type is None:
        raise APIError(404, "Not Found")
    return api.get_batched(portal_type=portal_type, uid=uid, endpoint="plone.jsonapi.routes.get")
Exemplo n.º 5
0
def get(context, request, uid=None):
    """ get folders
    """
    return get_batched("Folder", uid=uid, endpoint="folders")
Exemplo n.º 6
0
def get(context, request, uid=None):
    """ get topics
    """
    return get_batched("Topic", uid=uid, endpoint="topics")
Exemplo n.º 7
0
def get(context, request, uid=None):
    """ get newsitems
    """
    return get_batched("News Item", uid=uid, endpoint="newsitems")
Exemplo n.º 8
0
def get(context, request, uid=None):
    """ get documents
    """
    return get_batched("Document", uid=uid, endpoint="documents")
Exemplo n.º 9
0
def get(context, request, uid=None):
    """ get events
    """
    return get_batched("Event", uid=uid, endpoint="events")
Exemplo n.º 10
0
def get(context, request, uid=None):
    """ get images
    """
    return get_batched("Image", uid=uid, endpoint="images")
Exemplo n.º 11
0
def get(context, request, uid=None):
    """ get documents
    """
    return get_batched("Document", uid=uid, endpoint="documents")
Exemplo n.º 12
0
def get(context, request, uid=None):
    """ Plone sites
    """
    return get_batched("Plone Site", uid=uid, endpoint="plonesites")
Exemplo n.º 13
0
 def test_get_batched(self):
     results = api.get_batched("Document")
     self.assertEqual(results["count"], 50)
     self.assertEqual(results["pages"], 2)
Exemplo n.º 14
0
def get(context, request, uid=None):
    """ get files
    """
    return get_batched("File", request, uid=uid, endpoint="files")
Exemplo n.º 15
0
def get(context, request, uid=None):
    """ get files
    """
    return get_batched("File", request, uid=uid, endpoint="files")
Exemplo n.º 16
0
def get(context, request, uid=None):
    """ get links
    """
    return get_batched("Link", uid=uid, endpoint="links")
Exemplo n.º 17
0
def get(context, request, uid=None):
    """ get collections
    """
    return get_batched("Collection", uid=uid, endpoint="collections")
Exemplo n.º 18
0
def get(context, request, uid=None):
    """ get links
    """
    return get_batched("Link", uid=uid, endpoint="links")
Exemplo n.º 19
0
def get(context, request):
    """ search all contents
    """
    return get_batched([])
Exemplo n.º 20
0
def get(context, request, uid=None):
    """ get collections
    """
    return get_batched("Collection", uid=uid, endpoint="collections")
Exemplo n.º 21
0
 def test_get_batched(self):
     results = api.get_batched("Document")
     self.assertEqual(results["count"], 50)
     self.assertEqual(results["pages"], 2)
Exemplo n.º 22
0
def get(context, request):
    """ search all contents
    """
    return get_batched([])
Exemplo n.º 23
0
def get(context, request, uid=None):
    """ get events
    """
    return get_batched("Event", uid=uid, endpoint="events")
Exemplo n.º 24
0
def get(context, request, uid=None):
    """ get topics
    """
    return get_batched("Topic", uid=uid, endpoint="topics")
Exemplo n.º 25
0
def get(context, request, uid=None):
    """ get newsitems
    """
    return get_batched("News Item", uid=uid, endpoint="newsitems")