Beispiel #1
0
    def _on_access_token(self, callback, response):
        if response.error:
            logging.warning("Could not fetch access token")
            callback(None)
            return

        uid = self.get_secure_cookie("uid")
        if not uid:
            logging.warn("No user session: redirecting to root")
            return self.redirect("/")

        # NOTE that we assume the user has only one GMail account here!
        # This may be okay given that Google is moving towards single-login/multiple-account
        # but it could be a problem.
        access_token = tornado.auth._oauth_parse_response(response.body)
        session = model.Session()
        user = model.user(session, uid)
        id = user.identity(session, model.OP_GOOGLE)
        if id:
            id.accessToken = access_token["key"]
            id.accessSecret = access_token["secret"]
            session.add(id)
            session.commit()
        else:  # strange, we have no id for this user
            self.write(
                "Whoops - we don't have an authenticated Google login for you.  That's weird."
            )
            self.finish()
            return

        self.write(
            "Success.  Saved access codes for Google.  <a href='/fetch/google'>Take a look</a>"
        )
        self.finish()
Beispiel #2
0
  def get(self):
    uid = self.get_secure_cookie("uid")
    if not uid:
      logging.warn("No user session: redirecting to root")
      return self.redirect("/")

    args = {"max-results":1000}
    page = self.get_argument("page", None)

    session = model.Session()
    user = model.user(session, uid)
    id = user.identity(session, model.OP_GOOGLE)

    access_token = {"key":id.accessToken, "secret":id.accessSecret}
    url = "http://www.google.com/m8/feeds/contacts/default/full"
      
    if access_token:
        all_args = {}
        all_args.update(args)
        consumer_token = self._oauth_consumer_token()
        oauth = self._oauth_request_parameters(url, access_token, all_args, method="GET")
        args.update(oauth)

    if args: url += "?" + urllib.urlencode(args)
    callback = self.async_callback(self.onFetch)
    http = tornado.httpclient.AsyncHTTPClient()
    http.fetch(url, callback=callback)
Beispiel #3
0
  def get(self):
    uid = self.get_secure_cookie("uid")
    if not uid:
      logging.warn("No user session: redirecting to root")
      return self.redirect("/")

    args = {"count":"max", "format":"json"}
    page = self.get_argument("page", None)

    session = model.Session()
    user = model.user(session, uid)
    id = user.identity(session, model.OP_YAHOO)

    access_token = {"key":id.accessToken, "secret":id.accessSecret}
    url = "http://social.yahooapis.com/v1/user/" + id.opaqueID + "/contacts"
      
    if access_token:
        all_args = {}
        all_args.update(args)
        consumer_token = self._oauth_consumer_token()
        oauth = self._oauth_request_parameters(url, access_token, all_args, method="GET")
        args.update(oauth)

    if args: url += "?" + urllib.urlencode(args)
    callback = self.async_callback(self.onFetch)
    http = tornado.httpclient.AsyncHTTPClient()
    http.fetch(url, callback=callback)
    def irc_353(self, command, prefix, args):
        """ names list, shown when joining a channel 
        
            Currently, intercept 353 to build a userlist for channel. This
            means that doing a NAMES by hand will not result in any output.
            This can be changed if we use 366 (end of names) to mark a
            channel 'complete'
        """
        channel = args[2]
        # filter out empty spaces, remainder may end in ' '
        names = filter(None, split(args[-1], ' '))
        
        modemap = { None:model.user.MODE_NONE,
                    '@':model.user.MODE_OP, 
                    '+':model.user.MODE_VOICE }

        c = self.serverState.getChannel(channel)
        for i in names:
            name,mode = nickparse(i)
            u = c.getuser(name)
            if not u:
                c.adduser(model.user(name, modemap[mode])) # , mode
                self.channels[channel].adduser(name, mode)
            else: # use mode to update modes
                self.channels[channel].usermodechange(name, mode)
                u.setmode(modemap[mode])
