Changes between Version 2 and Version 3 of CallbacksAndForms


Ignore:
Timestamp:
06/25/2009 02:55:24 PM (9 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CallbacksAndForms

    v2 v3  
    5353 
    5454   class GuestBook: 
    55    def __init__(self): 
    56        self.msgs = [] 
    57  
    58    def add_message(self, msg): 
    59        self.msgs.append(msg) 
     55       def __init__(self): 
     56           self.msgs = [] 
     57 
     58       def add_message(self, msg): 
     59           self.msgs.append(msg) 
    6060 
    6161   @presentation.render_for(GuestBook) 
     
    107107``h.select(multiple=1)``     ``.action(callback)``      a tuple of the selected options value (even if 
    108108                                                        only one option is selected) 
    109 ``h.img``                    ``.action(callback)``      the image data (the callback will be called when 
    110                                                         the browser requests the image). 
    111                                                         If no ``h.response.content_type`` is set by the 
    112                                                         callback then Nagare will try to guess the image 
    113                                                         type.  
     109``h.img``                    ``.action(callback)``      *no parameter* 
     110                                                        The callback is called when the browser requests 
     111                                                        the image. The callback is called with the response 
     112                                                        object as parameter and must return the image data. 
     113                                                        If the ``content_type`` attribut of the response 
     114                                                        object is not set by the callback, Nagare will try 
     115                                                        to guess the image type. 
    114116============================ ========================== ================================================== 
    115117 
     
    156158selected checkboxes. So, you need to reset the attributes that keep the current 
    157159selected checkboxes before to process the callbacks. This reset method is 
    158 typically the ```pre_action`` callback of ``h.form``:  
     160typically the ```pre_action`` callback of the ``h.form``: 
    159161    
    160162.. code-block:: python 
     
    209211variable-like objects that provide a "functional" interface: 
    210212 
    211   - calling the object with a value, set the variable value 
     213  - calling the object with a value, set the variable value and return the value 
    212214  - calling the object without a value, return the variable value 
    213215 
     
    240242~~~~~~~~~~~~~~~~~ 
    241243 
    242 Calling the ``.error(msg)`` method on an element wrap it into styled ``div``, 
     244Calling the ``.error(msg)`` method on an element wrap it into styled ``div`` 
    243245if ``msg`` is not ``None``: 
    244246 
     
    358360   # the value is lesser than 10 and positive, and, finally, convert it to an 
    359361   # integer before to return it 
    360    >>> number.validate(lambda v: IntValidator(v).lesser_than(10).greater_than(0).to_int()) 
     362   >>> number.validate(lambda v: IntValidator(v).lesser_than(10).greater_than(0)) 
    361363 
    362364   >>> number(2) 
     
    429431           # We use a string validator to check that the name is not empty i.e 
    430432           # the name is required 
    431            self.name.validate(lambda name: StringValidator(name).not_empty().to_string()) 
     433           self.name.validate(lambda name: StringValidator(name).not_empty()) 
    432434            
    433435           # We use an integer validator to check the age is positive  
    434            self.age.validate(lambda age: IntValidator(age).greater_than(0).to_int())               
     436           self.age.validate(lambda age: IntValidator(age).greater_than(0))               
    435437 
    436438       # This ``commit`` method will write back the values of the ``name`` and