当前位置: 首页>>代码示例>>Python>>正文


Python users.Users类代码示例

本文整理汇总了Python中users.Users的典型用法代码示例。如果您正苦于以下问题:Python Users类的具体用法?Python Users怎么用?Python Users使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Users类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

class UUS:

    def __init__(self):
        self.__LOG_TAG__ = "UUS"
        self.rss_list = URL_list()
        self.html_list = URL_list()
        self.users = Users()

    def to_str(self):
        return "rss_list:\n"+self.rss_list.to_str()+'\n\nhtml_list:\n'+self.html_list.to_str()

    def print_users(self, p_users):
        for user in self.users.get_users():
            print str(user.get_id()) + "   " + str(user.get_nick()) + "   " + str(user.get_url_list())
            print 

    def get_url_split(self, p_url):
        "RSS|http://www.hardware.com.br/feeds/global.xml"
        ret = "", ""
        try:
            ret = p_url.split('|')
        except:
            log.error(self.__LOG_TAG__, "Error getting URL type")
        return ret[0], ret[1]

    def update(self, p_user):
        user_id = p_user.get_id()
        user_urls = p_user.get_url_list()
        for url in user_urls:
            url_type, url_link = self.get_url_split(url)
            if url_type == "RSS":
                self.rss_list.add_link(url_link)
                self.rss_list.add_user(url_link, user_id)
            elif url_type == "HTML":
                self.html_list.add_link(url_link)
                self.html_list.add_user(url_link, user_id)
            else:
                log.error(self.__LOG_TAG__, "URL type[%s] invalid" % (url_type))

    def maintenance_url_lists(self):
        #atualizar tabela user
        self.users.update_users()
        
        #atualizar tabela url de acordo com nova tabela user
        for user in self.users.get_users():
            user_status = user.get_status() 
            if user_status == 0:
                #status 0 = funcionando. nao fazer nada.
                pass
            elif (user_status == 1) or (user_status == 2):
                #novo ou alterado. atualizar.
                self.update(user)
            elif (user_status == 3):
                #block(user)
                pass
            elif (user_status == 9):
                #delete(user)
                pass
            else:
                log.error(self.__LOG_TAG__, "Error: invalid status[%s]" % (user_status))
开发者ID:guikingma,项目名称:Jarbas,代码行数:60,代码来源:user_url_system.py

示例2: add_user

def add_user():
  """
  Register a user, looking up username and password in request.form.
  Validates the username and password.

  Returns:
    A JSON string about the registration status.
  """
  username = request.form['username']
  password = request.form['password']
  confirmation = request.form['confirmPassword']
  if not confirmed_password_valid(password, confirmation):
    return fail_registration(
        "Your password and confirmation didn't match up.")
  if password.strip() == '':
    return fail_registration("Passwords can not be blank.")
  if ' ' in password:
    return fail_registration("Passwords can not have spaces")
  users = Users(g.database_service)
  if not users.is_valid_username(username):
    error = """
        Username %s is not valid.
        Either it's taken, it has a space, or it's blank.
        """ % (username)
    return fail_registration(error)
  new_user = users.register_user(username, password)
  session['user_id'] = new_user.get_id()
  return success_registration()
开发者ID:rahulraj,项目名称:web_projects,代码行数:28,代码来源:__init__.py

示例3: register_security_answer

def register_security_answer():
    # auth user
    request_data = request.get_json(force=True)

    try:
        user = auth()
    except AuthenticationFailed:
        return rAuthError

    try:
        params = get_from_request_data(["service_info"])
        service_info = params["service_info"]
    except MissingRequestParams:
        return rMissingServiceInfo

    service_name = service_info.get("service_name")
    question = service_info.get("question")
    answer = service_info.get("answer")
    if None in [service_name, question, answer]:
        return rMissingParams(["service_name", "question", "answer"])

    try:
        Users.register_security_answer(username, service_name, question, answer)
    except RuntimeError as e:
        return rInternalServerError

    return "OK"
