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


Python FieldSet.configure方法代码示例

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


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

示例1: cFilter

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
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,代码行数:9,代码来源:forms.py

示例2: readonly_form

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
    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,代码行数:27,代码来源:fa.py

示例3: edit_blog_post

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
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,代码行数:29,代码来源:views.py

示例4: edit_page

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
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,代码行数:34,代码来源:views.py

示例5: _makeFS

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
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,代码行数:10,代码来源:registry.py

示例6: blogpost_form_factory

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
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,代码行数:16,代码来源:views.py

示例7: cpFilter

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
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,代码行数:16,代码来源:forms.py

示例8: __init__

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
class UserForm:
    def __init__(self):
        #这里的directories是指表单模板存放的地方,我们在第二章提到的templates下创建一个文件夹,命名为form
        config.engine = Jinja2Engine(directories=["templates/form"])
 
    #为表单设置label
    def setLabel(self):
        self.name = self.fs.name.label("User Name")
        self.email = self.fs.email.label("Email Address")
        self.password = self.fs.password.label("Password")
        self.superuser = self.fs.superuser.label("Admin?")

    #定义编辑模式下通用的设置,编辑模式包括:新增,修改
    def wmode(self, password=None):
        self.setLabel()
 
        #因为新增和修改中都需要用户重新确认密码,所以要为表单加入Confirm Password
        #如果有指定password的值,说明用户是在修改记录,那么Confirm Password也必须有值
        if not password:
            self.fs.insert_after(self.fs.password, Field("confirm_password"))
        else:
            self.fs.insert_after(self.fs.password, Field("confirm_password", value=password))
        self.confirm_password = self.fs.confirm_password.label("Re-enter Password")
 
        self.name = self.name.required()
        self.email = self.email.required().email().validate(validators.email)
        self.password = self.password.required().password()
        self.confirm_password = self.confirm_password.required().password()
 
    #定义新增用户时调用的方法
    def write_render(self, cls):
        #设置Fieldset对象,指定要绑定的sqlalchemy中的表类,并赋予sqlalchemy的session
        self.fs = FieldSet(User, session=cls.db)
        self.wmode()
 
        #配置表单信息
        self.fs.configure(
            #表单包含的字段
            include=[
                self.name,
                self.email,
                self.password,
                self.confirm_password,
                self.superuser
            ]
        )
        return self.fs
开发者ID:vzer,项目名称:xiniunet-other,代码行数:49,代码来源:forms.py

示例9: new_blog_post

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
def new_blog_post(request):
    session = DBSession()

    if 'submitted' in request.params:
        post = Post()
        fs = FieldSet(Post, data=request.params)
        post.title = fs.title.value
        post.content = fs.content.value
        now = time.time()
        post.modified_time = now
        post.created_time = now
        post.user_id = authenticated_userid(request)
        session.add(post)

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

    new_blog_post_url = route_url("new_blog_post", request)
    fs = FieldSet(Post, session = session)
    fs.configure(options=[fs.content.textarea(size=(45, 10))], exclude = [fs["modified_time"], fs["user"], fs["comments"], fs["created_time"]])
    form = fs.render()
    return dict(title = _("New Fluid Nexus Blog Post"), form = form, new_blog_post_url = new_blog_post_url)
开发者ID:zeitkunst,项目名称:FluidNexusWebsite,代码行数:23,代码来源:views.py

示例10: new_page

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
def new_page(request):
    session = DBSession()

    if 'submitted' in request.params:
        page = Page()
        fs = FieldSet(Page, data=request.params)
        page.title = fs.title.value
        page.content = fs.content.value
        page.location = fs.location.value.lower()
        now = time.time()
        page.modified_time = now
        page.created_time = now
        page.user_id = authenticated_userid(request)
        session.add(page)

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

    new_page_url = route_url("new_page", request)
    fs = FieldSet(Page, session = session)
    fs.configure(options=[fs.content.textarea(size=(45, 10))], exclude = [fs["modified_time"], fs["user"], fs["created_time"]])
    form = fs.render()
    return dict(title = "Create new Fluid Nexus page", save_name = save_name, form = form)
开发者ID:zeitkunst,项目名称:FluidNexusWebsite,代码行数:24,代码来源:views.py

示例11: FieldSet

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
from bind_config_manager.lib.base import BaseController, render

log = logging.getLogger(__name__)

import bind_config_manager.lib.helpers as h
from bind_config_manager import model
from bind_config_manager.model import meta
from formalchemy import FieldSet
from formalchemy.validators import *

