def get_schema(self):
     """Get the schema
     """
     try:
         return self.context.Schema()
     except AttributeError:
         raise APIError(400, "Can not get Schema of %r" % self.context)
Exemple #2
0
def get(context, request, resource=None, uid=None):
    """GET
    """
    # we have a UID as resource, return the record
    if api.is_uid(resource):
        return api.get_record(resource)

    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="bika.lims.jsonapi.v2.get")
Exemple #3
0
def get(context, request, resource=None, uid=None):
    """GET
    """
    if bika_api.is_uid(resource):
        return bika_api.get_record(resource)

    portal_type = bika_api.resource_to_portal_type(resource)
    if portal_type is None:
        raise APIError(404, "Not Found")
    return bika_api.get_batched(context,
                                portal_type=portal_type,
                                uid=uid,
                                endpoint="baobab.lims.jsonapi.get")
Exemple #4
0
def fail(status, msg):
    """API Error
    """
    if msg is None:
        msg = "Reason not given."
    raise APIError(status, "{}".format(msg))