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

Python util.jsonify_model_db函数代码示例

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

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



在下文中一共展示了jsonify_model_db函数的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()
        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:g8824466,项目名称:life-line,代码行数:32,代码来源:admin.py


示例2: 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)
    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:Eenvincible,项目名称:gae-init,代码行数:30,代码来源:admin.py


示例3: profile

def profile():
  form = ProfileUpdateForm()
  user_db = auth.current_user_db()
  if form.validate_on_submit():
    user_db.name = form.name.data.strip()
    user_db.email = form.email.data.strip().lower()
    user_db.locale = form.locale.data.strip()
    user_db.put()
    return flask.redirect(flask.url_for(
        'set_locale', locale=user_db.locale, next=flask.url_for('welcome')
      ))

  if not form.errors:
    form.name.data = user_db.name
    form.email.data = user_db.email or ''
    form.locale.data = user_db.locale or auth.get_locale()

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(user_db)

  return flask.render_template(
      'profile.html',
      title=_('Profile'),
      html_class='profile',
      form=form,
      user_db=user_db,
    )
开发者ID:NamPNQ,项目名称:gae-init-babel,代码行数:27,代码来源:main.py


示例4: user_update

def user_update(user_id):
  user_db = model.User.get_by_id(user_id)
  if not user_db:
    flask.abort(404)

  form = UserUpdateForm(obj=user_db)
  for permission in user_db.permissions:
    form.permissions.choices.append((permission, permission))
  form.permissions.choices = sorted(set(form.permissions.choices))
  if form.validate_on_submit():
    if not util.is_valid_username(form.username.data):
      form.username.errors.append('This username is invalid.')
    elif not model.User.is_username_available(form.username.data, user_db.key):
      form.username.errors.append('This username is already taken.')
    else:
      form.populate_obj(user_db)
      if auth.current_user_id() == user_db.key.id():
        user_db.admin = True
        user_db.active = True
      user_db.put()
      return flask.redirect(flask.url_for(
          'user_list', order='-modified', active=user_db.active,
        ))

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(user_db)

  return flask.render_template(
      'user/user_update.html',
      title=user_db.name,
      html_class='user-update',
      form=form,
      user_db=user_db,
    )
开发者ID:gae-init,项目名称:phonebook,代码行数:34,代码来源:user.py


示例5: resource_update

def resource_update(resource_id):
  resource_db = model.Resource.get_by_id(resource_id)

  if not resource_db or resource_db.user_key != auth.current_user_key():
    return flask.abort(404)

  form = ResourceUpdateForm()

  if form.validate_on_submit():
    resource_db.name = form.name.data
    resource_db.put()
    return flask.redirect(flask.url_for(
        'resource_view', resource_id=resource_db.key.id(),
      ))
  if not form.errors:
    form.name.data = resource_db.name

  if flask.request.path.startswith('/_s/'):
    if form.errors:
      return flask.abort(400)
    return util.jsonify_model_db(resource_db)

  return flask.render_template(
      'resource/resource_update.html',
      html_class='resource-update',
      title='%s' % (resource_db.name),
      resource_db=resource_db,
      form=form,
      has_json=True,
    )
开发者ID:alpocr,项目名称:gae-init-upload,代码行数:30,代码来源:resource.py


示例6: profile

def profile():
  user_db = auth.current_user_db()
  form = ProfileUpdateForm(obj=user_db)

  if form.validate_on_submit():
    email = form.email.data
    if email and not user_db.is_email_available(email, user_db.key):
      form.email.errors.append('This email is already taken.')

    if not form.errors:
      send_verification = not user_db.token or user_db.email != email
      form.populate_obj(user_db)
      if send_verification:
        user_db.verified = False
        task.verify_email_notification(user_db)
      user_db.put()
      return flask.redirect(flask.url_for('welcome'))

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(user_db)

  return flask.render_template(
      'profile.html',
      title=user_db.name,
      html_class='profile',
      form=form,
      user_db=user_db,
      has_json=True,
    )
