Beispiel #1
0
    def read(cls, user, pk, result_fieldgroups=[]):
        """ Read the requested item and return a dict with the fields specified
        in ``Meta.resultfields`` and additional fields specified in
        ``result_fieldgroups``.

        :param user: Django user object.
        :param pk: Id of object or kwargs to the get method of the configured model.
        :param result_fieldgroups:
            Fieldgroups from the additional_fieldgroups specified in
            ``result_fieldgroups``.

        :throws PermissionDenied:
            If the given user does not have permission to view this object, or
            if the object does not exist.
        """
        obj = cls._readauth_get(user, pk) # authorization in cls._readauth_get
        resultfields = cls._meta.resultfields.aslist(result_fieldgroups)
        return modelinstance_to_dict(obj, resultfields)
 def __iter__(self):
     """ Iterate over all items in the result, yielding a dict
     containing the result data for each item. """
     for item in self._insecure_django_qryset.all():
         yield modelinstance_to_dict(item, self.resultfields)
 def __getitem__(self, index):
     """ Get the result at the given ``index`` as a dict. """
     return modelinstance_to_dict(self._insecure_django_qryset[index],
                                  self.resultfields)
 def __iter__(self):
     """ Iterate over all items in the result, yielding a dict
     containing the result data for each item. """
     for item in self._insecure_django_qryset.all():
         yield modelinstance_to_dict(item, self.resultfields)
 def __getitem__(self, index):
     """ Get the result at the given ``index`` as a dict. """
     return modelinstance_to_dict(self._insecure_django_qryset[index],
                                  self.resultfields)