Beispiel #5
0
  def get(self):

    uid = self.get_secure_cookie("uid")
    if not uid:
      logging.warn("No user session: redirecting to root")
      return self.redirect("/")

    session = model.Session()
    user = model.user(session, uid)
    id = user.identity(session, model.OP_GOOGLE)
    access_token = {"key":id.accessToken, "secret":id.accessSecret}

    # TODO could fill in arguments here...
    args = {}
    post_args = None

    rsrc = self.get_argument("rsrc", None)
    url = rsrc
      
    if access_token:
        all_args = {}
        all_args.update(args)
        consumer_token = self._oauth_consumer_token()
        method = "POST" if post_args is not None else "GET"
        oauth = self._oauth_request_parameters(
            url, access_token, all_args, method=method)
        args.update(oauth)
    if args: url += "?" + urllib.urlencode(args)
    callback = self.async_callback(self.onFetch)
    http = tornado.httpclient.AsyncHTTPClient()
    if post_args is not None:
        http.fetch(url, method="POST", body=urllib.urlencode(post_args),
                   callback=callback)
    else:
        http.fetch(url, callback=callback)
Beispiel #6
0
def admin_create_user(request, environment, session):
    """
    creates a new user and adds it to the database.

    Possible errortypes are:
     *
    May raise the following Exceptions:
     *
    """
    class CreateUserForm(Form):
        username = TextField('Username', [validators.Required()])
        password = TextField('Password', [validators.Required()])

    if request.method == 'POST':
        form = CreateUserForm(request.form)
        if form.validate():
            username = form.username.data.strip()
            password = form.password.data
            #TODO: hash password
            u = model.user(username, password)
            session.add(u)
            try:
                session.commit()
            except IntegrityError:
                return render_template("admin_create_user.htmljinja",
                                       environment, success=False, form=form)

            return redirect('/admin/users/view')
        else:
            return render_template("admin_create_user.htmljinja", environment,
                                   success=False, form=form)
    else:
        form = CreateUserForm()
        return render_template("admin_create_user.htmljinja", environment,
                               form=form)
Beispiel #7
0
def join_room(game_id):
    if not room_exists(game_id):
        return room_not_found()

    current_room = rooms.get_map().get(game_id, None)
    request_json = request.json
    user_name = request_json['user_name']

    try:
        current_room.add_user(
            user(name=user_name, colour=request_json['colour']))
    except KeyError:
        return user_exists()

    expiry = datetime.utcnow() + timedelta(
        hours=5)  # expire this room in 5 hours, not sure if should be used
    user_token = jwt.encode({
        'role': 'user',
        'name': user_name,
        'exp': expiry
    },
                            app.config['SECRET_KEY'],
                            algorithm='HS256').decode('utf8')
    res = {"token": user_token}
    return jsonify(res), status.HTTP_200_OK
    def irc_NICK(self, command, prefix, args):
        oldnick = getnick(prefix)
        newnick = args[-1]
        isme = self.isme(oldnick)

        if isme:
            self.serverState.nick = newnick
            # log this? Where?
        for name, chan in self.serverState.getChannels():
            if chan.getuser(oldnick):
                # XXX can this be done in viewtext.nickchange?
                self.channels[name].nickchange(oldnick, newnick)
                # pass the nickchange to model as well
                # as in ircView, it may be smarter to combine the 2 below
                chan.deluser(oldnick)
                chan.adduser(model.user(newnick))
                self.logger.log(name, "*** %s is now known as %s" % \
                                (oldnick, newnick))
        # Track nickchanges in querywindows
        self.viewtext.nickchange(oldnick, newnick, isme)
        if self.queries.has_key(oldnick):
            q = self.queries[oldnick]
            del self.queries[oldnick]
            # XXX move this to viewtext.nickchange as well?
            q.announce("%s is now known as %s" % (oldnick, newnick))
            self.queries[newnick] = q
            # perhaps log to newnick as well? Or perhaps not log at all?
            self.logger.log(oldnick, "*** %s is now known as %s" % \
                            (oldnick, newnick))
        else:
            msg = self.viewtext.get_msgwin(create=0)
            if msg:
                msg.nickchange(oldnick, newnick)
  def _on_access_token(self, callback, response):
    if response.error:
        logging.warning("Could not fetch access token")
        callback(None)
        return

    uid = self.get_secure_cookie("uid")
    if not uid:
      logging.warn("No user session: redirecting to root")
      return self.redirect("/")
    
    # NOTE that we assume the user has only one GMail account here! 
    # This may be okay given that Google is moving towards single-login/multiple-account
    # but it could be a problem.
    access_token = tornado.auth._oauth_parse_response(response.body)
    session = model.Session()
    user = model.user(session, uid)
    id = user.identity(session, model.OP_GOOGLE)
    if id:
      id.accessToken = access_token["key"]
      id.accessSecret = access_token["secret"]
      session.add(id)
      session.commit()
    else: # strange, we have no id for this user
      self.write("Whoops - we don't have an authenticated Google login for you.  That's weird.")
      self.finish()
      return
    
    self.write("Success.  Saved access codes for Google.  <a href='/fetch/google'>Take a look</a>")
    self.finish()