开发者ID:georgekis,项目名称:gae-init-docs,代码行数:29,代码来源:main.py


示例7: profile

def profile():
  user_db = auth.current_user_db()
  form = ProfileUpdateForm(obj=user_db)

  if form.validate_on_submit():
    send_verification = not user_db.token or user_db.email != form.email.data
    form.populate_obj(user_db)
    if send_verification:
      user_db.verified = False
      task.verify_email_notification(user_db)
    user_db.put()
    return flask.redirect(flask.url_for(
        'set_locale', locale=user_db.locale, next=flask.url_for('welcome')
      ))

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(user_db)

  return flask.render_template(
      'profile.html',
      title=user_db.name,
      html_class='profile',
      form=form,
      user_db=user_db,
      has_json=True,
    )
开发者ID:g8824466,项目名称:life-line,代码行数:26,代码来源:main.py


示例8: get_product

def get_product(key_id):
    product = Product.retrieve_by_id(key_id)
    if not product:
        return jsonify({"success": False, "msg": "Product with id:%s not found." % key_id})

    if request.method == "DELETE":

        @check_write_permission
        def delete_product():
            product.key.delete()
            return jsonify({"success": True, "msg": "Product id:%s deleted" % key_id})

        return delete_product()

    if request.method == "PUT":

        @check_write_permission
        def put_product():
            flag, model = load_data()
            if not flag:
                return model
            if model_populate(model, product) or param("force_save"):
                product.put()
                return jsonify({"success": True, "msg": "Product has been updated."})
            else:
                return jsonify({"success": False, "msg": "Product has not been updated."})

        return put_product()
    return jsonify_model_db(product)
开发者ID:gmist,项目名称:3dhero.ru,代码行数:29,代码来源:views.py


示例9: get_post_json

def get_post_json(key_id):
    if not key_id:
        raise ApiException('Invalid request: "id" parameter not found.')

    product = None
    if key_id:
        product = Post.retrieve_by_id(key_id)
    if not product and key_id:
        raise ApiException('Post with "%s" == %s not found' % ('id', key_id), status=404)
    return jsonify_model_db(product)
开发者ID:aegoroff,项目名称:egoroff.spb.ru,代码行数:10,代码来源:views.py


示例10: resource_delete

def resource_delete(resource_id):
  resource_db = model.Resource.get_by_id(resource_id)

  if not resource_db or resource_db.user_key != auth.current_user_key():
    return flask.abort(404)

  blobstore.BlobInfo.get(resource_db.blob_key).delete()
  resource_db.key.delete()

  return util.jsonify_model_db(resource_db)
开发者ID:alpocr,项目名称:gae-init-upload,代码行数:10,代码来源:resource.py


示例11: profile

def profile():
  user_db = auth.current_user_db()

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(user_db)

  return flask.render_template(
      'profile/profile.html',
      title=user_db.name,
      html_class='profile-view',
      user_db=user_db,
      has_json=True,
    )
开发者ID:Adhecious,项目名称:gae-init-auth,代码行数:13,代码来源:profile.py


示例12: profile

def profile():
    next_url = util.get_next_url()
    customer_fields_require = False
    user_db = current_user_db()
    form = ProfileUpdateForm(obj=user_db)
    if form.validate_on_submit():
        form.populate_obj(user_db)
        user_db.put()
        if not "customer_require" in flask.request.form:
            flask.flash(u"Профиль успешно обновлен")
            return flask.redirect(flask.url_for("pages.index"))
        else:
            if not form.email.data or not form.company.data:
                if not form.email.data:
                    form.email.errors.append(u"Это поле обязательно для заполнения")
                if not form.company.data:
                    form.company.errors.append(u"Это поле обязательно для заполнения")
                customer_fields_require = True
            else:
                msg = u"Профиль успешно обновлен, "
                request = PartnerRequest.query(PartnerRequest.customer == user_db.key)
                if request.count():
                    msg += u"Вы уже делали запрос на сотрудничество, запрос "
                    request = request.get()
                    if request.status == REQUEST_STATUS["now"]:
                        msg += u"еще не рассмотрен"
                    elif request.status == REQUEST_STATUS["accept"]:
                        msg += u"одобрен"
                    elif request.status == REQUEST_STATUS["admin"]:
                        msg += u"одобрен и Вам были даны права администратора"
                    else:
                        msg += u"отклонен"
                else:
                    msg += u"в ближайшее время с Вами свяжется наш менеджер"
                    request = PartnerRequest(customer=user_db.key)
                    request.put()
                flask.flash(msg)
                return flask.redirect(flask.url_for("pages.index"))

    if flask.request.path.startswith("/_json/"):
        return util.jsonify_model_db(user_db)

    return flask.render_template(
        "auth/profile.html",
        title="Profile",
        html_class="profile",
        form=form,
        user_db=user_db,
        customer_fields_require=customer_fields_require,
        next_url=next_url,
    )
