コード例 #1
0
ファイル: taskcloud.py プロジェクト: jourdain/ec2_cloud
    def remove(self, task):
        """
        Delete a task.

        :param task: The task document to delete.
        :type task: dict
        """
        # Delete this task
        AccessControlledModel.remove(self, task)
コード例 #2
0
ファイル: challenge.py プロジェクト: girder/covalic
    def remove(self, challenge, progress=noProgress):
        # Remove all phases for this challenge
        phases = Phase().find({
            'challengeId': challenge['_id']
        }, limit=0)
        for phase in phases:
            Phase().remove(phase, progress=progress)
        phases.close()

        AccessControlledModel.remove(self, challenge)

        progress.update(increment=1,
                        message='Deleted challenge ' + challenge['name'])
コード例 #3
0
    def remove(self, challenge, progress=noProgress):
        # Remove all phases for this challenge
        phases = self.model('phase',
                            'covalic').find({'challengeId': challenge['_id']},
                                            limit=0)
        for phase in phases:
            self.model('phase', 'covalic').remove(phase, progress=progress)
        phases.close()

        AccessControlledModel.remove(self, challenge)

        progress.update(increment=1,
                        message='Deleted challenge ' + challenge['name'])
コード例 #4
0
    def setAccessList(self, doc, access, save=False, user=None, force=False,
                      setPublic=None, publicFlags=None):
        """
        Overrides AccessControlledModel.setAccessList to encapsulate ACL
        functionality for an image.

        :param doc: the image to set access settings on
        :type doc: girder.models.image
        :param access: The access control list
        :type access: dict
        :param save: Whether the changes should be saved to the database
        :type save: bool
        :param user: The current user
        :param force: Set this to True to set the flags regardless of the passed in
            user's permissions.
        :type force: bool
        :param setPublic: Pass this if you wish to set the public flag on the
            resources being updated.
        :type setPublic: bool or None
        :param publicFlags: Pass this if you wish to set the public flag list on
            resources being updated.
        :type publicFlags: flag identifier str, or list/set/tuple of them,
            or None
        """
        if setPublic is not None:
            self.setPublic(doc, setPublic, save=False)

        if publicFlags is not None:
            doc = self.setPublicFlags(doc, publicFlags, user=user, save=False,
                                      force=force)

        doc = AccessControlledModel.setAccessList(self, doc, access,
                                                  user=user, save=save, force=force)

        return doc
コード例 #5
0
ファイル: taskcloud.py プロジェクト: jourdain/ec2_cloud
    def load(self, id, level=AccessType.ADMIN, user=None, objectId=True,
             force=False, fields=None, exc=False):
        """
        We override load in order to ensure the task has certain fields
        within it, and if not, we add them lazily at read time.

        :param id: The id of the resource.
        :type id: string or ObjectId
        :param user: The user to check access against.
        :type user: dict or None
        :param level: The required access type for the object.
        :type level: AccessType
        :param force: If you explicity want to circumvent access
                      checking on this resource, set this to True.
        :type force: bool
        """
        print "try to load ", id
        doc = AccessControlledModel.load(
            self, id=id, objectId=objectId, level=level, fields=fields,
            exc=exc, force=force, user=user)

        print 'got'
        print doc

        if doc is not None and 'baseParentType' not in doc:
            pathFromRoot = self.parentsToRoot(doc, user=user, force=force)
            baseParent = pathFromRoot[0]
            doc['baseParentId'] = baseParent['object']['_id']
            doc['baseParentType'] = baseParent['type']
            self.save(doc)
        if doc is not None and 'lowerName' not in doc:
            self.save(doc)

        return doc
コード例 #6
0
ファイル: job.py プロジェクト: ziqiangxu/girder
 def save(self, job, *args, **kwargs):
     """
     We extend save so that we can serialize the kwargs before sending them
     to the database. This will allow kwargs with $ and . characters in the
     keys.
     """
     job['kwargs'] = json_util.dumps(job['kwargs'])
     job = AccessControlledModel.save(self, job, *args, **kwargs)
     job['kwargs'] = json_util.loads(job['kwargs'])
     return job
コード例 #7
0
ファイル: job.py プロジェクト: girder/girder
 def save(self, job, *args, **kwargs):
     """
     We extend save so that we can serialize the kwargs before sending them
     to the database. This will allow kwargs with $ and . characters in the
     keys.
     """
     job['kwargs'] = json_util.dumps(job['kwargs'])
     job = AccessControlledModel.save(self, job, *args, **kwargs)
     job['kwargs'] = json_util.loads(job['kwargs'])
     return job
コード例 #8
0
ファイル: job.py プロジェクト: salamb/girder
    def load(self, *args, **kwargs):
        """
        We extend load to deserialize the kwargs back into a dict since we
        serialized them on the way into the database.
        """
        job = AccessControlledModel.load(self, *args, **kwargs)

        if job and isinstance(job['kwargs'], six.string_types):
            job['kwargs'] = json_util.loads(job['kwargs'])

        return job
コード例 #9
0
ファイル: job.py プロジェクト: 0x414A/girder
    def load(self, *args, **kwargs):
        """
        We extend load to deserialize the kwargs back into a dict since we
        serialized them on the way into the database.
        """
        job = AccessControlledModel.load(self, *args, **kwargs)

        if job and isinstance(job['kwargs'], six.string_types):
            job['kwargs'] = json_util.loads(job['kwargs'])

        return job