Exemplo n.º 1
0
 def _save_user(self, data):
     #assert data is a User. Visitor pattern.
     values = {
             'name': data.name,
             'auth': 'password',
             'credential': None,
             'uid': self.uid,
             'sid': self.sid,
             #'metadata': data.metadata
         }
     #@TODO: don't do that if data.uid != None
     status, resp =  self.ucengine.request('GET',
         '/find/user/?%s' % urllib.urlencode({
             'by_name': data.name,
             'uid':self.uid,
             'sid': self.sid}))
     if status == 200:
         data.uid = resp['result']['uid']
         status, resp = self.ucengine.request('PUT',
             '/user/%s' % data.uid,
             unicode_urlencode(values)
         )
         assert status == 200
     else:
         status, resp = self.ucengine.request('POST',
             '/user',
             unicode_urlencode(values)
         )
         print status, resp
         assert status == 201
Exemplo n.º 2
0
 def _save_meeting(self, data):
     values = {
         'start': data.start,
         'end': data.end,
         'metadata': data.metadata,
         'uid': self.uid,
         'sid': self.sid,
      }
     status, resp = self.ucengine.request('GET',
         '/meeting/all/%s?%s' % (data.name),
         urllib.urlencode({'uid':self.uid, 'sid': self.sid}))
     if status == 200:
         status, resp = self.ucengine.request('PUT',
         '/meeting/all/%s' % data.name,
         unicode_urlencode(values))
         assert status == 200
     else:
         status, resp = self.ucengine.request('POST',
         '/meeting/all/',
         unicode_urlencode(values))
         assert status == 201