| | 505 | The s3_rest_controller has multiple hooks,Look at how s3_rest_controller is actually defined in models/00_utils.py: |
| | 506 | |
| | 507 | {{{ |
| | 508 | def s3_rest_controller(prefix=None, resourcename=None, **attr): |
| | 509 | |
| | 510 | set_handler = r.set_handler |
| | 511 | set_handler("barchart", s3_barchart) |
| | 512 | set_handler("compose", s3base.S3Compose) |
| | 513 | set_handler("copy", lambda r, **attr: \ |
| | 514 | redirect(URL(args="create", |
| | 515 | vars={"from_record":r.id}))) |
| | 516 | set_handler("deduplicate", s3base.S3Merge) |
| | 517 | set_handler("filter", s3base.S3Filter) |
| | 518 | set_handler("import", s3base.S3Importer) |
| | 519 | set_handler("map", s3base.S3Map) |
| | 520 | set_handler("profile", s3base.S3Profile) |
| | 521 | set_handler("report", s3base.S3Report) |
| | 522 | set_handler("import", S3PDF(), |
| | 523 | http = ["GET", "POST"], |
| | 524 | representation="pdf") |
| | 525 | |
| | 526 | |
| | 527 | # Execute the request and apply crud functionality or execute other method handler |
| | 528 | output = r(**attr) |
| | 529 | return output |
| | 530 | }}} |
| | 531 | |
| | 532 | This is nothing else than a wrapper for the global r object (an instance of S3Request). |
| | 533 | You don't have to use s3_rest_controller to have a RESTful API, you can make your own handler configuration and call r directly. |
| | 534 | |
| | 535 | But even when using s3_rest_controller, you can take control over what actually happens. A very comfortable (and recommended) way to get control over s3rest when using s3_rest_controller is to hook in prep and postp functions. Look above to find out when prep and postp hooks are invoked. |
| | 536 | |