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


Python shortuuid.ShortUUID方法代码示例

本文整理汇总了Python中shortuuid.ShortUUID方法的典型用法代码示例。如果您正苦于以下问题:Python shortuuid.ShortUUID方法的具体用法?Python shortuuid.ShortUUID怎么用?Python shortuuid.ShortUUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shortuuid的用法示例。


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

示例1: drop

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def drop():
    file = request.files['file']
    i = Image()
    i.title = file.filename
    i.image = file
    uuid = shortuuid.ShortUUID().random(length=6)
    while Image.objects(iid=uuid):
        uuid = shortuuid.ShortUUID().random(length=6)
    i.iid = uuid
    if login.current_user.is_active():
        i.user = login.current_user._get_current_object()
    else:
        i.user = system_user
    i.description = ''
    i.tags = []
    i.save()
    return jsonify(id=uuid) 
开发者ID:ericls,项目名称:tushe,代码行数:19,代码来源:views.py

示例2: create_gallery

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def create_gallery():
    if not login.current_user.is_active():
        flash('请登录后再搞相册哦~')
        return redirect(url_for('light-cms.user_login'))
    if request.method == 'GET':
        return render_template('create_gallery.html', title='创建相册')
    if request.method == 'POST':
        uuid = shortuuid.ShortUUID().random(length=6)
        while Gallery.objects(gid=uuid):
            uuid = shortuuid.ShortUUID().random(length=6)
        title = request.form['title']
        g = Gallery()
        g.user = login.current_user._get_current_object()
        g.gid = uuid
        g.title = title
        g.save()
        return redirect(url_for('light-cms.add_image_to_gallery', gid=g.gid)) 
开发者ID:ericls,项目名称:tushe,代码行数:19,代码来源:views.py

示例3: gallery_drop

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def gallery_drop(gid):
    if not login.current_user.is_active():
        flash('请登录后再搞相册哦~')
        return redirect(url_for('light-cms.user_login'))
    g = Gallery.objects.get_or_404(gid=gid)
    file = request.files['file']
    i = Image()
    i.gallery.append(g)
    i.title = file.filename
    i.image = file
    uuid = shortuuid.ShortUUID().random(length=6)
    while Image.objects(iid=uuid):
        uuid = shortuuid.ShortUUID().random(length=6)
    i.iid = uuid
    i.user = login.current_user._get_current_object()
    i.description = ''
    i.tags = []
    i.save()
    return jsonify(id=uuid) 
开发者ID:ericls,项目名称:tushe,代码行数:21,代码来源:views.py

示例4: receive

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def receive():
    data = request.data
    data = xmltodict.parse(data)['xml']
    if data['MsgType'] == 'text':
        return send_text(data['FromUserName'], 'hi')
    if data['MsgType'] == 'image':
        token = current_access_token()
        file_url = 'https://api.weixin.qq.com/cgi-bin/media/get?access_token=%s&media_id=%s' % (token, data['MediaId'])
        file = requests.get(file_url, stream=True).raw
        i = Image()
        i.image = file
        uuid = shortuuid.ShortUUID().random(length=6)
        while Image.objects(iid=uuid):
            uuid = shortuuid.ShortUUID().random(length=6)
        i.iid = uuid
        i.title = data['MediaId']
        i.user = system_user
        i.description = ''
        i.tags = []
        i.save()
        return send_text(
            data['FromUserName'], '上传成功!图片地址:%s%s' % (
                request.url_root[:-1], url_for('light-cms.image', iid=i.iid)
            )
        ) 
开发者ID:ericls,项目名称:tushe,代码行数:27,代码来源:wc.py

示例5: regenerate_api_key

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def regenerate_api_key(id):
    user = User.query.get(id)
    user.api_key = shortuuid.ShortUUID().random(length=32)
    db.session.commit() 
开发者ID:dhamaniasad,项目名称:crestify,代码行数:6,代码来源:user_service.py

示例6: __init__

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def __init__(self, table_prefix="", region_name=None,
                 endpoint_url=None):
        self._client = boto3.client('dynamodb',
                                    region_name=region_name,
                                    endpoint_url=endpoint_url)
        self._db = boto3.resource("dynamodb",
                                  region_name=region_name,
                                  endpoint_url=endpoint_url)
        self._table_prefix = table_prefix
        self._create_all_tables()
        self._uuid = ShortUUID()
        self._uuid.set_alphabet('23456789abcdefghijkmnopqrstuvwxyz') 
开发者ID:gouthambs,项目名称:Flask-Blogging,代码行数:14,代码来源:dynamodbstorage.py

示例7: generate_uid

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def generate_uid(self):
        return self.uid_prefix + ShortUUID().random(UUID_LENGTH)
        # When UID_LENGTH is 22, that should be changed to:
        # return self.uid_prefix + shortuuid.uuid() 
开发者ID:kobotoolbox,项目名称:kpi,代码行数:6,代码来源:kpi_uid.py

示例8: _create

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def _create(contest, comments):
    random_gen = shortuuid.ShortUUID()
    ContestInvitation.objects.bulk_create(
      [ContestInvitation(contest=contest, code=random_gen.random(12), comment=comment) for comment in comments]) 
开发者ID:F0RE1GNERS,项目名称:eoj3,代码行数:6,代码来源:views.py

示例9: post

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def post(self, request, pk):
    namelist = list(filter(lambda x: x, map(lambda x: x.strip(), request.POST['list'].split('\n'))))
    user_id = 1
    contest = Contest.objects.get(pk=pk)
    for name in namelist:
      if name.startswith('*'):
        comment = name[1:].strip()
        star = True
      else:
        comment = name
        star = False
      password_gen = shortuuid.ShortUUID("23456789ABCDEF")
      password = password_gen.random(8)
      while True:
        try:
          username = self._get_username(pk, user_id)
          email = '%s@fake.ecnu.edu.cn' % username
          user = User.objects.create(username=username, email=email)
          user.set_password(password)
          user.save()
          user.avatar.save('generated.png', Identicon(user.email).get_bytes())
          ContestParticipant.objects.create(user=user, comment=comment, hidden_comment=password,
                                            star=star, contest=contest)
          break
        except IntegrityError:
          pass
        user_id += 1
    invalidate_contest(contest)
    return HttpResponseRedirect(request.POST['next']) 
开发者ID:F0RE1GNERS,项目名称:eoj3,代码行数:31,代码来源:views.py

示例10: get_invitation_code

# 需要导入模块: import shortuuid [as 别名]
# 或者: from shortuuid import ShortUUID [as 别名]
def get_invitation_code():
  return shortuuid.ShortUUID().random(12) 
开发者ID:F0RE1GNERS,项目名称:eoj3,代码行数:4,代码来源:models.py


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