Ñò ìÜIc @ s* d Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k l Z d d k l Z l Z l Z d d k l Z d d k l Z d d k l Z d d g Z e i e ƒ Z d „ Z e e ƒ Z d d d e d d e d e d „ Z d „ Z d d „ Z d „ Z d e f d „ ƒ YZ d S( sï Pylons Decorators Common decorators intended for use in controllers. Additional decorators for use with controllers are in the :mod:`~pylons.decorators.cache`, :mod:`~pylons.decorators.rest` and :mod:`~pylons.decorators.secure` modules. iÿÿÿÿN( t decorator( t apit htmlfillt variabledecode( t UnicodeMultiDict( t get_pylons( t _t jsonifyt validatec O s… t | ƒ } d | i i d <| | | Ž } t | t t f ƒ o* d } t i | t d ƒ t i | ƒ n t i d ƒ t i | ƒ S( s× Action decorator that formats output for JSON Given a function that will return content, this decorator will turn the result into JSON, with a content-type of 'application/json' and output it. s application/jsons Content-Types JSON responses with Array envelopes are susceptible to cross-site data leak attacks, see http://pylonshq.com/warnings/JSONArrayi s$ Returning JSON wrapped action output( R t responset headerst isinstancet listt tuplet warningst warnt Warningt logt warningt debugt simplejsont dumps( t funct argst kwargst pylonst datat msg( ( s> /usr/lib/python2.6/site-packages/pylons/decorators/__init__.pyR s t .t -c sK ˆ d j o t ‰ n ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ f d † } t | ƒ S( s› Validate input either for a FormEncode schema, or individual validators Given a form schema or dict of validators, validate will attempt to validate the schema or validator list. If validation was successful, the valid result dict will be saved as ``self.form_result``. Otherwise, the action will be re-run as if it was a GET, and the output will be filled by FormEncode's htmlfill to fill in the form field errors. ``schema`` Refers to a FormEncode Schema object to use during validation. ``form`` Method used to display the form, which will be used to get the HTML representation of the form for error filling. ``variable_decode`` Boolean to indicate whether FormEncode's variable decode function should be run on the form input before validation. ``dict_char`` Passed through to FormEncode. Toggles the form field naming scheme used to determine what is used to represent a dict. This option is only applicable when used with variable_decode=True. ``list_char`` Passed through to FormEncode. Toggles the form field naming scheme used to determine what is used to represent a list. This option is only applicable when used with variable_decode=True. ``post_only`` Boolean that indicates whether or not GET (query) variables should be included during validation. .. warning:: ``post_only`` applies to *where* the arguments to be validated come from. It does *not* restrict the form to only working with post, merely only checking POST vars. ``state`` Passed through to FormEncode for use in validators that utilize a state object. ``on_get`` Whether to validate on GET requests. By default only POST requests are validated. Example:: class SomeController(BaseController): def create(self, id): return render('/myform.mako') @validate(schema=model.forms.myshema(), form='create') def update(self, id): # Do something with self.form_result pass c si | i i } h } ˆ o% | i d d j o | | | | Ž Sˆ o | i } n | i } t | t ƒ } | i ƒ } ˆ o&