开发者ID:gmist,项目名称:3dhero.ru,代码行数:51,代码来源:auth_views.py


示例13: resource_view

def resource_view(resource_id):
  resource_db = model.Resource.get_by_id(resource_id)

  if not resource_db or resource_db.user_key != auth.current_user_key():
    return flask.abort(404)

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(resource_db)

  return flask.render_template(
      'resource/resource_view.html',
      html_class='resource-view',
      title='%s' % (resource_db.name),
      resource_db=resource_db,
    )
开发者ID:iroot,项目名称:gae-init-page,代码行数:15,代码来源:resource.py


示例14: profile

def profile():
    user_db = auth.current_user_db()
    form = ProfileUpdateForm(obj=user_db)

    if form.validate_on_submit():
        form.populate_obj(user_db)
        user_db.put()
        return flask.redirect(flask.url_for("welcome"))

    if flask.request.path.startswith("/_s/"):
        return util.jsonify_model_db(user_db)

    return flask.render_template(
        "profile.html", title=user_db.name, html_class="profile", form=form, user_db=user_db, has_json=True
    )
开发者ID:JackNova,项目名称:gae-init,代码行数:15,代码来源:main.py


示例15: profile

def profile():
    form = ProfileUpdateForm()
    user_db = auth.current_user_db()
    if form.validate_on_submit():
        user_db.name = form.name.data.strip()
        user_db.email = form.email.data.strip().lower()
        user_db.put()
        return flask.redirect(flask.url_for("welcome"))
    if not form.errors:
        form.name.data = user_db.name
        form.email.data = user_db.email or ""

    if flask.request.path.startswith("/_s/"):
        return util.jsonify_model_db(user_db)

    return flask.render_template("profile.html", title="Profile", html_class="profile", form=form, user_db=user_db)
开发者ID:handol,项目名称:gae-init,代码行数:16,代码来源:main.py


示例16: admin_config_update

def admin_config_update():
  form = ConfigUpdateForm()

  config_db = model.Config.get_master_db()
  if form.validate_on_submit():
    config_db.analytics_id = form.analytics_id.data.strip()
    config_db.announcement_html = form.announcement_html.data.strip()
    config_db.announcement_type = form.announcement_type.data.strip()
    config_db.brand_name = form.brand_name.data.strip()
    config_db.bucket_name = form.bucket_name.data.strip()
    config_db.facebook_app_id = form.facebook_app_id.data.strip()
    config_db.facebook_app_secret = form.facebook_app_secret.data.strip()
    config_db.feedback_email = form.feedback_email.data.strip()
    config_db.flask_secret_key = form.flask_secret_key.data.strip()
    config_db.locale = form.locale.data.strip()
    config_db.twitter_consumer_key = form.twitter_consumer_key.data.strip()
    config_db.twitter_consumer_secret = form.twitter_consumer_secret.data.strip()
    config_db.put()
    reload(config)
    app.config.update(CONFIG_DB=config_db)
    return flask.redirect(flask.url_for('welcome'))
  if not form.errors:
    form.analytics_id.data = config_db.analytics_id
    form.announcement_html.data = config_db.announcement_html
    form.announcement_type.data = config_db.announcement_type
    form.brand_name.data = config_db.brand_name
    form.bucket_name.data = config_db.bucket_name
    form.facebook_app_id.data = config_db.facebook_app_id
    form.facebook_app_secret.data = config_db.facebook_app_secret
    form.feedback_email.data = config_db.feedback_email
    form.flask_secret_key.data = config_db.flask_secret_key
    form.locale.data = config_db.locale
    form.twitter_consumer_key.data = config_db.twitter_consumer_key
    form.twitter_consumer_secret.data = config_db.twitter_consumer_secret

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(config_db)

  return flask.render_template(
      'admin/config_update.html',
      title=_('Admin Config'),
      html_class='admin-config',
      form=form,
      config_db=config_db,
    )