Beispiel #10
0
 def index(self):
     users = model.user().getList('*')  ##进行表查询
     self.assign('users', users)  ##设置为模板变量
     group = model.groups().getList('*')
     self.assign('group', group)
     forum = model.forum().getList('*')
     self.assign('forum', forum)
     return self.display('index')  ##显示指定模板
Beispiel #11
0
 def index(self):
     users = model.user().getList('*')  ##进行表查询
     self.assign('users', users)  ##设置为模板变量
     group = model.groups().getList('*')
     self.assign('group', group)
     forum = model.forum().getList('*')
     self.assign('forum', forum)
     return self.display('index')  ##显示指定模板
Beispiel #12
0
 def index(self):
     users = model.user().getList('*')  ##进行表查询
     self.assign('users', users)  ##设置为模板变量
     jobs = model.job().getList('*')
     self.assign('jobs', jobs)
     resumes = model.resume().getList('*')
     self.assign('resumes', resumes)
     return self.display('index')  ##显示指定模板
Beispiel #13
0
 def index(self):
     users = model.user().getList('*')  ##进行表查询
     self.assign('users', users)  ##设置为模板变量
     jobs = model.job().getList('*')
     self.assign('jobs', jobs)
     resumes = model.resume().getList('*')
     self.assign('resumes', resumes)
     return self.display('index')  ##显示指定模板
 def irc_311(self, command, prefix, args):
     """ whois reply """
     # mark that we're parsing this users whois
     nick = getnick(args[0])
     user = self.serverState.users.get(nick, model.user(nick))
     user.in_whois = 1
     self.serverState.addUser(user)
     self.viewtext.announce("%s is %s@%s (%s)" % \
          (args[1], args[2], args[3], args[-1]))
Beispiel #15
0
def create_user_record():
    id = request.json['id']
    name = request.json['name']
    full_name = request.json['fullname']
    password = request.json['password']
    newUser = user(id=id, name=name, fullname=full_name, password=password)
    psqlconfigutils.session.add(newUser)
    psqlconfigutils.session.commit()
    return "user created successfully"
    def init_database(self):
        import model
        model.Base.metadata.create_all(bind=self.db)

        from sqlalchemy.orm import sessionmaker
        session = sessionmaker(bind=self.db)()
        adminuser = model.user('admin', 'admin')
        #session.add(adminuser.identity)
        session.add(adminuser)
        session.commit()
Beispiel #17
0
def commit_user_to_ecs(threadnName, delay):
    i = 0
    id = 1
    user_update = model.user(userId=id,
                                    userName='******'
                                )
    i + 1
    config.db.session.add(user_update)
    config.db.session.commit()
    print 'comitted'
Beispiel #18
0
def register(user_username,user_userpasswd):
    result=config.session.query(model.user).\
       from_statement(text("SELECT * from user where userName=:username")).\
        params(username=user_username).first()
    if (result is None):
        new_user = model.user(userName=user_username,userPasswd=user_userpasswd)
        config.session.merge(new_user)
        config.session.commit()
        config.db.session.close()
        return 'succeed'
    return 'username is already exist!'
Beispiel #19
0
def register(user_username,user_userpasswd):
    result=config.session.query(model.user).\
       from_statement(text("SELECT * from user where userName=:username")).\
        params(username=user_username).first()
    if (result is None):
        new_user = model.user(userName=user_username,userPasswd=user_userpasswd)
        config.session.merge(new_user)
        config.session.commit()
        config.db.session.close()
        return 'succeed'
    return 'username is already exist!'
Beispiel #20
0
  def get(self):
    uid = self.current_user

    session = model.Session()
    user = model.user(session, uid)
    result = {"status":"ok"}
    services = result["services"] = []
    for anID in user.identities:
      services.append(anID.name())

    self.write(result)
Beispiel #21
0
def user_register(pars):
    if pars['passwd']!=pars['repasswd']:
        return -1
    # 数据库操作
    tableObj = model.user()  ##获取数据表对象
    condition = dict(pars)
    del condition['repasswd']
    condition['create_date'] = 'now()'
    condition['passwd'] = fun.mk_md5(condition['passwd'])
    listData = tableObj.insert(condition)
    print 'DB Logging:', listData
    return  listData
