當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。