开发者ID:iroot,项目名称:gae-init-page,代码行数:45,代码来源:admin.py


示例17: config_update

def config_update():
    config_db = model.Config.get_master_db()
    form = ConfigUpdateForm(obj=config_db)
    if form.validate_on_submit():
        form.populate_obj(config_db)
        config_db.put()
        update_config_variables(config_db)
        flask.flash('Your Config settings have been saved', category='success')
        return flask.redirect(flask.url_for('admin.config_update'))
    if flask.request.path.startswith('/_json/'):
        return util.jsonify_model_db(config_db)
    return flask.render_template(
        'admin/config_update.html',
        title=u'Общие настройки',
        html_class='admin-config',
        form=form,
        config_db=config_db,
    )
开发者ID:gmist,项目名称:3dhero.ru,代码行数:18,代码来源:admin_views.py


示例18: resource_upload

def resource_upload():
  if flask.request.method == 'GET':
    gs_bucket_name = config.CONFIG_DB.bucket_name or None
    count = util.param('count', int) or 1

    if flask.request.path.startswith('/_s/'):
      urls = []
      for i in range(count):
        urls.append({'upload_url': blobstore.create_upload_url(
            flask.request.path,
            gs_bucket_name=gs_bucket_name,
          )})
      return flask.jsonify({
          'status': 'success',
          'count': count,
          'result': urls,
        })

    return flask.render_template(
        'resource/resource_upload.html',
        title='Resource Upload',
        html_class='resource-upload',
        get_upload_url=flask.url_for('resource_upload_service'),
        has_json=True,
        upload_url=blobstore.create_upload_url(
            flask.request.path,
            gs_bucket_name=gs_bucket_name,
          ),
      )

  # POST stuff
  resource_db = resource_db_from_upload()

  if flask.request.path.startswith('/_s/'):
    if resource_db:
      return util.jsonify_model_db(resource_db)
    else:
      flask.abort(500)

  if resource_db:
    return flask.redirect(flask.url_for('welcome'))
  else:
    flask.flash('Something went wrong with the uploading.. please try again!', category='danger')
    return flask.redirect(flask.url_for('resource_upload'))
开发者ID:alpocr,项目名称:gae-init-upload,代码行数:44,代码来源:resource.py


示例19: profile

def profile():
  user_db = auth.current_user_db()
  form = ProfileUpdateForm(obj=user_db)

  if form.validate_on_submit():
    form.populate_obj(user_db)
    user_db.put()
    return flask.redirect(flask.url_for('welcome'))

  if flask.request.path.startswith('/_s/'):
    return util.jsonify_model_db(user_db)

  return flask.render_template(
      'profile.html',
      title='Profile',
      html_class='profile',
      form=form,
      user_db=user_db,
    )
开发者ID:smitson,项目名称:gae-init,代码行数:19,代码来源:main.py


示例20: 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)
    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)

  return flask.render_template(
      'admin/config_update.html',
      title='Admin Config',
      html_class='admin-config',
      form=form,
      config_db=config_db,
    )
开发者ID:oliver32767,项目名称:gae-init-debug,代码行数:20,代码来源:admin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.jsonify_model_dbs函数代码示例发布时间:2022-05-26
下一篇:
Python util.joiniter函数代码示例发布时间: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