• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.jsonify_model_dbs函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ads

def ads(id=0,act=''):
  if act=='delete' and id:
    #delete
    k=ndb.Key(cms.Ads,id)
    k.delete()
    flask.flash('delete advertisement success', category='success')
    memcache.delete(memkey.ads_key)
    return flask.redirect(flask.url_for('ads'))
  query=cms.Ads.query()
  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(query.fetch())
  btn = 'Create'
  form = AdsForm()
  if id:
    obj=cms.Ads.get_by_id(id)
    if not obj:
      flask.flash('invalid obj id', category='danger')
      return flask.render_template('admin/ads.html',has_json=True,form=form,data=query,btn=btn)
    else:
      btn = 'Save'
      form=AdsForm(obj=obj)
  elif flask.request.method=='GET':
    # init some ad itmes
    ads_for_add = []
    for ad in ADS_POSITION:
      if not query.filter(cms.Ads.name == ad).get():
        ads_for_add.append(cms.Ads(name=ad))
    if ads_for_add:
      ndb.put_multi(ads_for_add)
  if form.validate_on_submit():
    name=form.name.data.lower()
    if id:
      # update
      # check existence
      if obj.name.lower() != name:
        if query.filter(cms.Ads.name==name,
          cms.Ads.key!=ndb.Key(cms.Ads,id)).get():
          flask.flash('name exist',category='danger')
          return flask.render_template('admin/ads.html',has_json=True,form=form,data=query,btn=btn)
      form.name.data=name
      form.populate_obj(obj)
      obj.put()
      flask.flash('update success',category='success')
    else:
      # create
      # check existence
      if query.filter(cms.Ads.name==name).get():
        flask.flash('name exist',category="danger")
        return flask.render_template('admin/ads.html',has_json=True,form=form,data=query,btn=btn)
      item = cms.Ads(
        name=name,
        value=form.value.data,
        description=form.description.data)
      item.put()
      flask.flash('ads add success',category='success')
    memcache.delete(memkey.ads_key)
    return flask.redirect(flask.url_for('ads'))
  #get
  else:
    return flask.render_template('admin/ads.html',has_json=True,form=form,data=query,btn=btn)
开发者ID:walkerwzy,项目名称:gae-init,代码行数:60,代码来源:admin.py


示例2: user_list

def user_list():
  user_dbs, more_cursor = util.retrieve_dbs(
      model.User.query(),
      limit=util.param('limit', int),
      cursor=util.param('cursor'),
      order=util.param('order') or '-created',
      name=util.param('name'),
      admin=util.param('admin', bool),
      active=util.param('active', bool),
      permissions=util.param('permissions', list),
    )

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(user_dbs, more_cursor)

  permissions = list(UserUpdateForm._permission_choices)
  permissions += util.param('permissions', list) or []
  return flask.render_template(
      'user/user_list.html',
      html_class='user-list',
      title='User List',
      user_dbs=user_dbs,
      more_url=util.generate_more_url(more_cursor),
      has_json=True,
      permissions=sorted(set(permissions)),
    )
开发者ID:CLOUGH,项目名称:info3180-lab5,代码行数:26,代码来源:user.py


示例3: user_list

def user_list():
    user_dbs, more_cursor = util.retrieve_dbs(
        model.User.query(),
        limit=util.param("limit", int),
        cursor=util.param("cursor"),
        order=util.param("order") or "-created",
        admin=util.param("admin", bool),
        active=util.param("active", bool),
        permissions=util.param("permissions", list),
    )

    if flask.request.path.startswith("/_s/"):
        return util.jsonify_model_dbs(user_dbs, more_cursor)

    permissions = list(UserUpdateForm._permission_choices)
    permissions += util.param("permissions", list) or []
    return flask.render_template(
        "user/user_list.html",
        html_class="user-list",
        title="User List",
        user_dbs=user_dbs,
        more_url=util.generate_more_url(more_cursor),
        has_json=True,
        permissions=sorted(set(permissions)),
    )
开发者ID:Tropicana,项目名称:zebra-reader,代码行数:25,代码来源:user.py


示例4: user_merge