开发者ID:rikonor,项目名称:vanguard-api,代码行数:27,代码来源:api.py

示例4: enroll_in_service

def enroll_in_service():
    # Lets assume for now the only service we support is vanguard
    # For that reason, all service info validation logic shall be in this sole handler

    # required: service_name, username, password
    request_data = request.get_json(force=True)

    try:
        user = auth()
    except AuthenticationFailed:
        return rAuthError

    service_info = request_data.get("service_info")
    if service_info is None:
        return "Please provide service information for enrollment", 400

    service_name = service_info.get("service_name")
    username = service_info.get("username")
    password = service_info.get("password")
    if None in [service_name, username, password]:
        return "Please provide service information for enrollment", 400

    try:
        Users.enroll_in_service(username, service_info)
    except RuntimeError as e:
        print "ERROR:", e
        return rInternalServerError

    return "OK"
开发者ID:rikonor,项目名称:vanguard-api,代码行数:29,代码来源:api.py

示例5: register

def register():
  """
  Sending a GET request returns the register.html page.
  Sending a POST request validates, then registers the user.
  If successful, the user is immediately brought to the sticky note page.
  """
  if request.method == 'GET':
    return render_template('register.html')
  else:
    username = request.form['username']
    password = request.form['password']
    confirmation = request.form['confirmPassword']
    if not confirmed_password_valid(password, confirmation):
      return fail_registration(
          "Your password and confirmation didn't match up.")
    if len(password) == 0:
      return fail_registration("Passwords can not be blank.")
    if ' ' in password:
      return fail_registration("Passwords can not have spaces")
    with closing(shelve.open(users_file)) as user_shelf:
      users = Users(user_shelf)
      if not users.is_valid_user(username):
        flash("Username %s is not valid." % (username))
        flash("Either it's taken, it has a space, or it's blank")
        return render_template('register.html')
      users.register_user(username, password)
      session['username'] = username
    return redirect(url_for('notes'))
开发者ID:rahulraj,项目名称:web_projects,代码行数:28,代码来源:main.py

示例6: register

def register():
    form = RegistrationForm(request.form)
    if request.method == 'POST' and form.validate():
        user = Users(form.firstname.data, form.lastname.data, form.email.data, form.password.data)
        user.add_user(user)
        flash('Thanks for registering')
        return redirect('/')
    return render_template('register.j2', form=form)
开发者ID:JohnPreston,项目名称:dummy-3tier,代码行数:8,代码来源:views.py

示例7: login

def login():
    dsn = app.config['dsn']
    page = Users(dsn)
    if request.method == 'GET':
        return render_template('user/login.html')
    else:
        username = request.form['username']
        password = request.form['password']
        return page.login(username, password)
开发者ID:itucsdb1525,项目名称:itucsdb1525,代码行数:9,代码来源:server.py

示例8: add_members

def add_members(obj, srcId, dstId):
	# delete all the existing members first (objects' creator should be here)
	for mbr in map(lambda m: m['id'], obj.get_members(dstSys, dstId)):
		obj.del_member(dstSys, dstId, mbr)
	# return an user_id in the destination system according to a given member dict from the source system
	usr = Users()
	uidByMember = lambda mbr: get_user(dstSys, usr.by_id(srcSys, mbr['id']))
	for mbr in obj.get_members(srcSys, srcId):
		obj.add_member(dstSys, dstId, uidByMember(mbr), mbr['access_level'])
开发者ID:alces,项目名称:gitlab-rest-client,代码行数:9,代码来源:copyGroup.py

示例9: updateUser

def updateUser():
    conn = MySQLdb.connect(host='127.0.0.1',user='root',passwd='******',db='github')
    cur = conn.cursor()
    with open("/Users/dreamteam/Documents/study/sonar/results/oss developer evaluation/update_star_num.csv") as seed:
        reader = csv.reader(seed)
        next(reader,None)
        mUsers = Users(conn,cur,1,'1','1',"2016-03-01 00:00:00")
        for line in reader:
            mUsers.getFollowerAndStar(str(line[1]))