Beispiel #22
0
def user_register(pars):
    if pars['passwd'] != pars['repasswd']:
        return -1
    # 数据库操作
    tableObj = model.user()  ##获取数据表对象
    condition = dict(pars)
    del condition['repasswd']
    condition['create_date'] = 'now()'
    condition['passwd'] = fun.mk_md5(condition['passwd'])
    listData = tableObj.insert(condition)
    print 'DB Logging:', listData
    return listData
Beispiel #23
0
def user_login(pars):
    email = pars.get('email')
    passwd = fun.mk_md5(pars.get('passwd'))
    tableObj = model.user()  ##获取数据表对象
    condition = {'email': email}
    listData = tableObj.getOne('*', condition)  ##进行表查询
    print listData
    if listData and listData['passwd'] == passwd:
        web.ctx.session.login = True
        web.ctx.session.user_info = listData
        return True
    else:
        return None
Beispiel #24
0
def reg():
    user_name=request.form["username"]
    user_password=request.form["user_password"]
    result=config.session.query(model.user).\
       from_statement(text("SELECT * from user where userName=:username")).\
        params(username=user_name).first()
    if (result is None):
        new_user = model.user(userName=user_name,userPasswd=user_password)
        config.session.merge(new_user)
        config.session.commit()
        config.db.session.close()
        return '<html>succeed</html>'
    return 'username is already exist!'
Beispiel #25
0
def user_login(pars):
    email = pars.get('email')
    passwd = fun.mk_md5(pars.get('passwd'))
    tableObj = model.user()  ##获取数据表对象
    condition = {'email':email}
    listData = tableObj.getOne('*',condition)  ##进行表查询
    print listData
    if listData and listData['passwd']==passwd:
        web.ctx.session.login = True
        web.ctx.session.user_info = listData
        return True
    else:
        return None
Beispiel #26
0
  def get(self):
    uid = self.get_secure_cookie("uid")
    if not uid:
      return self.write("""{status:"error", message:"No user session"}""")

    session = model.Session()
    user = model.user(session, uid)
    result = {"status":"ok"}
    services = result["services"] = []
    for anID in user.identities:
      services.append(anID.name())

    self.write(result)
Beispiel #27
0
def reg():
    user_name=request.form["username"]
    user_password=request.form["user_password"]
    result=config.session.query(model.user).\
       from_statement(text("SELECT * from user where userName=:username")).\
        params(username=user_name).first()
    if (result is None):
        new_user = model.user(userName=user_name,userPasswd=user_password)
        config.session.merge(new_user)
        config.session.commit()
        config.db.session.close()
        return '<html>succeed</html>'
    return 'username is already exist!'
Beispiel #28
0
 def foo(self):
     settings = self.getSettings()  ##获取setting对象
     count = settings.WEB_NAME  ##获取具体的setting值
     inputParams = self.getPars()  ##获取请求参数
     tableObj = model.user()  ##获取数据表对象
     condition = {'name':'', 'email':'', 'passwd':'', 'create_date':'now()'}
     listData = tableObj.insert(condition)  ##进行表查询
     print 'DB Logging:', listData
     self.assign('listData',listData)  ##设置为模板变量
     logging.debug('This is debug message')
     logging.info('This is info message')
     logging.warning('This is warning message')
     return self.display('index')  ##显示指定模板
Beispiel #29
0
def get_user_record(id):
    user_record = psqlconfigutils.session.query(user).get(id)

    # change password of the trived object
    user_record.password = "******"
    print("Updated password of this user: {0}, password {1}".format(
        user_record.name, user_record.password))

    #add fake user to the users table
    fake_user = psqlconfigutils.session.add(
        user(id=11, name="fake", fullname="fakeuser", password="******"))

    get_list_users_by_names = psqlconfigutils.session.query(user).filter(
        user.name.in_(["Sirajunnisa", "fake", "Jani"])).all()
    print("The list of users filter by name {0}".format(
        json.dumps(user.serialize_list(get_list_users_by_names))))

    #role back changes which we made before
    # psqlconfigutils.session.rollback()

    # retrive record based on name is Saleem
    get_record_by_name = psqlconfigutils.session.query(user).filter_by(
        name='Saleem').first()
    print(
        "Get single user by using name, userid is : {0},username is : {1},userfullname is : {2}"
        .format(get_record_by_name.id, get_record_by_name.name,
                get_record_by_name.fullname))

    #Get instances of the user class in desc order
    get_all_user_desc = psqlconfigutils.session.query(user).order_by(
        desc(user.id))
    print("Get all instances of the user in desceding order:{0}".format(
        json.dumps(user.serialize_list(get_all_user_desc))))

    get_all_user_asc = psqlconfigutils.session.query(user).order_by(user.id)
    print("Get all instances of the user in ascending order:{0}".format(
        json.dumps(user.serialize_list(get_all_user_asc))))

    for name, fullname, password in psqlconfigutils.session.query(
            user.name, user.fullname, user.password):
        print("All users are {0},{1},{2}".format(name, fullname, password))

    for row, lab in psqlconfigutils.session.query(
            user, user.name.label('user_name')).all():
        print("labeld colums{0}:{1}:{2}{3}".format(row.name, row.fullname,
                                                   row.password,
                                                   lab.user_name))

    return json.dumps(user.serialize(user_record))
