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


Python formalchemy.FieldSet类代码示例

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


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

示例1: edit_blog_post

def edit_blog_post(request):
    session = DBSession()
    matchdict = request.matchdict
    post = session.query(Post).filter(Post.id == matchdict["post_id"]).one()

    if 'submitted' in request.params:
        fs = FieldSet(post, data=request.params)
        # TODO
        # Not sure why this is necessary...shouldn't I just be able to pass the session to FieldSet and have it sync?
        post.title = fs.title.value
        post.content = fs.content.value
        post.modified_time = time.time()
        session.add(post)

        return HTTPFound(location = route_url("view_blog_post", request, post_id = post.id))

    if 'delete' in request.params:
        session.delete(post)

        return HTTPFound(location = route_url("edit_blog", request))


    edit_blog_post_url = route_url("edit_blog_post", request, post_id = post.id)
    fs = FieldSet(post)
    fs.configure(options=[fs.content.textarea(size=(45, 10))], exclude = [fs["modified_time"], fs["created_time"], fs["user"]])
    form = fs.render()
    return dict(form = form, title = post.title, edit_blog_post_url = edit_blog_post_url)
开发者ID:zeitkunst,项目名称:FluidNexusWebsite,代码行数:27,代码来源:views.py

示例2: edit_page

def edit_page(request):
    """Edit a given page."""
    session = DBSession()
    matchdict = request.matchdict
    page = session.query(Page).join(User).filter(Page.id == matchdict["page_id"]).order_by(desc(Page.modified_time)).one()

    if 'submitted' in request.params:
        fs = FieldSet(page, data=request.params)
        # TODO
        # add validation
        # Not sure why this is necessary...shouldn't I just be able to pass the session to FieldSet and have it sync?
        page.title = fs.title.value
        page.content = fs.content.value
        page.modified_time = time.time()
        page.location = fs.location.value
        session.add(page)
        return HTTPFound(location = route_url("view_page", request, page_location = page.location))

    elif 'delete' in request.params:
        session.delete(page)
        return HTTPFound(location = route_url("edit_pages", request))



    edit_blog_post_url = route_url("edit_page", request, page_id = page.id)
    fs = FieldSet(page)
    fs.configure(options=[fs.content.textarea(size=(45, 10))], exclude = [fs["modified_time"], fs["created_time"], fs["user"]])
    form = fs.render()

    # TODO
    # Figure out how to delete using checkboxes
    return dict(title = "Edit '%s'" % page.title, save_name = save_name, delete_name = delete_name, form = form)
开发者ID:zeitkunst,项目名称:FluidNexusWebsite,代码行数:32,代码来源:views.py

示例3: readonly_form

    def readonly_form(self, resource):
        """
        returns a read-only view of a model
        """
        # Exclude stuff we're displaying as subitems
        exclude = []
        # subitems_source can be a class or a str here
        # we're only interested in str, as it's the name
        # of an attribute
        for (key, ss) in resource.subsections.items():
            exclude.append(ss.subitems_source)

        fs = FieldSet(resource.model)
        include = []
        # render models's fields using FA
        # TODO: there's a way to set this on the form itself
        # rather than on individual fields
        for (k, field) in fs.render_fields.items():
            if k not in exclude:
                include.append(field.readonly())
            else:
                pass

        fs.configure(include=include)
        return fs.render()
开发者ID:sergeyv,项目名称:crud,代码行数:25,代码来源:fa.py

示例4: post

 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,代码行数:7,代码来源:handlers.py

示例5: cFilter

def cFilter(context=None):
    ffs = FieldSet(Channel,session=__session__)
    ffs.permissions.is_collection = True
    ffs.configure(include=[ffs.title.label(_(u"Title")),
                           ffs.permissions.label(_(u"Permissions")),
                           ])
    return {'form': ffs}
开发者ID:OpenBfS,项目名称:dokpool-plone,代码行数:7,代码来源:forms.py

示例6: _makeFS

def _makeFS(klass, fields):
    """
    Erzeugt aus einer Feldliste und einer Pythonklasse ein Fieldset fuer alle Felder.
    """
    #print fields
    fs = FieldSet(klass, session=__session__)
    fs.configure(include=[getattr(fs, fname) for fname in fields])
    return fs
