Пример #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")
Пример #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()
Пример #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()
Пример #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")
Пример #5
0
def get(context, request, uid=None):
    """ get folders
    """
    return get_batched("Folder", uid=uid, endpoint="folders")
Пример #6
0
def get(context, request, uid=None):
    """ get topics
    """
    return get_batched("Topic", uid=uid, endpoint="topics")
Пример #7
0
def get(context, request, uid=None):
    """ get newsitems
    """
    return get_batched("News Item", uid=uid, endpoint="newsitems")
Пример #8
0
def get(context, request, uid=None):
    """ get documents
    """
    return get_batched("Document", uid=uid, endpoint="documents")
Пример #9
0
def get(context, request, uid=None):
    """ get events
    """
    return get_batched("Event", uid=uid, endpoint="events")
Пример #10
0
def get(context, request, uid=None):
    """ get images
    """
    return get_batched("Image", uid=uid, endpoint="images")
Пример #11
0
def get(context, request, uid=None):
    """ get documents
    """
    return get_batched("Document", uid=uid, endpoint="documents")
Пример #12
0
def get(context, request, uid=None):
    """ Plone sites
    """
    return get_batched("Plone Site", uid=uid, endpoint="plonesites")
Пример #13
0
 def test_get_batched(self):
     results = api.get_batched("Document")
     self.assertEqual(results["count"], 50)
     self.assertEqual(results["pages"], 2)
Пример #14
0
def get(context, request, uid=None):
    """ get files
    """
    return get_batched("File", request, uid=uid, endpoint="files")
Пример #15
0
def get(context, request, uid=None):
    """ get files
    """
    return get_batched("File", request, uid=uid, endpoint="files")
Пример #16
0
def get(context, request, uid=None):
    """ get links
    """
    return get_batched("Link", uid=uid, endpoint="links")
Пример #17
0
def get(context, request, uid=None):
    """ get collections
    """
    return get_batched("Collection", uid=uid, endpoint="collections")
Пример #18
0
def get(context, request, uid=None):
    """ get links
    """
    return get_batched("Link", uid=uid, endpoint="links")
Пример #19
0
def get(context, request):
    """ search all contents
    """
    return get_batched([])
Пример #20
0
def get(context, request, uid=None):
    """ get collections
    """
    return get_batched("Collection", uid=uid, endpoint="collections")
Пример #21
0
 def test_get_batched(self):
     results = api.get_batched("Document")
     self.assertEqual(results["count"], 50)
     self.assertEqual(results["pages"], 2)
Пример #22
0
def get(context, request):
    """ search all contents
    """
    return get_batched([])
Пример #23
0
def get(context, request, uid=None):
    """ get events
    """
    return get_batched("Event", uid=uid, endpoint="events")
Пример #24
0
def get(context, request, uid=None):
    """ get topics
    """
    return get_batched("Topic", uid=uid, endpoint="topics")
Пример #25
0
def get(context, request, uid=None):
    """ get newsitems
    """
    return get_batched("News Item", uid=uid, endpoint="newsitems")