def user_merge():
  user_keys = util.param('user_keys', list)
  if not user_keys:
    flask.abort(400)

  user_db_keys = [ndb.Key(urlsafe=k) for k in user_keys]
  user_dbs = ndb.get_multi(user_db_keys)
  if len(user_dbs) < 2:
    flask.abort(400)

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(user_dbs)

  user_dbs.sort(key=lambda user_db: user_db.created)
  merged_user_db = user_dbs[0]
  auth_ids = []
  permissions = []
  is_admin = False
  is_active = False
  for user_db in user_dbs:
    auth_ids.extend(user_db.auth_ids)
    permissions.extend(user_db.permissions)
    is_admin = is_admin or user_db.admin
    is_active = is_active or user_db.active
    if user_db.key.urlsafe() == util.param('user_key'):
      merged_user_db = user_db

  auth_ids = sorted(list(set(auth_ids)))
  permissions = sorted(list(set(permissions)))
  merged_user_db.permissions = permissions
  merged_user_db.admin = is_admin
  merged_user_db.active = is_active
  merged_user_db.verified = False

  form_obj = copy.deepcopy(merged_user_db)
  form_obj.user_key = merged_user_db.key.urlsafe()
  form_obj.user_keys = ','.join(user_keys)

  form = UserMergeForm(obj=form_obj)
  if form.validate_on_submit():
    form.populate_obj(merged_user_db)
    merged_user_db.auth_ids = auth_ids
    merged_user_db.put()

    deprecated_keys = [k for k in user_db_keys if k != merged_user_db.key]
    merge_user_dbs(merged_user_db, deprecated_keys)
    return flask.redirect(
        flask.url_for('user_update', user_id=merged_user_db.key.id()),
      )

  return flask.render_template(
      'user/user_merge.html',
      title='Merge Users',
      html_class='user-merge',
      user_dbs=user_dbs,
      merged_user_db=merged_user_db,
      form=form,
      auth_ids=auth_ids,
    )
开发者ID:gae-init,项目名称:phonebook,代码行数:59,代码来源:user.py


示例5: admin_pay_upgrade_service

def admin_pay_upgrade_service():
  pay_dbs, pay_cursor = util.get_dbs(
      model.Pay.query(),
      limit=util.param('limit', int),
      cursor=util.param('cursor'),
      order=util.param('order'),
    )
  ndb.put_multi(pay_dbs)
  return util.jsonify_model_dbs(pay_dbs, pay_cursor)
开发者ID:georgekis,项目名称:salary,代码行数:9,代码来源:admin.py


示例6: category

def category(cateid=0,act=''):
  if act=='delete' and cateid:
    #delete
    k=ndb.Key(cms.Category,cateid)
    k.delete()
    flask.flash('delete category success', category='success')
    memcache.delete(memkey.cate_key)
    return flask.redirect(flask.url_for('category'))
  query=cms.Category.query()
  cate_dbs=cms.Category.allcates()
  if flask.request.path.startswith('/_s/'):
    # if cateid:
    #   return util.jsonify_model_db(cms.Category.get_by_id(cateid))
    # else:
    return util.jsonify_model_dbs(cate_dbs)
  btn = 'Create'
  form = CategoryForm()
  if cateid:
    obj=cms.Category.get_by_id(cateid)
    if not obj:
      flask.flash('invalid obj id', category='danger')
      return flask.render_template('admin/category.html',has_json=True,form=form,data=cate_dbs,btn=btn)
    else:
      btn = 'Save'
      form=CategoryForm(obj=obj)
  if form.validate_on_submit():
    name=form.name.data.capitalize()
    if cateid:
      # update
      # check existence
      if obj.name.capitalize() != name:
        if query.filter(cms.Category.name==name,
          cms.Category.key!=ndb.Key(cms.Category,cateid)).get():
          flask.flash('name exist',category='danger')
          return flask.render_template('admin/category.html',has_json=True,form=form,data=query,btn=btn)
      form.name.data=name
      form.populate_obj(obj)
      obj.put()
      flask.flash('update success',category='success')
    else:
      # create
      # check existence
      if query.filter(cms.Category.name==name).get():
        flask.flash('name exist',category="danger")
        return flask.render_template('admin/category.html',form=form,data=query,btn=btn)
      cate = cms.Category(
        name=name,
        slug=form.slug.data,
        sort=form.sort.data)
      cate.put()
      flask.flash('category add success',category='success')
    memcache.delete(memkey.cate_key)
    return flask.redirect(flask.url_for('category'))
  #get
  else:
    return flask.render_template('admin/category.html',has_json=True,form=form,data=query,btn=btn)
开发者ID:walkerwzy,项目名称:gae-init,代码行数:56,代码来源:admin.py


示例7: admin_tournament_update

def admin_tournament_update():
  tournament_dbs, tournament_cursor = util.get_dbs(
      model.Tournament.query(),
      limit=util.param('limit', int) or config.DEFAULT_DB_LIMIT,
      order=util.param('order'),
      cursor=util.param('cursor'),
    )

  ndb.put_multi(tournament_dbs)
  return util.jsonify_model_dbs(tournament_dbs, tournament_cursor)
开发者ID:georstef,项目名称:GoogleAppEngine,代码行数:10,代码来源:admin.py


