| 524 | | """Allows REST style dispatch based on different HTTP methods |
|---|
| 525 | | |
|---|
| 526 | | For an example usage see turbogears.tests.test_restmethod |
|---|
| | 524 | """Allow REST style dispatch based on different HTTP methods. |
|---|
| | 525 | |
|---|
| | 526 | For an elaborate usage example see turbogears.tests.test_restmethod. |
|---|
| | 527 | |
|---|
| | 528 | In short, instead of an exposed method, you define a sub-class of |
|---|
| | 529 | RESTMethod inside the controller class and inside this class you define |
|---|
| | 530 | exposed methods named after each HTTP method that should be supported. |
|---|
| | 531 | |
|---|
| | 532 | Example:: |
|---|
| | 533 | |
|---|
| | 534 | class Controller(controllers.Controller): |
|---|
| | 535 | |
|---|
| | 536 | class article(copntrollers.RESTMethod): |
|---|
| | 537 | @expose() |
|---|
| | 538 | def get(self, id): |
|---|
| | 539 | ... |
|---|
| | 540 | |
|---|
| | 541 | @expose() |
|---|
| | 542 | def post(self, id): |
|---|
| | 543 | ... |
|---|
| | 544 | |
|---|
| 539 | | """Computes URLs. |
|---|
| 540 | | |
|---|
| 541 | | tgpath can be a list or a string. If the path is absolute (starts |
|---|
| 542 | | with a "/"), the server.webpath, SCRIPT_NAME and the approot of the |
|---|
| 543 | | application are prepended to the path. In order for the approot to |
|---|
| 544 | | |
|---|
| 545 | | be detected properly, the root object should extend |
|---|
| 546 | | |
|---|
| 547 | | controllers.RootController. |
|---|
| | 557 | """Computes relocatable URLs. |
|---|
| | 558 | |
|---|
| | 559 | tgpath can be a list or a string. If the path is absolute (starts with a |
|---|
| | 560 | "/"), the server.webpath, SCRIPT_NAME and the approot of the application |
|---|
| | 561 | are prepended to the path. In order for the approot to be detected |
|---|
| | 562 | properly, the root object must extend controllers.RootController. |
|---|