Beispiel #30
0
def verify():
    data = cache_verify.get(request.args.get("registerId"))
    if not data:
        raise Exceptions.InvalidToken()
    if model.getuser(data.get("email")):
        raise Exceptions.InvalidToken()
    result = model.user(username=data.get("username"),
                        email=data.get("email"),
                        password=password.crypt(data["password"]['context'],
                                                data["password"]['salt']),
                        passwordsalt=data["password"]['salt'],
                        register_time=datetime.now(),
                        last_login=0,
                        last_joinserver=0)
    result.save()
    cache_verify.delete(request.args.get("registerId"))
    return Response(status=204)
Beispiel #31
0
 def foo(self):
     settings = self.getSettings()  ##获取setting对象
     count = settings.WEB_NAME  ##获取具体的setting值
     inputParams = self.getPars()  ##获取请求参数
     tableObj = model.user()  ##获取数据表对象
     condition = {
         'name': '',
         'email': '',
         'passwd': '',
         'create_date': 'now()'
     }
     listData = tableObj.insert(condition)  ##进行表查询
     print 'DB Logging:', listData
     self.assign('listData', listData)  ##设置为模板变量
     logging.debug('This is debug message')
     logging.info('This is info message')
     logging.warning('This is warning message')
     return self.display('index')  ##显示指定模板
    def _on_access_token(self, callback, response):
        if response.error:
            logging.warning("Could not fetch access token")
            callback(None)
            return

        uid = self.get_secure_cookie("uid")
        if not uid:
            logging.warn("No user session: redirecting to root")
            return self.redirect("/")

        logging.info("Got OAuth callback: %s" % response)
        # NOTE that we assume the user has only one Yahoo account here!
        access_token = tornado.auth._oauth_parse_response(response.body)
        logging.info(" parsed to: %s" % access_token)

        # What we get back is:
        #  {'xoauth_yahoo_guid': '54MJG4TXXXXXXMDIXXXXX5G5M',
        #   'oauth_authorization_expires_in': '855808199', 'oauth_expires_in': '3600',
        #   'oauth_session_handle': 'AHNm_UxwMcc-',
        #   'secret': '2864f3d82f082cbbcf70b',
        #   'key': 'A=EDiRDHTtsx3u5W.I9Vj<lots bigger>...'}

        session = model.Session()
        user = model.user(session, uid)
        id = user.identity(session, model.OP_YAHOO)
        if id:
            id.accessToken = access_token["key"]
            id.accessSecret = access_token["secret"]
            id.opaqueID = access_token["xoauth_yahoo_guid"]
            session.add(id)
            session.commit()
        else:  # strange, we have no id for this user
            self.write(
                "Whoops - we don't have an authenticated Yahoo login for you.  That's weird."
            )
            self.finish()
            return

        to = self.get_argument("to", None)
        if to:
            self.redirect(to)
        else:
            self.redirect("/")