示例8: update_user_tutor

def update_user_tutor():
    event_dbs, event_cursor = util.get_dbs(
        model.Event.query(),
        limit=util.param("limit", int) or config.MAX_DB_LIMIT,
        order=util.param("order"),
        cursor=util.param("cursor"),
    )

    for event_db in event_dbs:
        event_db.accuracy = "day"

    ndb.put_multi(event_dbs)
    return util.jsonify_model_dbs(event_dbs, event_cursor)
开发者ID:g8824466,项目名称:life-line,代码行数:13,代码来源:admin.py


示例9: my_tournament_list

def my_tournament_list():
  tournament_dbs, next_cursor = model.Tournament.get_dbs(user_key=auth.current_user_key())

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(tournament_dbs, next_cursor)

  return flask.render_template(
      'tournament/my_tournament_list.html',
      html_class='my-tournament-list',
      title='My Tournaments',
      tournament_dbs=tournament_dbs,
      next_url=util.generate_next_url(next_cursor),
  )
开发者ID:georstef,项目名称:GoogleAppEngine,代码行数:13,代码来源:tournament.py


示例10: tournament_list

def tournament_list():
  tournament_dbs, next_cursor = model.Tournament.get_dbs(is_public=True)

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(tournament_dbs, next_cursor)

  return flask.render_template(
      'tournament/tournament_list.html',
      html_class='tournament-list',
      title='Tournaments',
      tournament_dbs=tournament_dbs,
      next_url=util.generate_next_url(next_cursor),
  )
开发者ID:georstef,项目名称:GoogleAppEngine,代码行数:13,代码来源:tournament.py


示例11: links

def links(id=0,act=''):
  if act=='delete' and id:
    #delete
    k=ndb.Key(cms.Links,id)
    k.delete()
    flask.flash('delete link success', category='success')
    memcache.delete(memkey.links_key)
    return flask.redirect(flask.url_for('links'))
  query=cms.Links.query()
  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(query.fetch())
  btn = 'Create'
  form = LinksForm()
  if id:
    obj=cms.Links.get_by_id(id)
    if not obj:
      flask.flash('invalid obj id', category='danger')
      return flask.render_template('admin/links.html',has_json=True,form=form,data=query,btn=btn)
    else:
      btn = 'Save'
      form=LinksForm(obj=obj)
  if form.validate_on_submit():
    name=form.name.data
    if id:
      # update
      # check existence
      if obj.name != name:
        if query.filter(cms.Links.name==name,
          cms.Links.key!=ndb.Key(cms.Links,id)).get():
          flask.flash('name exist',category='danger')
          return flask.render_template('admin/links.html',has_json=True,form=form,data=query,btn=btn)
      form.populate_obj(obj)
      obj.put()
      flask.flash('update success',category='success')
    else:
      # create
      # check existence
      if query.filter(cms.Links.name==name).get():
        flask.flash('name exist',category="danger")
        return flask.render_template('admin/links.html',has_json=True,form=form,data=query,btn=btn)
      item = cms.Links(
        name=name,
        url=form.url.data,
        sort=form.sort.data)
      item.put()
      flask.flash('link add success',category='success')
    memcache.delete(memkey.links_key)
    return flask.redirect(flask.url_for('links'))
  #get
  else:
    return flask.render_template('admin/links.html',has_json=True,form=form,data=query,btn=btn)
开发者ID:walkerwzy,项目名称:gae-init,代码行数:51,代码来源:admin.py


示例12: resource_list

def resource_list():
  resource_dbs, resource_cursor = auth.current_user_db().get_resource_dbs()

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(resource_dbs, resource_cursor)

  return flask.render_template(
      'resource/resource_list.html',
      html_class='resource-list',
      title='Resource List',
      resource_dbs=resource_dbs,
      next_url=util.generate_next_url(resource_cursor),
      has_json=True,
    )
开发者ID:alpocr,项目名称:gae-init-upload,代码行数:14,代码来源:resource.py


示例13: user_list

def user_list():
  user_dbs, user_cursor = model.User.get_dbs(email=util.param('email'))

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(user_dbs, user_cursor)

  permissions = list(UserUpdateForm._permission_choices)
  permissions += util.param('permissions', list) or []
  return flask.render_template(
      'user/user_list.html',
      html_class='user-list',
      title='User List',
      user_dbs=user_dbs,
      next_url=util.generate_next_url(user_cursor),
      has_json=True,
      permissions=sorted(set(permissions)),
    )
开发者ID:gae-init,项目名称:phonebook,代码行数:17,代码来源:user.py


示例14: index

