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


Python FieldSet.sync方法代码示例

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


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

示例1: post

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import sync [as 别名]
 def post(self):
     fs = FieldSet(self.instance,
                   data=self.request.POST)
     if fs.validate():
         fs.sync()
         self.session.flush()
         return HTTPFound(location=fs.model.getUrl())
开发者ID:SEL-Columbia,项目名称:gateway,代码行数:9,代码来源:handlers.py

示例2: object_edit

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import sync [as 别名]
def object_edit(model_slug, model_key=None, **attrs):
	if model_slug not in models:
		abort(404)
	model = models[model_slug]
	sk = attrdict()
	if model_key:
		try: data = model.q.get_by(id=model_key)
		except NoData: abort(404)
	else:
		data = model
		sk.session = db

	if model_key:
		obj = model.q.get_by(id=int(model_key))
	else:
		obj = None

	fields = FieldSet(data, **sk)
	_fixup_fs(fields,model_key,attrs)

	if request.method == 'POST':
		fields.rebind(data=request.form)
		if fields.validate():
			fields.sync()
			next_url = url_for('_admin.object_list', model_slug=model_slug)
			return redirect(next_url)
	context = {
		'model_slug': model_slug,
		'model': model,
		'fields': fields,
	}
	template_name = '_admin/edit.html' if model_key else '_admin/new.html'
	return render_template(template_name, **context)
开发者ID:smurfix,项目名称:pybble,代码行数:35,代码来源:__init__.py

示例3: save

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import sync [as 别名]
 def save(self, model, data, session):
     fs = FieldSet(model, session=session)
     fs.rebind(model, data=data)
     if fs.validate():
         fs.sync()
         return True
     #TODO: need to return validation result
     return False
开发者ID:sergeyv,项目名称:crud,代码行数:10,代码来源:fa.py

示例4: new

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import sync [as 别名]
 def new(self, req, model_name):
     model = self.model.get_model_or_404(model_name)
     if req.method == 'POST':
         item = model()
         fs = FieldSet(item, session=session, data=req.form)
         if fs.validate():
             fs.sync()
             item.save()
             session.commit()
             return self.redirect_to('list', model_name=model_name)
     else:
         fs = FieldSet(model, session=session)
     return self.render_response('_admin/new.jinja',
         item=None, model_name=model_name, fs=fs)
开发者ID:fugu13,项目名称:opp-frontpage,代码行数:16,代码来源:__init__.py

示例5: edit

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import sync [as 别名]
 def edit(self, req, model_name, id):
     model = self.model.get_model_or_404(model_name)
     item = model.query.get(id)
     if req.method == 'POST':
         fs = FieldSet(item, data=req.form)
         if fs.validate():
             fs.sync()
             item.save()
             session.commit()
             return self.redirect_to('list', model_name=model_name)
     else:
         fs = FieldSet(item)
     return self.render_response('_admin/new.jinja',
         item=item, model_name=model_name, fs=fs, crumbs=[model_name, 'Edit'])
开发者ID:fugu13,项目名称:opp-frontpage,代码行数:16,代码来源:__init__.py

示例6: edit

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import sync [as 别名]
def edit(request):
    model = meta.__dict__.get(request.matchdict["model"])

    if "id" in request.matchdict:
        obj = request.db.query(model).filter(model.id==request.matchdict["id"]).first()
        fs = FieldSet(obj, request=request)
    else:
        fs = FieldSet(model, session=request.db, request=request)

    if "POST"==request.environ.get("REQUEST_METHOD", "").upper() and request.POST:
        if fs.validate():
            request.db.add(fs.model)
            fs.sync()
            return HTTPFound(location=request.route_url("list", model=request.matchdict["model"]))

    return { 'fs': fs }
开发者ID:petrblahos,项目名称:faapp-sample,代码行数:18,代码来源:views.py

示例7: saveedit

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import sync [as 别名]
def saveedit(request):
    model = meta.__dict__.get(request.matchdict["model"])

    if "id" in request.matchdict:
        obj = request.db.query(model).filter(model.id==request.matchdict["id"]).first()
        fs = FieldSet(obj, request=request)
    else:
        fs = FieldSet(model, session=request.db, request=request)

    if fs.validate():
        request.db.add(fs.model)
        fs.sync()
    else:
        return { "fs": fs }

    return HTTPFound(location=request.route_url("list", model=request.matchdict["model"]))
开发者ID:petrblahos,项目名称:faapp-sample,代码行数:18,代码来源:views.py


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