Beispiel #33
0
  def _on_access_token(self, callback, response):
    if response.error:
        logging.warning("Could not fetch access token")
        callback(None)
        return

    uid = self.get_secure_cookie("uid")
    if not uid:
      logging.warn("No user session: redirecting to root")
      return self.redirect("/")
    
    logging.info("Got OAuth callback: %s" % response)
    # NOTE that we assume the user has only one Yahoo account here! 
    access_token = tornado.auth._oauth_parse_response(response.body)
    logging.info(" parsed to: %s" % access_token)

    # What we get back is:
    #  {'xoauth_yahoo_guid': '54MJG4TXXXXXXMDIXXXXX5G5M', 
    #   'oauth_authorization_expires_in': '855808199', 'oauth_expires_in': '3600', 
    #   'oauth_session_handle': 'AHNm_UxwMcc-', 
    #   'secret': '2864f3d82f082cbbcf70b', 
    #   'key': 'A=EDiRDHTtsx3u5W.I9Vj<lots bigger>...'}

    session = model.Session()
    user = model.user(session, uid)
    id = user.identity(session, model.OP_YAHOO)
    if id:
      id.accessToken = access_token["key"]
      id.accessSecret = access_token["secret"]
      id.opaqueID = access_token["xoauth_yahoo_guid"]
      session.add(id)
      session.commit()
    else: # strange, we have no id for this user
      self.write("Whoops - we don't have an authenticated Yahoo login for you.  That's weird.")
      self.finish()
      return
    
    to = self.get_argument("to", None)
    if to:
      self.redirect(to)
    else:
      self.redirect("/")
    def irc_301(self, command, prefix, args):
        """ 
            whois reply: away 
        
            This reply is given both as a whois reply as when messaging someone
            who is away. Currently, this is the only whois reply that is 
            dispatched to query/msg windows, so this will look confusing when
            doing a whois on someone you're querying with.

            Solution? Probably to send all whois info to the query window
        """
        #
        # check if we've already seen this away message
        nick = args[1]
        remainder = args[-1]
        user = self.serverState.users.get(nick, model.user(nick))
        self.serverState.addUser(user)

        #
        # Only surpress display if we're not in a whois
        if user.away == args[-1] and not user.in_whois:
            return                      # XXX check if SHOW_AWAY_ONCE is on
        #
        # only store awaymsg if not in whois, so we see the awaymsg 
        # explicitly again on first msg.
        if not user.in_whois:
            user.away = remainder

        #
        # send the 303 to the query window if it's not part of a whois
        # (perhaps display entire whois replies in msg/query windows?)
        if not user.in_whois:
            if self.queries.has_key(nick):
                self.queries[nick].announce("%s is away: %s" % \
                                            (nick, args[-1]))
            else:
                msg = self.viewtext.get_msgwin(create=0)
                if msg:
                    msg.isaway(nick, args[-1])
        self.viewtext.announce("%s is away: %s" % (nick, args[-1]))
    def irc_JOIN(self, command, prefix, args):
        """ the channelname is in the remainder part. A bit weird.

            actually, it seems there are two syntaxes? One where the 
            channelname is the target ?! 
        """
        ##if ircMsg.target:
        ##    channel = ircMsg.target
        ##else:
        ##    channel = ircMsg.remainder
        channel = args[0]
        nick = getnick(prefix)
        userhost = getuserhost(prefix)

        if self.isme(nick):
            self.do_join(channel)
        # add user to model
        c = self.serverState.getChannel(channel)
        c.adduser(model.user(nick))

        self.channels[channel].userjoin(nick, userhost)
        self.logger.log(channel, "*** %s (%s) has joined channel %s" % \
                        (nick, userhost, channel))
Beispiel #36
0
        if msg['msg'] == 'ok':
            return True

    def get_contact_by_group(self, groupid=2):
        self.login_unless_not()
        self.opener.addheaders += [('Referer', settings.wx_index_url % self.token)]
        try:
            html = self.opener.open(settings.wx_contact_url % (self.token, groupid)).read()
        except Exception, e:
            logging.error(e.message, e)
            return
        users_json = json.loads(bs(html).findAll(id="json-friendList")[0].text)
        users = []
        for i in xrange(0, len(users_json)):
            user_json = users_json[i]
            u = user()
            u.nickname = user_json['nickName']
            u.fake_id = user_json['fakeId']
            u.remark_name = user_json['remarkName']
            u.group_id = int(user_json['groupId'])
            u.save()
            users.append(u)
        return users


class PushException(Exception):
    pass


class LoginException(Exception):
    pass
Beispiel #37
0
	def GET(self, uri):
		#if not uri: uri = 'World'
		users = model.user()
		return render.index(users.all())
Beispiel #38
0
async def get_all_users():
    users = []
    cursor = collection.find({})
    async for document in cursor:
        users.append(user(**document))
    return users
Beispiel #39
0
 def json(self):
     activity = Activity(name=self.require("name"), user=user(),
         tags=Activity.parsetags(self.request.get("tags", "")))
     activity.put()
     return {"activity":render("activity", activity=activity)}
Beispiel #40
0
 def modify(self, activity):
     return Activity(name=activity.name, user=user())