| | 52 | |
|---|
| | 53 | class PositionalParametersAware(object): |
|---|
| | 54 | """ |
|---|
| | 55 | Utility class that restores positional parameters functionality that |
|---|
| | 56 | was found in 2.0.0-beta. |
|---|
| | 57 | |
|---|
| | 58 | Use case: |
|---|
| | 59 | |
|---|
| | 60 | from cherrypy.lib import cptools |
|---|
| | 61 | from cherrypy import cpg |
|---|
| | 62 | class Root(cptools.PositionalParametersAware): |
|---|
| | 63 | def something(self, name): |
|---|
| | 64 | return "hello, " + name |
|---|
| | 65 | something.exposed |
|---|
| | 66 | cpg.root = Root() |
|---|
| | 67 | cpg.server.start() |
|---|
| | 68 | |
|---|
| | 69 | Now, fetch http://localhost:8080/something/name_is_here |
|---|
| | 70 | """ |
|---|
| | 71 | def default( self, *args, **kwargs ): |
|---|
| | 72 | # remap parameters to fix positional parameters |
|---|
| | 73 | if hasattr( self, args[ 0 ] ): |
|---|
| | 74 | return getattr( self, args[ 0 ] )( *args[ 1: ], **kwargs ) |
|---|
| | 75 | default.exposed = True |
|---|
| | 76 | |
|---|