I use web.auto_application() so controller classes define their path
themselves

# app.py

app = web.auto_application()

# controller/__init__.py

import sys
sys.path.append("..")

__all__ = [
    "auth",
    "application",
    "documents",
    "blocks",
    "pages",
]

# controller/auth.py

from app import app

class Users(app.page):

    path="/a/users/?"

    @auth.restrict(role="admin")
    def GET(self):
        users = db.select("users", where="NOT is_deleted", order="id
DESC")
        user_form = userForm()
        return render.auth.list(users, user_form)

# code.py

import os
import sys

sys.path.append(os.path.abspath(os.path.dirname(__file__)))

from app import app
from controller import *

if __name__ == "__main__":
    app.run()
else:
    application = app.wsgifunc()



On Oct 12, 7:07 pm, Tony <[email protected]> wrote:
> Hello,
>
> I'm trying to write a REST-style backend using webpy and wondered if
> anyone had suggestions or examples. The app deals with data sets in
> the 10k to 100k range of similar items, with the need to select out
> views of the data with different groupings and orders based on the
> properties of the items and return JSON for client side parsing. So
> what I wanted to do was something like this:
>
>  * /{container-uuid}/  (general listing of items)
>  * /{container-uuid}/attribute  (listing of items with the attribute)
>  * /{container-uuid}/attribute/value   (listing of items with the
> specific attribute value)
>  * /{container-uuid}/{item-id}    (summary listing of single item)
>  * /{container-uuid}/{item-id}/detailed   (detailed listing of a
> single item)
>
> I wanted to use the GET parameters for iterating through the result
> sets (using jqGrid for the HTML view) to handle skip, offset, sort
> order, etc. When I started to try doing this I ran into an
> inconsistency in the subapp regex handling, basically you can't use
> regex in subapps:
>
> https://github.com/webpy/webpy/issues/12
>
> Trying to keep everything in one giant python script makes the code
> difficult to read and it will take some careful planning to break
> things out into libraries or functions. Either that or I'll have to
> put all the parameters into GET/POST/DELETE variables which is not
> what I want to do either. Has anyone got a good template or example
> for doing this kind of thing?
>
> Tony

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to