def index():
    user_dbs, more_cursor = util.retrieve_dbs(
        User,
        User.query(),
        limit=util.param('limit', int),
        cursor=util.param('cursor'),
        order=util.param('order'),
        name=util.param('name'),
      )

    if request.path.startswith('/_json/'):
        return util.jsonify_model_dbs(user_dbs, more_cursor)
    return render_template(
        'admin/user/index.html',
        title=u'Пользователи',
        user_dbs=user_dbs,
        more_url=util.generate_more_url(more_cursor)
    )
开发者ID:gmist,项目名称:3dhero.ru,代码行数:18,代码来源:views.py


示例15: admin_user_update

def admin_user_update():
  user_dbs, user_cursor = util.get_dbs(
      model.User.query(),
      limit=util.param('limit', int) or config.DEFAULT_DB_LIMIT,
      order=util.param('order'),
      cursor=util.param('cursor'),
    )

  updated_dbs = []
  for user_db in user_dbs:
    if not user_db.birthdate:
      user_db.birthdate = None
      updated_dbs.append(user_db)

  if updated_dbs:
    ndb.put_multi(updated_dbs)

  return util.jsonify_model_dbs(updated_dbs, user_cursor)
开发者ID:georstef,项目名称:GoogleAppEngine,代码行数:18,代码来源:admin.py


示例16: event_list_service

def event_list_service(username=None):
  if auth.is_logged_in():
    user_db = auth.current_user_db()
  else:
    user_dbs, user_cursor = model.User.get_dbs(is_public=True, limit=10)
    user_db = random.choice(user_dbs) if user_dbs else None

  if username and user_db.username != username:
    if not user_db.admin:
      return flask.abort(404)
    user_db = model.User.get_by('username', username)

  if not user_db:
    return flask.abort(404)

  event_dbs, next_cursor = user_db.get_event_dbs()

  return util.jsonify_model_dbs(event_dbs, next_cursor)
开发者ID:g8824466,项目名称:life-line,代码行数:18,代码来源:event.py


示例17: admin_event_list

def admin_event_list():
    event_dbs, next_cursor = util.get_dbs(
        model.Event.query(),
        limit=util.param("limit", int),
        cursor=util.param("cursor"),
        order=util.param("order") or "user_key,-timestamp,accuracy,-created",
    )

    if flask.request.path.startswith("/_s/"):
        return util.jsonify_model_dbs(event_dbs, next_cursor)

    return flask.render_template(
        "admin/event_list.html",
        html_class="admin-event-list",
        title="Event List",
        event_dbs=event_dbs,
        next_url=util.generate_next_url(next_cursor),
    )
开发者ID:g8824466,项目名称:life-line,代码行数:18,代码来源:admin.py


示例18: admin_event_list

def admin_event_list():
  event_dbs, next_cursor = util.get_dbs(
      model.Event.query(),
      limit=util.param('limit', int),
      cursor=util.param('cursor'),
      order=util.param('order') or 'user_key,-timestamp,accuracy,-created',
    )

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(event_dbs, next_cursor)

  return flask.render_template(
      'admin/event_list.html',
      html_class='admin-event-list',
      title='Event List',
      event_dbs=event_dbs,
      next_url=util.generate_next_url(next_cursor),
    )
开发者ID:lipis,项目名称:life-line,代码行数:18,代码来源:admin.py


示例19: resource_list

def resource_list():
  resource_dbs, more_cursor = util.retrieve_dbs(
      model.Resource.query(),
      user_key=auth.current_user_key(),
      limit=util.param('limit', int),
      cursor=util.param('cursor'),
      order=util.param('order') or '-created',
    )

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_dbs(resource_dbs, more_cursor)

  return flask.render_template(
      'resource/resource_list.html',
      html_class='resource-list',
      title='Resource List',
      resource_dbs=resource_dbs,
      more_url=util.generate_more_url(more_cursor),
    )
开发者ID:iroot,项目名称:gae-init-page,代码行数:19,代码来源:resource.py


示例20: user_list

def user_list():
    user_dbs, more_cursor = util.retrieve_dbs(
        model.User.query(),
        limit=util.param("limit", int),
        cursor=util.param("cursor"),
        order=util.param("order") or "-created",
        name=util.param("name"),
        admin=util.param("admin", bool),
    )

    if flask.request.path.startswith("/_s/"):
        return util.jsonify_model_dbs(user_dbs, more_cursor)

    return flask.render_template(
        "user_list.html",
        html_class="user",
        title="User List",
        user_dbs=user_dbs,
        more_url=util.generate_more_url(more_cursor),
    )
开发者ID:handol,项目名称:gae-init,代码行数:20,代码来源:main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.jsonpify函数代码示例发布时间:2022-05-26
下一篇:
Python util.jsonify_model_db函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap