コード例 #1
0
ファイル: model.py プロジェクト: Afrankie/FoodSharing
 def __init__(self, id: int):
     self.id = id
     pdata = to_dict(r.hgetall('post:{}'.format(self.id)))
     self.userid = pdata['userid']
     self.content = pdata['content']
     self.title = pdata['title']
     self.posttime = pdata['posttime']
     self.faceimage = pdata['faceimage']
コード例 #2
0
ファイル: model.py プロジェクト: Afrankie/FoodSharing
 def __init__(self, id: str):
     self.id = str(id)
     udata = to_dict(r.hgetall('user:{}'.format(self.id)))
     self.username = udata['username']
     self.image = udata['image']
     self.gender = udata['gender']
     self.city = udata['city']
     self.intro = udata['intro']
     self.province = udata['province']
     self.bgimage = udata['bgimage']
コード例 #3
0
 def processRequest( self, action, params ):
   """
     Process a request handling each of a set of possible actions.
   """
   if action == 'create':
     result = self.createDoc( params )
     return convert.to_dict( result, 'x-search-api-doc' )
   elif action == 'delete':
     return self.deleteDoc( params.get( 'id' ) )
   elif action == 'update':
     result = self.updateDoc( self.makeDoc( params, params.get( 'id' ) ) )
     return convert.to_dict( result, 'x-search-api-doc' )
   elif action == 'search':
     result = self.searchDoc( params.get( 'query' ) )
     return [ convert.to_dict( doc, 'x-search-api-doc' ) for doc in result ]
   elif action == 'read':
     result = self.readDoc( params.get( 'id' ) )
     return convert.to_dict( result, 'x-search-api-doc' )
   else:
     raise TypeError( "Action %s must be one of create, delete, update, search or read. It is not." % action )
コード例 #4
0
ファイル: model.py プロジェクト: Afrankie/FoodSharing
 def __init__(self, id: int):
     self.id = id
     mdata = to_dict(r.hgetall('messages:{}'.format(self.id)))
     self.content = mdata['content']
     self.username = mdata['username']
     self.image = mdata['image']
     self.uid = mdata['uid']
     self.time = mdata['time']
     self.type = mdata['type']
     if mdata['type'] != 'comment':
         self.operate = mdata['operate']
         if mdata['type'] == 'tcomment':
             self.whouid = mdata['whouid']
             self.who = mdata['who']
         else:
             self.whouid = ''
             self.who = ''
     else:
         self.refercontent = mdata['refercontent']
コード例 #5
0
  def post( self, 
      input_format = 'x-www-form-urlencoded', 
      output_format = 'html' ):
    """
      A standard post method that accepts data,
      handles converting from the input format,
      processes the request, and returns the response
      also handling converting to the output format.
    """
    params = None
    result = dict()
    output = None

    # convert from input format
    params = convert.to_dict( self.request, input_format )
    action = params.get( 'action' )
    # process input to output
    result = self.processRequest( action, params )
    # convert to output format
    output = convert.from_dict( result, output_format )
    self.response.out.write( output )
コード例 #6
0
ファイル: model.py プロジェクト: Afrankie/FoodSharing
 def userinfo(self) -> dict:
     return to_dict(r.hgetall('user:{}'.format(self.id)))
コード例 #7
0
ファイル: model.py プロジェクト: Afrankie/FoodSharing
 def info(self):
     cdata = to_dict(r.hgetall('comments:{}'.format(self.id)))
     return cdata
コード例 #8
0
ファイル: model.py プロジェクト: Afrankie/FoodSharing
 def getLocation(self):
     return to_dict(r.hgetall('post:{}:location'.format(self.id)))
コード例 #9
0
 def users():
     users = to_dict(r.hgetall('users'))
     return [User(uid) for username, uid in users.items()]
コード例 #10
0
 def __init__(self, id: int):
     self.id = int(id)
     udata = to_dict(r.hgetall('user:{}'.format(self.id)))
     self.username = udata['username']
     self.password = udata['password']