开发者ID:OpenBfS,项目名称:dokpool-plone,代码行数:8,代码来源:registry.py

示例7: __init__

    def __init__(self, user = None):
        """Pre-configuration"""
        FieldSet.__init__(self, User)

        inc = [
            self.username.label(_("* Username you provided when registering")),
            self.email.label(_("* E-mail address you provided when registering")).required().validate(email_match),
              ]
        self.configure(include = inc)
开发者ID:zeitkunst,项目名称:FluidNexusWebsite,代码行数:9,代码来源:forms.py

示例8: __init__

 def __init__(self, *arg, **kwargs):
     """Pre-configuration"""
     FieldSet.__init__(self, *arg, **kwargs)
     options = [self.ip_address.required().validate(IPAddressValidator),
                self.type.required(),
                self.location.textarea(size="25x10"),
                self.mac_address.validate(MacAddressValidator)
                ]
     self.configure(options=options)
开发者ID:fruch,项目名称:python-snippts,代码行数:9,代码来源:pool_server.py

示例9: __init__

 def __init__(self):
     FieldSet.__init__(self, Session)
     self.configure(options=[
             self.sched_start.label("Scheduled Start"),
             self.sched_end.label("Scheduled End"),
             self.approved.label("Approved?"),
             self.cancelled.label("Cancelled?"),
             self.start.label("Actual Start"),
             self.end.label("Actual End"),
             self.notes.label("Log").textarea()], exclude=[
             self.problem])
开发者ID:prarobinson,项目名称:cfmi,代码行数:11,代码来源:forms.py

示例10: __init__

 def __init__(self):
     FieldSet.__init__(self, User)
     self.add(Field('passwd1'))
     self.add(Field('passwd2'))
     include = [self.username,
                self.passwd1.password().label(u'Password'),
                self.passwd2.password().label(u'Confirm').\
                     validate(validators.passwords_match('passwd1')),
                self.email,
                self.firstname,
                self.lastname,
             ]
     self.configure(include=inc)
开发者ID:sumukh210991,项目名称:Cyberweb,代码行数:13,代码来源:newadmin.py

示例11: __init__

    def __init__(self):
        """Pre-configuration"""
        FieldSet.__init__(self, User)

        self.add(Field('passwd1'))
        self.add(Field('passwd2'))
        inc = [self.username,
               self.passwd1.password().label(u'Password'),
               self.passwd2.password().label(u'Confirm') \
                   .validate(validators.passwords_match('passwd1')),
               self.email,
               self.fullname
               ]
        self.configure(include=inc)
开发者ID:twdb,项目名称:txhis,代码行数:14,代码来源:admin_utils.py

示例12: cpFilter

def cpFilter(context=None):
    """
    """
    ffs = FieldSet(ChannelPermissions,session=__session__)
    ffs.channel.is_collection = True
    self = context.getContextObj()
    if shasattr(self, "myDPTransferFolder", acquire=True):
        c_field = ffs.channel_id.with_renderer(HiddenFieldRenderer)
    else:
        c_field = ffs.channel.with_null_as(('---', '')).dropdown(multiple=True,size=5)
    ffs.configure(include=[c_field,
                           ffs.doc_type.label(_(u"Doc. type short")),
                           ffs.perm.label(_("Permission"))])
    return {'form': ffs, 'filter' : p_pre_filter}
开发者ID:OpenBfS,项目名称:dokpool-plone,代码行数:14,代码来源:forms.py

示例13: blogpost_form_factory

def blogpost_form_factory(model, session=None, request=None):
    form = FieldSet(model, session=session, request=request)
    exclude = [form.user_id, form.user, form.date]
    form.configure(exclude=exclude,
            options=[
                form.text.textarea(),
                form.image.with_renderer(
                    FileFieldRenderer.new(
                            storage_path=img_storage_path,
                        )
                    )
                ]
        )
    return form
开发者ID:nskrypnik,项目名称:dneprpy,代码行数:14,代码来源:views.py

示例14: new

 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,代码行数:14,代码来源:__init__.py

示例15: edit

 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,代码行数:14,代码来源:__init__.py


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