开发者ID:roadfar,项目名称:CasualContributor,代码行数:9,代码来源:main.py

示例10: get_category_info

    def get_category_info(category):
        result = Objects.get_object_info(category)
        owners = list()
        for owner in category.owners.all():
            user_extension = Users.get_user_extension(owner.username)
            if user_extension:
                owners.append(Users.get_user_info(user_extension))

        result["owners"] = owners
        return result
开发者ID:appleface2050,项目名称:WorkCode_Bakup,代码行数:10,代码来源:forums.py

示例11: UsersTest

class UsersTest(unittest.TestCase):
  def setUp(self):
    """ Using dicts instead of Shelve objects to speed up testing. """
    self.fake_database = FakeDatabaseService()
    self.users = Users(self.fake_database)
    self.username = 'test_user'
    self.password = 'test_password'

  def test_confirm_passwords(self):
    self.assertTrue(confirmed_password_valid('foo', 'foo'))
    self.assertFalse(confirmed_password_valid('foo', 'bar'))

  def test_simple_add_users(self):
    self.assertFalse(self.users.has_user(self.username))
    self.users.register_user(self.username, self.password)
    self.assertTrue(self.users.has_user(self.username))
    self.assertTrue( \
        self.users.try_login_user(self.username, self.password) is not None)

  def test_login_before_register(self):
    self.assertTrue( \
        self.users.try_login_user(self.username, self.password) is None)

  def test_login_with_wrong_password(self):
    self.users.register_user(self.username, self.password)
    self.assertTrue( \
        self.users.try_login_user(self.username, 'bad_password') is None)
开发者ID:rahulraj,项目名称:web_projects,代码行数:27,代码来源:users_test.py

示例12: person_page

def person_page():
     now = datetime.datetime.now()
     uses = Users(app.config['dsn'])
     if request.method == 'GET':
        now = datetime.datetime.now()
        return render_template('persons.html', current_time=now.ctime())
     elif 'persons_to_control' in request.form:
        searchList = uses.control_user(request.form['username'],request.form['password']);
        if searchList == 1:
            return redirect(url_for('person_page'))
        else:
            return redirect(url_for('home_page2'))
开发者ID:itucsdb1501,项目名称:itucsdb1501,代码行数:12,代码来源:server.py

示例13: get_post_win_count_by_user

 def get_post_win_count_by_user(user_id):
     try:
         user = Users.get_user_by_id(user_id)
         user_extension = Users.get_user_extension(user.username)
         count = 0
         for fp in ForumPost.objects.all():
             if user_extension in fp.win_users.all():
                 count += 1
         return count
     except Exception as ex:
         Logs.print_current_function_name_and_line_number(ex)
         return 0
开发者ID:appleface2050,项目名称:WorkCode_Bakup,代码行数:12,代码来源:forums.py

示例14: login

def login():
    from users import Users
    if request.method == "POST":
        if not Users.authentification(str(request.form["username"]), str(request.form["password"])):
            return render_template("login.html", citation=getCitation(), message="Invalid credential.")
        else:
            print Users.get_by_pseudonyme(request.form["username"])
            # login_user(Users.get_by_pseudonyme(request.form["username"]))
            return redirect(request.args.get("next") or "/")
    else:


        return render_template("login.html", citation=getCitation())
开发者ID:PXke,项目名称:Home1.0,代码行数:13,代码来源:views.py

示例15: sign_up

def sign_up():
    dsn = app.config['dsn']
    page = Users(dsn)
    if request.method == 'GET':
        return render_template('user/signup.html')
    else:
        username = request.form['username']
        password = request.form['password']
        if username and password:
            return page.sign_up(username, password)
        else:
            flash("You must enter a username and a password!")
            return render_template('user/signup.html')
开发者ID:itucsdb1525,项目名称:itucsdb1525,代码行数:13,代码来源:server.py


注:本文中的users.Users类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。