DomainFields = FieldSet(model.Domain)
DomainFields.configure(
  options=[
    DomainFields.type.dropdown(['master', 'slave']),
    DomainFields.name.validate(regex('^[\w\.]+$')),
    DomainFields.soa_nameserver.validate(regex('^[\w\.]+$')),
    DomainFields.admin_mailbox.validate(regex('^[\w\.]+$')),
  ],
  exclude=[DomainFields.records]
)


class DomainsController(BaseController):
    
    requires_auth = True
    
    def index(self):
        c.domains = meta.Session.query(model.Domain).all()
        return render('domains/index.html')
    
    def new(self):
开发者ID:svarks,项目名称:bind_config_manager,代码行数:33,代码来源:domains.py

示例12: FieldSet

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect

from bind_config_manager.lib.base import BaseController, render

log = logging.getLogger(__name__)

from bind_config_manager import model
from bind_config_manager.model import meta
import bind_config_manager.lib.helpers as h

import formalchemy
from formalchemy import FieldSet

UserFields = FieldSet(model.User)
UserFields.configure(include=[UserFields.username, UserFields.password, UserFields.is_admin, UserFields.is_active])
UserFields.password.name = 'password'

class UsersController(BaseController):
    
    requires_admin = True
    
    def new(self):
        c.fs = UserFields
        return render('users/new.html')
    
    def create(self):
        user = model.User()
        c.fs = UserFields.bind(user, data=request.POST)
        if c.fs.validate():
            c.fs.sync()
开发者ID:svarks,项目名称:bind_config_manager,代码行数:33,代码来源:users.py

示例13: Module

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
import re

from flask import Module, request, session, g, redirect, url_for, \
     abort, render_template, flash
from formalchemy import FieldSet
from formalchemy.base import ModelRenderer
from sqlalchemy.exceptions import IntegrityError

import model
from model import db

projects = Module(__name__)

project_form = FieldSet(model.Project)
project_form.configure(options=[
    project_form.description.textarea('70x20'),
    project_form.rating.hidden(),
    ])


model_re = re.compile('(\w+)-(\d*)-.*')

def split_model(fields):
    """Find the (ModelClass, id) of the first matching form field.

    The field names are like ModelClass-id-FieldName
    """
    for field_name, value in fields.items():
        m = model_re.match(field_name)
        if m:
            model_name, id = m.groups()
            if not id:
开发者ID:allancaffee,项目名称:programmingbyexample,代码行数:34,代码来源:projects.py

示例14: FieldSet

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
from formalchemy import FieldSet, Grid

from pylons import request, response, session, tmpl_context as c, url
from pylons.controllers.util import abort, redirect

from ideabox.lib.base import BaseController, Session, render
from ideabox.model.project import Project, TaskList, Task
from ideabox.model.user import User
import ideabox.model as model

log = logging.getLogger(__name__)

project_form = FieldSet(Project)
project_form.configure(
    include = [
        project_form.name,
        project_form.description.textarea(),
    ]
)
# TODO project description will get cut off after 300 chars. The use should be warned.


class ProjectsController(BaseController):

    filter_actions = ["new", "edit", "create", "update", "delete", "index"]

    def new(self):
        context = {
            "project_form": project_form.render()
        }
        return render("projects/new.html", context)
开发者ID:mengu,项目名称:ideabox,代码行数:33,代码来源:projects.py

示例15: TemplateEngine

# 需要导入模块: from formalchemy import FieldSet [as 别名]
# 或者: from formalchemy.FieldSet import configure [as 别名]
from formalchemy import Grid, FieldSet, config
from pyramid_formalchemy.utils import TemplateEngine
from fa.jquery import renderers as fa_renderers

from pygall import models
from pygall.lib.forms.pygallimage import PyGallImageFieldRenderer

config.engine = TemplateEngine()

FieldSet.default_renderers.update(fa_renderers.default_renderers)

Tag = FieldSet(models.Tag)
Tag.configure(exclude=[Tag.photos])
TagGrid = Grid(models.Tag)
TagGrid.configure(exclude=[TagGrid.photos])

PhotoView = FieldSet(models.Photo)
PhotoView.fspot_id.set(readonly=True)
PhotoView.md5sum.set(readonly=True)
PhotoView.uri.set(renderer=PyGallImageFieldRenderer)
PhotoView.configure()

PhotoEdit = FieldSet(models.Photo)
PhotoEdit.fspot_id.set(readonly=True)
PhotoEdit.md5sum.set(readonly=True)
PhotoEdit.uri.set(renderer=PyGallImageFieldRenderer, readonly=True)
PhotoEdit.configure()

PhotoAdd = FieldSet(models.Photo)
PhotoAdd.uri.set(renderer=PyGallImageFieldRenderer)
PhotoAdd.configure(exclude=[
开发者ID:bbinet,项目名称:PyGall,代码行数:33,代码来源:forms.py


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