Changes between Version 30 and Version 31 of S3/S3REST/s3_rest_controller


Ignore:
Timestamp:
10/24/10 05:51:55 (11 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3/S3REST/s3_rest_controller

    v30 v31  
    6767=== Callbacks ===
    6868
     69For every DB table, you can define functions to be invoked upon certain CRUD events. Those "callbacks" can be:
     70
     71  - a single callable (function, lambda, callable object)
     72  - a list of callables, which are invoked in list order
     73  - a dict of callables, where the tablename is used as key to find the callable to be invoked
     74  - a dict of lists of callables, where the tablename is used as key to find the list of callables to be executed in list order
     75
     76The return value of the callables, if any, is ignored.
     77
     78==== Validation Callbacks ====
     79
     80After successful submission of a create/update form (=the input data have successfully passed the field validation), you can define extra form validation methods to be invoked by using:
     81
     82{{{
     83s3xrc.model.configure(table, create_onvalidation=callback)
     84}}}
     85{{{
     86s3xrc.model.configure(table, update_onvalidation=callback)
     87}}}
     88
     89where:
     90
     91  - '''table''' is the respective DB table
     92  - '''callable''' is the callback setting, see [#Callbacks Callbacks]
     93
     94If either of {{{create_onvalidation}}} or {{{update_onvalidation}}} is not set, then the {{{onvalidation}}} setting is tried:
     95
     96{{{
     97s3xrc.model.configure(table, onvalidation=callback)
     98}}}
     99
     100This allows you to define a common onvalidation callback for both ''create'' and ''update''.
     101
     102Onvalidation callbacks are meant to allow form data validation, where any validation errors are to be put directly into the form as:
     103
     104{{{
     105form.errors[fieldname] = error_msg
     106}}}
     107
     108where:
     109
     110  - '''fieldname''' is the field containing the invalid value
     111  - '''error_msg''' is the error message to be displayed in the form close to that field
     112
     113The callables receive the form as first and only parameter, and their return values will be ignored.
     114
     115'''Important:'''
     116  On-validation callbacks are also invoked in non-interactive data imports, where multiple records are being processed in one and the same request. Therefore the callback '''must not redirect'''!
     117
     118==== On-accept Callbacks ====
     119
     120==== On-Delete Callback ====
    69121=== Pagination ===
    70122