Hi, I would make sure a site and a subsite is a "resource" in Routes. RESTful really means that you are using the verbs available in HTTP, that is, GET, POST, UPDATE, DELETE without wasting name spaces like addsite, delsite, etc., in your URL. RESTful doesn't necessarily mean that you must *not* use a query in the URL (like ?site_id=1).
So, for your sites, I would have the following CRUD: Create: /admin/site/ (POST) Read: /admin/site/id (GET) Update: /admin/site/id (PUT) Delete: /admin/site/id (DELETE) Meaning that for your subsites, you could have the following CRUD: Create: /admin/subsite (POST) (where parent ID and any other info would be in the POST body) Read: /admin/subsite/id (GET) Update: /admin/subsite/id (PUT) Delete: /admin/subsite/id (DELETE) You can create a RESTful controller in Pylons with: $ paster restcontroller site sites (singular and plural version of your resource) This will create a controller with ready-to-use actions. Read about how Routes maps HTTP requests to your controller's actions when using "map.resource". http://routes.groovie.org/restful.html Here's the Pylons documentation about RESTful controllers: http://pylonshq.com/docs/en/0.9.7/controllers/#using-the-rest-controller-with-a-restful-api And here is something I wasn't aware of, I just found out about these decorators, could be handy: http://pylonshq.com/docs/en/1.0/modules/decorators_rest/ HTH, 2010/10/30 cd34 <[email protected]>: > I have an app I'm putting together that has a common UI issue, but, I > wasn't sure what the typical pylons method was to handle it. > Basically I have: > > Add Site > > site Edit | Delete | Add subsite > site Edit | Delete | Add subsite > subsite > site Edit | Delete | Add subsite > subsite > site Edit | Delete | Add subsite > > The controller is /admin/ and I have urls of /admin/site to create a > new site, /admin/site/id to edit the site and /admin/delsite/id to > delete a site. However, I am faced with the situation of adding a > subsite to an existing site without some hideous hack. > > I can't really do /admin/addsubsite/id where id = the parent site > id because that would invalidate the ability to later edit that > subsite. I'd prefer a restful uri or something without get > parameters, but, temporarily I've resorted to ?site_id=1. > > Any suggestions? > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" 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/pylons-discuss?hl=en. > > -- Alex | twitter.com/alexconrad -- You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en.
