How to use the formencode.validators.Int function in FormEncode

To help you get started, we’ve selected a few FormEncode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / allura / Allura / allura / ext / user_profile / user_main.py View on Github external
    @expose()
    @validate(dict(
            since=DateTimeConverter(if_empty=None),
            until=DateTimeConverter(if_empty=None),
            page=validators.Int(if_empty=None),
            limit=validators.Int(if_empty=None)))
    def feed(self, since=None, until=None, page=None, limit=None):
        username = c.project.shortname.split('/')[1]
        user = User.by_username(username)
        if request.environ['PATH_INFO'].endswith('.atom'):
            feed_type = 'atom'
        else:
            feed_type = 'rss'
        title = 'Recent posts by %s' % user.display_name
        feed = Notification.feed(
            {'author_id':user._id},
            feed_type,
            title,
            c.project.url(),
            title,
            since, until, page, limit)
        response.headers['Content-Type'] = ''
github ebroder / bluechips / bluechips / controllers / transfer.py View on Github external
from pylons import request, app_globals as g
from pylons.decorators import validate
from pylons.decorators.secure import authenticate_form
from pylons.controllers.util import abort

from formencode import Schema, validators

from mailer import Message

log = logging.getLogger(__name__)


class TransferSchema(AuthFormSchema):
    "Validate a transfer."
    allow_extra_fields = False
    debtor_id = validators.Int(not_empty=True)
    creditor_id = validators.Int(not_empty=True)
    amount = model.types.CurrencyValidator(not_empty=True)
    description = validators.UnicodeString()
    date = validators.DateConverter()
 

class TransferController(BaseController):
    def index(self):
       return self.edit()
    
    def edit(self, id=None):
        c.users = get_users()
        if id is None:
            c.title = 'Add a New Transfer'
            c.transfer = model.Transfer()
            c.transfer.debtor_id = request.environ['user'].id
github apache / allura / ForgeWiki / forgewiki / wiki_main.py View on Github external
                   page=validators.Int(if_empty=0, if_invalid=0),
                   limit=validators.Int(if_empty=None, if_invalid=None)))
    def index(self, version=None, page=0, limit=None, **kw):
        if not self.page:
            redirect(c.app.url + h.urlquote(self.title) + '/edit')
        c.confirmation = W.confirmation
        c.thread = W.thread
        c.attachment_list = W.attachment_list
        c.subscribe_form = W.page_subscribe_form
        post_count = self.page.discussion_thread.post_count
        limit, pagenum, _ = g.handle_paging(limit, page)
        limit, pagenum = h.paging_sanitizer(limit, pagenum, post_count)
        page = self.get_version(version)
        if page is None:
            if version:
                redirect('.?version=%d' % (version - 1))
            else:
github apache / allura / Allura / allura / controllers / repository.py View on Github external
    @without_trailing_slash
    @expose()
    @validate(dict(
            since=h.DateTimeConverter(if_empty=None, if_invalid=None),
            until=h.DateTimeConverter(if_empty=None, if_invalid=None),
            offset=validators.Int(if_empty=None),
            limit=validators.Int(if_empty=None)))
    def feed(self, since=None, until=None, offset=None, limit=None):
        if request.environ['PATH_INFO'].endswith('.atom'):
            feed_type = 'atom'
        else:
            feed_type = 'rss'
        title = 'Recent changes to %s' % c.app.config.options.mount_point
        feed = M.Feed.feed(
            dict(project_id=c.project._id,app_config_id=c.app.config._id),
            feed_type,
            title,
            c.app.url,
            title,
            since, until, offset, limit)
        response.headers['Content-Type'] = ''
        response.content_type = 'application/xml'
github apache / allura / ForgeWiki / forgewiki / wiki_main.py View on Github external
                   limit=validators.Int(if_empty=25, if_invalid=25)))
    def index(self, version=None, page=0, limit=25, **kw):
        if not self.page:
            redirect(c.app.url+h.urlquote(self.title)+'/edit')
        c.thread = W.thread
        c.attachment_list = W.attachment_list
        c.subscribe_form = W.page_subscribe_form
        post_count = self.page.discussion_thread.post_count
        limit, pagenum = h.paging_sanitizer(limit, page, post_count)
        page = self.get_version(version)
        if page is None:
            if version: redirect('.?version=%d' % (version-1))
            else: redirect('.')
        elif 'all' not in page.viewable_by and c.user.username not in page.viewable_by:
            raise exc.HTTPForbidden(detail="You may not view this page.")
        cur = page.version
        if cur > 1: prev = cur-1
github mediadrop / mediadrop / mediadrop / controllers / sitemaps.py View on Github external
        'limit': validators.Int(if_empty=10000, if_missing=10000, if_invalid=10000)
    })
    @beaker_cache(expire=60 * 60 * 4)
    @expose('sitemaps/google.xml')
    @observable(events.SitemapsController.google)
    def google(self, page=None, limit=10000, **kwargs):
        """Generate a sitemap which contains googles Video Sitemap information.

        This action may return a  or a , depending
        on how many media items are in the database, and the values of the
        page and limit params.

        :param page: Page number, defaults to 1.
        :type page: int
        :param page: max records to display on page, defaults to 10000.
        :type page: int
github aptise / peter_sslers / peter_sslers / web / lib / forms.py View on Github external
account_key_option = OneOf(model_utils.AcmeAccontKey_options_a, not_empty=True,)
    account_key_global_default = UnicodeString(not_empty=False, if_missing=None)
    account_key_existing = UnicodeString(not_empty=False, if_missing=None)

    # these are via Form_AcmeAccount_new__file
    account_key_file_pem = FieldStorageUploadConverter(not_empty=False, if_missing=None)
    account_key_file_le_meta = FieldStorageUploadConverter(
        not_empty=False, if_missing=None
    )
    account_key_file_le_pkey = FieldStorageUploadConverter(
        not_empty=False, if_missing=None
    )
    account_key_file_le_reg = FieldStorageUploadConverter(
        not_empty=False, if_missing=None
    )
    acme_account_provider_id = Int(not_empty=False, if_missing=None)


class _form_PrivateKey_core(_Form_Schema_Base):
    private_key_option = OneOf(model_utils.PrivateKey_options_a, not_empty=True,)
    private_key_existing = UnicodeString(not_empty=False, if_missing=None)
    private_key_file_pem = FieldStorageUploadConverter(not_empty=False, if_missing=None)


class _form_AcmeAccount_reuse(_form_AcmeAccount_core):
    account_key_option = OneOf(model_utils.AcmeAccontKey_options_b, not_empty=True,)
    account_key_reuse = UnicodeString(not_empty=False, if_missing=None)


class _form_PrivateKey_reuse(_form_PrivateKey_core):
    private_key_option = OneOf(model_utils.PrivateKey_options_b, not_empty=True)
    private_key_reuse = UnicodeString(not_empty=False, if_missing=None)