本文整理汇总了Python中util.uuid函数的典型用法代码示例。如果您正苦于以下问题:Python uuid函数的具体用法?Python uuid怎么用?Python uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uuid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: admin_config_update
def admin_config_update():
config_db = model.Config.get_master_db()
form = ConfigUpdateForm(obj=config_db)
if form.validate_on_submit():
form.populate_obj(config_db)
if not config_db.flask_secret_key:
config_db.flask_secret_key = util.uuid()
if not config_db.salt:
config_db.salt = util.uuid()
config_db.put()
reload(config)
app.config.update(CONFIG_DB=config_db)
return flask.redirect(flask.url_for('welcome'))
if flask.request.path.startswith('/_s/'):
return util.jsonify_model_db(config_db)
instances_url = None
if config.PRODUCTION:
instances_url = '%s?app_id=%s&version_id=%s' % (
'https://appengine.google.com/instances',
app_identity.get_application_id(),
config.CURRENT_VERSION_ID,
)
return flask.render_template(
'admin/config_update.html',
title='Admin Config',
html_class='admin-config',
form=form,
config_db=config_db,
instances_url=instances_url,
has_json=True,
)
开发者ID:mdxs,项目名称:gae-init-upload,代码行数:34,代码来源:admin.py
示例2: admin_config
def admin_config():
config_db = model.Config.get_master_db()
form = ConfigUpdateForm(obj=config_db)
if form.validate_on_submit():
if form.trusted_hosts.data:
form.trusted_hosts.data = set(
[e.strip() for e in form.trusted_hosts.data.split(',')])
else:
form.trusted_hosts.data = []
form.populate_obj(config_db)
if not config_db.flask_secret_key:
config_db.flask_secret_key = util.uuid()
if not config_db.salt:
config_db.salt = util.uuid()
config_db.put()
reload(config)
app.config.update(CONFIG_DB=config_db)
return flask.redirect(flask.url_for('admin'))
form.trusted_hosts.data = ', '.join(config_db.trusted_hosts)
return flask.render_template(
'admin/admin_config.html',
title=_('App Config'),
html_class='admin-config',
form=form,
api_url=flask.url_for('api.admin.config'),
)
开发者ID:gmist,项目名称:gae-init-babel,代码行数:27,代码来源:admin.py
示例3: user_reset
def user_reset(token=None):
user_db = model.User.get_by('token', token)
if not user_db:
flask.flash(__('That link is either invalid or expired.'), category='danger')
return flask.redirect(flask.url_for('welcome'))
if auth.is_logged_in():
login.logout_user()
return flask.redirect(flask.request.path)
form = UserResetForm()
if form.validate_on_submit():
user_db.password_hash = util.password_hash(user_db, form.new_password.data)
user_db.token = util.uuid()
user_db.verified = True
user_db.put()
flask.flash(__('Your password was changed succesfully.'), category='success')
return auth.signin_user_db(user_db)
return flask.render_template(
'user/user_reset.html',
title='Reset Password',
html_class='user-reset',
form=form,
user_db=user_db,
)
开发者ID:mdxs,项目名称:gae-init-babel,代码行数:26,代码来源:user.py
示例4: user_activate
def user_activate(token):
if auth.is_logged_in():
login.logout_user()
return flask.redirect(flask.request.path)
user_db = model.User.get_by('token', token)
if not user_db:
flask.flash(__('That link is either invalid or expired.'), category='danger')
return flask.redirect(flask.url_for('welcome'))
form = UserActivateForm(obj=user_db)
if form.validate_on_submit():
form.populate_obj(user_db)
user_db.password_hash = util.password_hash(user_db, form.password.data)
user_db.token = util.uuid()
user_db.verified = True
user_db.put()
return auth.signin_user_db(user_db)
return flask.render_template(
'user/user_activate.html',
title='Activate Account',
html_class='user-activate',
user_db=user_db,
form=form,
)
开发者ID:mdxs,项目名称:gae-init-babel,代码行数:26,代码来源:user.py
示例5: reset_password_notification
def reset_password_notification(user_db):
"""Sends email with url, which user can use to reset his password
Args:
user_db (model.User): User, who requested password reset
"""
if not user_db.email:
return
user_db.token = util.uuid()
user_db.put()
receiver = '%s <%s>' % (user_db.name, user_db.email)
body = '''Hello %(name)s,
it seems someone (hopefully you) tried to reset your password with %(brand)s.
In case it was you, please reset it by following this link:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'name': user_db.name,
'link': flask.url_for('user_reset', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
send_mail_notification('Reset your password', body, receiver)
开发者ID:Huijari,项目名称:gae_test,代码行数:32,代码来源:task.py
示例6: create_user_db
def create_user_db(auth_id, name, username, email='', verified=False, **props):
email = email.lower() if email else ''
if verified and email:
user_dbs, _ = model.User.get_dbs(email=email, verified=True, limit=2)
if len(user_dbs) == 1:
user_db = user_dbs[0]
user_db.auth_ids.append(auth_id)
user_db.put()
task.new_user_notification(user_db)
return user_db
if isinstance(username, str):
username = username.decode('utf-8')
username = unidecode.unidecode(username.split('@')[0].lower()).strip()
username = re.sub(r'[\W_]+', '.', username)
new_username = username
n = 1
while not model.User.is_username_available(new_username):
new_username = '%s%d' % (username, n)
n += 1
user_db = model.User(
name=name,
email=email,
username=new_username,
auth_ids=[auth_id],
verified=verified,
token=util.uuid(),
**props
)
user_db.put()
task.new_user_notification(user_db)
return user_db
开发者ID:aegoroff,项目名称:egoroff.spb.ru,代码行数:33,代码来源:auth.py
示例7: verify_user_email_notification
def verify_user_email_notification(user_db):
"""Sends email, which user can use to verify his email address
Args:
user_db (model.User): user, who should verify his email
"""
if not user_db.email:
return
user_db.token = util.uuid()
user_db.put()
receiver = user_db.email
body = '''Welcome to %(brand)s.
Follow the link below to confirm your email address and activate your account:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'link': flask.url_for('user_verify', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
send_mail_notification('Verify your email', body, receiver)
开发者ID:Huijari,项目名称:gae_test,代码行数:29,代码来源:task.py
示例8: activate_user_notification
def activate_user_notification(user_db):
if not user_db.email:
return
user_db.token = util.uuid()
user_db.put()
to = user_db.email
body = '''Welcome to %(brand)s.
Follow the link below to confirm your email address and activate your account:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'link': flask.url_for('user_activate', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
flask.flash(
'An activation link has been sent to your email address.',
category='success',
)
send_mail_notification('Activate your account', body, to)
开发者ID:Adhecious,项目名称:gae-init-auth,代码行数:28,代码来源:task.py
示例9: reset_password_notification
def reset_password_notification(user_db):
if not user_db.email:
return
user_db.token = util.uuid()
user_db.put()
to = '%s <%s>' % (user_db.name, user_db.email)
body = '''Hello %(name)s,
it seems someone (hopefully you) tried to reset your password with %(brand)s.
In case it was you, please reset it by following this link:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'name': user_db.name,
'link': flask.url_for('user_reset', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
flask.flash(
'A reset link has been sent to your email address.',
category='success',
)
send_mail_notification('Reset your password', body, to)
开发者ID:Adhecious,项目名称:gae-init-auth,代码行数:31,代码来源:task.py
示例10: verify_email_notification
def verify_email_notification(user_db):
if not (config.CONFIG_DB.verify_email and user_db.email) or user_db.verified:
return
user_db.token = util.uuid()
user_db.put()
to = '%s <%s>' % (user_db.name, user_db.email)
body = '''Hello %(name)s,
it seems someone (hopefully you) tried to verify your email with %(brand)s.
In case it was you, please verify it by following this link:
%(link)s
If it wasn't you, we apologize. You can either ignore this email or reply to it
so we can take a look.
Best regards,
%(brand)s
''' % {
'name': user_db.name,
'link': flask.url_for('user_verify', token=user_db.token, _external=True),
'brand': config.CONFIG_DB.brand_name,
}
send_mail_notification('Verify your email!', body, to)
开发者ID:seedrr,项目名称:gae-init,代码行数:27,代码来源:task.py
示例11: incoming_call
def incoming_call(user_id):
'''
Entry point for new, incoming calls.
'''
numberInfo = mongo.db.numbers.find_one({'number': request.form['To']})
# Verify that the dialed phone number is in the database
if not numberInfo:
app.logger.info("WARNING: Number {} not in database.".format(request.form['To']))
err = plivoxml.Response()
err.addSpeak(body="There has been an error. Please contact somebody.")
return Response(str(err), mimetype='text/xml')
# Get basic data from the POST
caller_number = request.form['From']
dialed_number = request.form['To']
route_type = numberInfo['defaultRoute'][0]['type']
bridge_name = uuid()
# Get list of numbers to ring
if route_type == "ringOne":
connect_to_number = numberInfo['defaultRoute'][0]['number']
connect_to_number_digits = readable_digits(connect_to_number)
numbers_to_try = [connect_to_number]
elif route_type == "ringMany":
numbers_to_try = [number for number in numberInfo['defaultRoute'][0]['numbers']]
connect_to_number_digits = "one of multiple phone numbers."
if DEBUG:
log_state('incoming_call', locals())
r = plivoxml.Response()
r.addSpeak(body="I will attempt to connect you to " + connect_to_number_digits)
r.addConference(
body=bridge_name,
waitSound=base_url_for(
'wait_sound',
user_id=user_id
),
callbackUrl=base_url_for(
'bridge_enter_exit',
user_id=user_id,
bridge_name=bridge_name,
caller_number=caller_number,
dialed_number=dialed_number,
numbers_to_try='+'.join(numbers_to_try)
),
action=base_url_for(
'action_by_caller',
user_id=user_id,
bridge_name=bridge_name,
caller_number=caller_number,
dialed_number=dialed_number
)
)
return Response(str(r), mimetype='text/xml')
开发者ID:RKJuve,项目名称:onering.io,代码行数:59,代码来源:app.py
示例12: user_verify
def user_verify(token):
user_db = auth.current_user_db()
if user_db.token != token:
flask.flash(__('That link is either invalid or expired.'), category='danger')
return flask.redirect(flask.url_for('profile'))
user_db.verified = True
user_db.token = util.uuid()
user_db.put()
flask.flash(__('Hooray! Your email is now verified.'), category='success')
return flask.redirect(flask.url_for('profile'))
开发者ID:mdxs,项目名称:gae-init-babel,代码行数:10,代码来源:user.py
示例13: add
def add(self, file, type):
# if /dev/null, say bye bye
if self.url == "/dev/null":
return
name = os.path.basename(file)
id = util.uuid()
shutil.copy(file, path.ftp_queue_dir + '/' + id)
self.queue.append({'name': name, 'id': id, 'type': type})
st = os.stat(path.ftp_queue_dir + '/' + id)
self.status += "%10d %s\n" % (st.st_size, name)
开发者ID:draenog,项目名称:pld-builder.new,代码行数:10,代码来源:ftp.py
示例14: user_verify
def user_verify(token):
user_db = auth.current_user_db()
if user_db.token != token:
flask.flash("That link is either invalid or expired.", category="danger")
return flask.redirect(flask.url_for("profile"))
user_db.verified = True
user_db.token = util.uuid()
user_db.put()
flask.flash("Hooray! Your email is now verified.", category="success")
return flask.redirect(flask.url_for("profile"))
开发者ID:gmist,项目名称:1businka2,代码行数:10,代码来源:views.py
示例15: send_rpmqa
def send_rpmqa():
tmp = path.build_dir + '/' + util.uuid() + '/'
os.mkdir(tmp)
log = tmp + config.rpmqa_filename
open(log, 'a').write("Query done at: %s\n" % datetime.datetime.now().isoformat(' '))
chroot.run("rpm -qa|sort", logfile=log)
os.chmod(log,0644)
ftp.init(rpmqa=True)
ftp.add(log)
ftp.flush()
os.unlink(log)
os.rmdir(tmp)
开发者ID:draenog,项目名称:pld-builder.new,代码行数:12,代码来源:maintainer.py
示例16: admin_config
def admin_config():
config_db = model.Config.get_master_db()
form = ConfigUpdateForm(obj=config_db)
if form.validate_on_submit():
form.populate_obj(config_db)
if not config_db.flask_secret_key:
config_db.flask_secret_key = util.uuid()
if not config_db.salt:
config_db.salt = util.uuid()
config_db.put()
reload(config)
app.config.update(CONFIG_DB=config_db)
return flask.redirect(flask.url_for('admin'))
return flask.render_template(
'admin/admin_config.html',
title='App Config',
html_class='admin-config',
form=form,
api_url=flask.url_for('api.config'),
)
开发者ID:wodore,项目名称:wodore-gae,代码行数:21,代码来源:admin.py
示例17: admin_config
def admin_config():
config_db = model.Config.get_master_db()
form = ConfigUpdateForm(obj=config_db)
if form.validate_on_submit():
form.populate_obj(config_db)
if not config_db.flask_secret_key:
config_db.flask_secret_key = util.uuid()
if not config_db.salt:
config_db.salt = util.uuid()
config_db.put()
reload(config)
app.config.update(CONFIG_DB=config_db)
return flask.redirect(flask.url_for('admin'))
if flask.request.path.startswith('/_s/'):
return util.jsonify_model_db(config_db)
return flask.render_template(
'admin/admin_config.html',
title='App Config',
html_class='admin-config',
form=form,
has_json=True,
)
开发者ID:joernhees,项目名称:gae-init,代码行数:24,代码来源:admin.py
示例18: post
def post(self):
"""Sets new password given by user if he provided valid token
Notice ndb.toplevel decorator here, so we can perform asynchronous put
and signing in in parallel
"""
parser = reqparse.RequestParser()
parser.add_argument('token', type=UserValidator.create('token'))
parser.add_argument('newPassword', type=UserValidator.create('password'), dest='new_password')
args = parser.parse_args()
user_db = User.get_by('token', args.token)
user_db.password_hash = util.password_hash(args.new_password)
user_db.token = util.uuid()
user_db.verified = True
user_db.put_async()
auth.signin_user_db(user_db)
return user_db.to_dict(include=User.get_private_properties())
开发者ID:jacraven,项目名称:lsiapp,代码行数:16,代码来源:auth_api.py
示例19: rename_section
def rename_section(section, section_product_cls, section_name):
section_products = section_product_cls.query(section_product_cls.section_key == section.key)
for section_product in section_products:
product_mem_key = uuid()
if not section_product.product_key:
continue
memcache.add(
product_mem_key,
{'%s' % section_name: section.name},
7200
)
taskqueue.add(
url=url_for(
'product.task.update_product',
key_id=section_product.product_key.id(),
mem_key=product_mem_key
))
开发者ID:gmist,项目名称:3dhero.ru,代码行数:17,代码来源:models.py
示例20: user_verify
def user_verify(token):
"""Verifies user's email by token provided in url"""
if auth.is_logged_in():
login.logout_user()
return flask.redirect(flask.request.path)
user_db = model.User.get_by('token', token)
if user_db and not user_db.verified:
# setting new token is necessary, so this one can't be reused
user_db.token = util.uuid()
user_db.verified = True
user_db.put()
auth.signin_user_db(user_db)
flask.flash('Welcome on board %s!' % user_db.username)
else:
flask.flash('Sorry, activation link is either invalid or expired.')
return flask.redirect(flask.url_for('index'))
开发者ID:jacraven,项目名称:lsiapp,代码行数:18,代码来源:user.py
注:本文中的util.uuid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论