Ejemplo n.º 1
0
	def _unprocess_arg(self, kind, value):
		if kind == dict:
			return json.dumps(value)
		elif kind == mongor.DBRef and isinstance(value, mongor.DBRef):
			return mongor.serialize_dbref(value)
		else:
			return value
Ejemplo n.º 2
0
	def dbinstance(self, dbrefserial):
		if isinstance(dbrefserial, mongor.DBRef):
			dbref = dbrefserial
			dbrefserial = mongor.serialize_dbref(dbrefserial)
		else:
			dbref = mongor.deserialize_dbref(dbrefserial)
		
		# look for instance - is this necessary or good?
		instance = mongor.Model.__instances__.get(dbrefserial)
		if instance: return instance
		
		# okay find the class
		cls = mongor.ModelMeta.__subclasses__.get(dbref.collection)
		if cls: return cls.get(dbref.id)