Пример #1
0
 def process_insert(self, incoming):
     errs = enforce_datatypes(self.schema, incoming)
     if errs:
         return (None, errs)
         
     data = generate_prototype(self.schema)
     merge(data, incoming)
     fill_in_prototypes(self.schema, data)
     run_auto_funcs(self.schema, data)
     
     errs = enforce_schema_behaviors(self.schema, data, self)
     if errs:
         return (None, errs)
         
     return (data, [])
Пример #2
0
    def process_update(self, incoming):
        assert '_id' in incoming, "Cannot update document without _id attribute"
        
        errs = enforce_datatypes(self.schema, incoming)
        if errs:
            return (None, errs)

        data = self.coll.find_one({"_id":incoming["_id"]})
        merge(data, incoming)
        fill_in_prototypes(self.schema, data)
        run_auto_funcs(self.schema, data)

        errs = enforce_schema_behaviors(self.schema, data, self)
        if errs:
            return (None, errs)
            
        return (data, [])
Пример #3
0
 def process_direct_update(self, incoming):
     data = self.coll.find_one({"_id":incoming["_id"]})
     merge(data, incoming)
     fill_in_prototypes(self.schema, data)
     run_auto_funcs(self.schema, data)
     return (data, [])
Пример #4
0
 def process_direct_insert(self, incoming):
     data = generate_prototype(self.schema)
     merge(data, incoming)
     fill_in_prototypes(self.schema, data)
     run_auto_funcs(self.schema, data)
     return (data, [])