예제 #1
0
	def put(self):
		"""These need to be unique, so if we don't have an ID we
		search for another authorization with all the same properties"""
		if not self.id:
			for obj in self.find(auth_group=self.auth_group, method=self.method, obj_name=self.obj_name, prop_name=self.prop_name):
				self.id = obj.id
				break
		Model.put(self)
예제 #2
0
    def put(self):
        """These need to be unique, so if we don't have an ID we
		search for another authorization with all the same properties"""
        if not self.id:
            for obj in self.find(auth_group=self.auth_group,
                                 method=self.method,
                                 obj_name=self.obj_name,
                                 prop_name=self.prop_name):
                self.id = obj.id
                break
        Model.put(self)
예제 #3
0
파일: model.py 프로젝트: ssalkeld/botoweb
def _findSubQueries(cls, qs):
        """Find any possible sub-queries in this query
        This is a complicated bit of parsing which essentially
        allows for nested sub-queries"""
        # If there's no "[" in it, just return the query
        if not "[" in qs:
                return qs
        # Otherwise, we split this apart, 
        # the retQ is the return query we're
        # building, and the leftovers still need
        # to be processed
        (retQ, leftovers) = qs.split("[", 1)
        leftovers = _findSubQueries(cls, leftovers).split("]", 1)
        subQ = leftovers[0].strip()

        # Now that we FOUND the sub query, we need to 
        # perform the query, and insert the IDs in
        # it's place
        # Step 1, find the model to use
        (model_name, q2) = subQ.split(" ", 1)
        model = CoreModel.find_subclass(model_name)
        if not model:
                raise Exception, "Error, model: %s not found" % model_name
        subq_results = query(model, q2)
        # A limit placed here to prevent catostrophic failures, 
        # you can't really make this much higher or bad things happen
        subq_results.limit = 30

        ids = ["'%s'" % obj.id for obj in subq_results]
        retQ += "(%s)" % ",".join(ids)
        if len(leftovers) > 1:
                retQ += leftovers[1]

        return retQ
예제 #4
0
def _findSubQueries(cls, qs):
    """Find any possible sub-queries in this query
        This is a complicated bit of parsing which essentially
        allows for nested sub-queries"""
    # If there's no "[" in it, just return the query
    if not "[" in qs:
        return qs
    # Otherwise, we split this apart,
    # the retQ is the return query we're
    # building, and the leftovers still need
    # to be processed
    (retQ, leftovers) = qs.split("[", 1)
    leftovers = _findSubQueries(cls, leftovers).split("]", 1)
    subQ = leftovers[0].strip()

    # Now that we FOUND the sub query, we need to
    # perform the query, and insert the IDs in
    # it's place
    # Step 1, find the model to use
    (model_name, q2) = subQ.split(" ", 1)
    model = CoreModel.find_subclass(model_name)
    if not model:
        raise Exception, "Error, model: %s not found" % model_name
    subq_results = query(model, q2)
    # A limit placed here to prevent catostrophic failures,
    # you can't really make this much higher or bad things happen
    subq_results.limit = 30

    ids = ["'%s'" % obj.id for obj in subq_results]
    retQ += "(%s)" % ",".join(ids)
    if len(leftovers) > 1:
        retQ += leftovers[1]

    return retQ
예제 #5
0
    def to_dict(self, *args, **kwargs):
        """Get this object as a simple dict, to be serialized.
		This just adds in the authorizations in addition to the
		rest of the object that is serialized via Model.to_dict"""
        ret = Model.to_dict(self, *args, **kwargs)
        if not self.authorizations:
            self.load_auths()
        ret['authorizations'] = self.authorizations
        return ret
예제 #6
0
파일: user.py 프로젝트: Web5design/botoweb
	def to_dict(self, *args, **kwargs):
		"""Get this object as a simple dict, to be serialized.
		This just adds in the authorizations in addition to the
		rest of the object that is serialized via Model.to_dict"""
		ret = Model.to_dict(self, *args, **kwargs)
		if not self.authorizations:
			self.load_auths()
		ret['authorizations'] = self.authorizations
		return ret
예제 #7
0
파일: user.py 프로젝트: ssalkeld/botoweb
	def put(self):
		"""Auto-index"""
		self._indexed_name = self.name.upper().strip()
		return Model.put(self)
예제 #8
0
 def put(self):
     """Auto-index"""
     self._indexed_name = self.name.upper().strip()
     return Model.put(self)