Esempio n. 1
0
 def __init__(self, json):
     """ takes in a json string
         Creates a new object
     """
     Document.__init__(self)
     self.from_json(json)
     self.validate()
Esempio n. 2
0
    def save(self, uuid=False, validate=None, safe=True, *args, **kwargs):

        # before save
        if not self['key']:
            self['key'] = self.generate_key()

        # save
        Document.save(self, uuid, validate, safe, *args, **kwargs)
Esempio n. 3
0
    def save(self, uuid=False, validate=None, safe=True, *args, **kwargs):
        Document.save(self, uuid, validate, safe, *args, **kwargs)

        owner_id = self['owner']
        if self['group']:
            group = connection.Group.find_one({'_id': owner_id})
            group['grades'].add(self['_id'])
            group.save()
            student_ids = group['members']
            for _id in student_ids:
                self.add_grade_to_student(_id)
        else:
            self.add_grade_to_student(owner_id)
Esempio n. 4
0
 def __getitem__(self, key):
     try:
         return Document.__getitem__(self, key)
     except KeyError:
         ans = self.default_values[key]
         if callable(ans):
             ans = ans()
         self[key] = ans
         self.save()
         return ans
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     # Document needs a lot of parameters
     Document.__init__(self, *args, **kwargs)
     self.authenticated = False
Esempio n. 6
0
 def __init__(self, *args, **kwargs):
     # Document needs a lot of parameters
     Document.__init__(self, *args, **kwargs)
     self.authenticated = False
Esempio n. 7
0
 def __init__(self, *args, **kwargs):
     # Document needs a lot of parameters
     Document.__init__(self, *args, **kwargs)
     # store the elo per player (before, after)
     self.elos_per_player = {}
Esempio n. 8
0
 def __setattr__(self, field, value):
     if field in self.keys():
         if isinstance(value, basestring):
             value = unicode(value)
         self[field] = value
     Document.__setattr__(self, field, value)
Esempio n. 9
0
 def __getattr__(self, field):
     if field in self.keys():
         return self[field]
     return Document.__getattr__(self, field)
Esempio n. 10
0
 def save(self, uuid=False, validate=None, safe=True, *args, **kwargs):
     self.before_save()
     Document.save(self, uuid, validate, safe, *args, **kwargs)
Esempio n. 11
0
 def __init__(self, *args, **kwargs):
     # Document needs a lot of parameters
     Document.__init__(self, *args, **kwargs)