當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。