[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-07 Thread Tracy Ruggles



On Dec 6, 2005, at 10:54 AM, Kevin Dangoor wrote:


On 12/6/05, paron [EMAIL PROTECTED] wrote:

I think that's RESTful, but that's just me. How about asking at the
REST Yahoo group? Kind of a second opinion? Some of the heavyweights
that don't hang around here, hang around there.


I've heard about that group, and I'm afraid we just don't have that
kind of time to wait for a conclusive answer :)

Enough of this thread seems to be in favor of choice #1, so that's
what I'm going to do for starters.


POST /link_styles/1/vote HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 12

support=true




[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-07 Thread Kevin Dangoor

On 12/7/05, Tracy Ruggles [EMAIL PROTECTED] wrote:
 POST /link_styles/1/vote HTTP/1.1
 Content-Type: application/x-www-form-urlencoded
 Content-Length: 12

 support=true

200 OK


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-06 Thread Janzert
+1 on 1.Explanation and origin of bike sheds. ;) http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/misc.html#BIKESHED-PAINTING
JanzertOn 12/6/05, Mike Orr [EMAIL PROTECTED] wrote:
What's a Bike Shed?--Mike Orr [EMAIL PROTECTED]([EMAIL PROTECTED] address is semi-reliable)


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-06 Thread Kevin Dangoor

On 12/6/05, paron [EMAIL PROTECTED] wrote:
 I think that's RESTful, but that's just me. How about asking at the
 REST Yahoo group? Kind of a second opinion? Some of the heavyweights
 that don't hang around here, hang around there.

I've heard about that group, and I'm afraid we just don't have that
kind of time to wait for a conclusive answer :)

Enough of this thread seems to be in favor of choice #1, so that's
what I'm going to do for starters.

Kevin

--
Kevin Dangoor
Author of the Zesty News RSS newsreader

email: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Ronald Jaramillo


+1

On Dec 5, 2005, at 10:57 PM, bruno modulix wrote:



Kevin Dangoor a écrit :
So, in a generic CRUD feature, what would you want your URLs to  
look like:

1) http://yoursite/articles/10/edit
2) http://yoursite/articles/edit/10
3) http://yoursite/articles/edit?id=10


The first, of course.


the advantage to the first one is that it makes view look like this:
http://yoursite/articles/10


aol /




Ronald Jaramillo
mail: ronald AT checkandshare DOT com
blog: http://www.checkandshare.com/blog





[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Michael Schneider

Kevin,

I am still new to cherrypy.

I was under the impression that you built an object tree, and it
automatically mapped
the URI to the object tree, passing in args to the function

 http://yoursite/articles/edit?id=10

wouldn't this map to

class  Article(.):
  def edit(self, id=None):
   function to edit article

with cherry py dispatching the uri to

article.edit(id=10)




would you go to  partial matches for the other URL (like the CherryPy
docs below),
or is there a trick that directly mapps to a function?

Just trying to learn the options,

Thanks
Mike
-   From CherryPy Tutorial -


Partial matches and the default method

Partial matches can happen when a URL contains components that do not
map to the cpg.root object tree. This can happen for a number of
reasons. For example, it may be an error; the user just typed the wrong
URL. But it also can mean that the URL contains extra arguments.

When a partial match happens, CherryPy calls a default method. The
default method is similar to the index method; however, it is only
called as a last resort method, and it's recommended for two
applications:

* Error handling, to be called when the user types the wrong URL;
* Support for positional arguments.

Support for positional arguments when handling partial URL matches is
one of the new features provided by CherryPy. For example, assume that
you have a blog-like application written in CherryPy that takes the
year, month and day as part of the URL:

http://localhost/blog/2005/01/17

This URL can be handled by the following code:

class Blog:
def default(self, year, month, day):
...
default.exposed = True
...
cpg.root.blog = Blog()

So the URL above will be mapped as a call to:

cpg.root.blog.default('2005', '1', '17')

In this case, there is a partial match up to the blog component. The
rest of the URL can't be found in the published object tree. In this
case, the default() method will be called, and the positional
parameters will receive the remaining path components as arguments. The
values are passed as strings; in the above mentioned example, the
arguments would still need to be converted back into numbers, but the
idea is correctly presented.



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Michele Cella

william wrote:

 Does this is implementable into CP2.1 
 AFAIK, such flexible URL would available in CP2.2.


I think Routes provides the maximum flexibility one could ever need and
it seems that it will be easily integrable with CherryPy 2.2:

http://www.groovie.org/articles/2005/11/21/routes-1-0-released

Ciao
Michele



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Michele Cella

Michele Cella wrote:
 I'm unable to make a choice between 1 and 2, definitely not the third
 option.

Ok, the first seems the best.
If I read the second it seems like I'm going to edit (or show) 10
articles not the article number 10.

So +1 for the first.

Ciao
Michele



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Michael Schneider

Here a nice overview of the REST approach to URI encoding  with some
links

http://en.wikipedia.org/wiki/Representational_State_Transfer



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Jared Kuolt

I prefer the command before anything, e.g.:

http://yoursite/edit/article/10

That's assuming 'articles' isn't a subdirectory.


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Bob Ippolito



On Dec 5, 2005, at 12:58 PM, Ian Bicking wrote:



Kevin Dangoor wrote:
So, in a generic CRUD feature, what would you want your URLs to  
look like:

1) http://yoursite/articles/10/edit
2) http://yoursite/articles/edit/10
3) http://yoursite/articles/edit?id=10


http://yoursite/article-10?action=edit

... because 10 doesn't mean anything and articles isn't a very  
useful container, I prefer non-hierarchical URIs like  
article-10.  You can usefully use that in several contexts, like / 
edit?obj=article-10, or  /editor/article-10, or /article-10/edit


Generally I don't like query arguments... Mostly because they're  
kinda ugly and are too closely related to form posting.  I'd avoid  
them most of the time if it was easy to.


The combined class-identifier scheme looks nice though, in a flat is  
better than nested kind of way.


-bob



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Ian Bicking


Sylvain Hellegouarch wrote:

Indeed, IMO the three are equivalent (in fact 2 and 3 are the same). If we refer
to REST we have:

http://www.ics.uci.edu/~fielding/pubs/dissertation/evaluation.htm#sec_6_2_4

Which clearly indicates that the underlying implementation should be seen
through the URI to access a resource. So in the end if we could support the
three different URLs to access a resource it would be the best.


*That's* certainly not what I would propose.  I'd rather take the 
crappiest of the options (um... let's say 
/edit?class=myapp.Articles?id=10) than multiple ways to access the 
resource with the same meaning.


Reading that particular document, my impression is that he is saying 
that URIs don't matter, that they are opaque strings, and their only 
meaning is what you can do with them.  They don't represent resources, 
only potential actions, and if you read anything more into the strings 
you are overstepping the abstractions of the web.


Some REST principles seem unattainable in this context as well, like the 
fact we are strictly limited to the GET and POST verbs.  This is why I 
think ?action=edit is reasonable, as it is the verb and there's no real 
positional location that implies verb.  It's an inversion of the typical 
URI of edit?id=10, where the path is the verb and the variables are the 
noun.


Of course, a real set of actions would be more like:

view: show a representation
editform: show a form to edit the item
save: save changes to an item
delete: delete an item
createform: show a form to create an item
create: actually create the given item
select: show several items (e.g., /articles/ typically means select all).

Several of these should *absolutely not* be in the URI, specifically 
delete, save, and create.  Now, you could conflate these with 
other actions, e.g., editform and save (edit+GET=editform, 
edit+POST=save), and createform and create, and some arbitrary action 
and delete (maybe select or even view).  But I don't think that's very 
REST, if we're throwing about terms.


But on the other hand, this is a total Bike Shed moment, so whatev'.

--
Ian Bicking  /  [EMAIL PROTECTED]  /  http://blog.ianbicking.org


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Sylvain Hellegouarch

True.

From CherryPy 2.2, all exposed methods will be positional parameters aware by
default except index().

Selon Michele Cella [EMAIL PROTECTED]:


 Michael Schneider wrote:
 
  would you go to  partial matches for the other URL (like the CherryPy
  docs below),
  or is there a trick that directly mapps to a function?
 

 With CherryPy 2.1 you can also use a PositionalParametersAware class.
 I think that probably 0.9 will use positional parameters by default
 since they will be the default in CherryPy 2.2 if I'm right, but we
 should really ask Kevin about this.

 See also ticket 73: http://trac.turbogears.org/turbogears/ticket/73

 Ciao
 Michele







This message was sent using IMP, the Internet Messaging Program.



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Jorge Godoy

Kevin Dangoor [EMAIL PROTECTED] writes:

 So, in a generic CRUD feature, what would you want your URLs to look like:
 
 1) http://yoursite/articles/10/edit
 2) http://yoursite/articles/edit/10
 3) http://yoursite/articles/edit?id=10
 
 the advantage to the first one is that it makes view look like this:
 http://yoursite/articles/10

I like more the second kind.

The advantage is that I can use classes for articles, news, etc. and have
a consistent look throughout the website.  The id is always the last
element.  It looks more natural to me to have the variant thing in the end
(it also makes it easier to navigate through the URL location bar.

I hate more the third kind.  



Anyway, some good articles that might help...

http://www.w3.org/Provider/Style/URI
http://www.adaptivepath.com/publications/essays/archives/58.php
http://www.port80software.com/support/articles/nextgenerationurls


Be seeing you,
-- 
Jorge Godoy  [EMAIL PROTECTED]


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Ian Bicking


Kevin Dangoor wrote:

So, in a generic CRUD feature, what would you want your URLs to look like:

1) http://yoursite/articles/10/edit
2) http://yoursite/articles/edit/10
3) http://yoursite/articles/edit?id=10


http://yoursite/article-10?action=edit

... because 10 doesn't mean anything and articles isn't a very 
useful container, I prefer non-hierarchical URIs like article-10.  You 
can usefully use that in several contexts, like /edit?obj=article-10, or 
 /editor/article-10, or /article-10/edit


I don't think objects like article 10 are very meaningful containers 
for things like an editor, so I find .../edit to be less than meaningful.


But it depends on what you think the pieces mean:

/articles is a class
/articles/10 is an instance
/articles/10/edit is a method

/edit is an function
/articles/10 is an instance
/edit/articles/10 is a generic function applied to that instance

/articles is a module
/articles/edit is a function
/articles/edit/10 is a function invocation

It might be more useful to consider what object creation looks like too 
(cloning/edit-as-new is a useful operation as well).  Pragmatically I 
usually do /articles/edit/10, and /articles/edit/ creates an object. 
Deep down I don't personally care that much about the internal URIs of a 
web application; once the system becomes interactive, all the URIs are 
tightly bound and opaque for most practical purposes.


--
Ian Bicking  /  [EMAIL PROTECTED]  /  http://blog.ianbicking.org


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread bruno modulix


Kevin Dangoor a écrit :

So, in a generic CRUD feature, what would you want your URLs to look like:

1) http://yoursite/articles/10/edit
2) http://yoursite/articles/edit/10
3) http://yoursite/articles/edit?id=10


The first, of course.


the advantage to the first one is that it makes view look like this:
http://yoursite/articles/10


aol /



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Ray Cote


At 3:42 PM -0500 12/5/05, Kevin Dangoor wrote:

So, in a generic CRUD feature, what would you want your URLs to look like:

1) http://yoursite/articles/10/edit
2) http://yoursite/articles/edit/10
3) http://yoursite/articles/edit?id=10

the advantage to the first one is that it makes view look like this:
http://yoursite/articles/10

Kevin


Forgot one. ::
4) http://yoursite/articles/10?op=edit
For me, it is selecting an item (articles/10) and then performing an 
operation on it.

Also has advantage of having the view be like your #1 which I like.
--Ray


--

Raymond Cote
Appropriate Solutions, Inc.
PO Box 458 ~ Peterborough, NH 03458-0458
Phone: 603.924.6079 ~ Fax: 603.924.8668
rgacote(at)AppropriateSolutions.com
www.AppropriateSolutions.com


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Michele Cella

Well, I've found another opinion (and some comments) regarding 1) vs 2)
from the Rails side:

http://tech.rufy.com/entry/91

(notice the above url :D)

Ciao
Michele



[TurboGears] link titles (was: Re: [TurboGears] Re: a triviality: how do you like your URLs?)

2005-12-05 Thread Ian Bicking


Bob Ippolito wrote:
I'd personally tend towards something simpler, and enforce unique  
titles... either automatically by adding predicable garbage to the  end, 
or by validating edits/creates to make sure they have a unique  title.


It would be quite reasonable in the SQLObject trunk to create a column 
that worked like:


class Article(SQLObject):
title = StringCol()
linkTitle = LinkTitle('title')

a = Article(title='foo bar')
a.linkTitle == 'foo-bar'
Article.byLinkTitle('foo-bar') == a

Basically you'd just be listening for create events, and generate the 
actual link title at that time, making the title safe and then appending 
stuff to make it unique (if necessary).  I think this would be quite 
useful for web apps.  This example of a column tracking last-modified is 
similar in mechanism: 
http://xentac.net/~jchu/blog/technology/sqlobject-event-fu


--
Ian Bicking  /  [EMAIL PROTECTED]  /  http://blog.ianbicking.org


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Joost Moesker

I would vote #1

For an ecommerce project i'm currently using the following URL scheme:

catagoryname/subcatagoryname
catagoryname/subcatagoryname/edit
catagoryname/subcatagoryname/.../productname
catagoryname/subcatagoryname/.../productname/edit

Editing the product and catagory 'pages' directly feels verry natural.



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Mike Orr

On 12/5/05, Kevin Dangoor [EMAIL PROTECTED] wrote:

 So, in a generic CRUD feature, what would you want your URLs to look like:

 1) http://yoursite/articles/10/edit

This is the most natural.  articles contains all articles.  10 is
an article. edit is an operation on 10.  view is the index method
(/articles/10/).

 2) http://yoursite/articles/edit/10

Acceptable, but I don't like the 10 jumping levels.  article as a
collection of articles makes sense.  article as a collection of
actions doesn't -- people don't go to the site for actions, they go
for articles.  They also don't want to type  /articles/view/10 into
the location bar; they want a straightforward /articles/10 .  The
actions are just a means to facilitate article management, so they go
to the right.  An OO application has objects with methods, not methods
with objects.

/articles/10?action=edit

Acceptable, but an action should arguably be part of the URL path. 
And it would mean one huge controller method that switched on actions,
which contradicts the CherryPy structural philosophy of one small
controller method per action.  That's one of the main things that
draws people to TG (and Quixote, which does the same thing).

/article-10/edit

Ugh, this goes back to the dark ages of parsing data out of strings. 
The thing between the / is supposed to be an identifier, not an
identifier embedded into an arbitrary string.  Numeric identifiers
have many advantages such as sorting.  Will article-100 show up after
article-99 or between article-10 and article-11?  I understand the
point about treating the article ID as an arbitrary string, but then
why incorporate a number at all?Still, numbers make more sense for
a generic CRUD application because we don't know what all the user
plans to do with the data, and numbers make it easier for them build
any kind of local add-on.

 3) http://yoursite/articles/edit?id=10

This is frustrating when you're analyzing logs or implementing a
caching system, and some third-party software has dropped the query
string.  Anything that's essential to identifying the resource belongs
in the URL path.

--
Mike Orr [EMAIL PROTECTED]
([EMAIL PROTECTED] address is semi-reliable)


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread [EMAIL PROTECTED]

either 1 or 2



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Michael Schneider

Sorry for the stupid question, but what would the Controller code look
like for option #1? for CRUD

1) http://yoursite/articles/10/edit
2) http://yoursite/articles/edit/10
3) http://yoursite/articles/edit?id=10


1) http://yoursite/articles/10/edit
2) http://yoursite/articles/10/delete
3) http://yoursite/articles/10/create

The main reason that I am liking 2, then 3 is that I can see how
cherrypy easily maps the urls to functions edit, delete and create.


I am having a mind blank here, how would you code #1 without using
if clauses and one function?

Sorry for my confusion,
Mike



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Swaroop C H
On 12/6/05, Jeff Watkins [EMAIL PROTECTED] wrote:
I'm certain some will suggest this is unpythonic

Why?
-- Swaroop C Hwww.swaroopch.info


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Levi

+1 on 1) http://yoursite/articles/10/edit



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Swaroop C H
+1

On 12/6/05, Jonathan LaCour [EMAIL PROTECTED] wrote:
 So, in a generic CRUD feature, what would you want your URLs to look like: 1) http://yoursite/articles/10/edit+1 for #1.It is far and away the best option.It just seems to
match the way I think of HTTP as messages being sent to objects.Awhile back, I read an article[1] about HTTP by Dan Connolly, who said: HTTP was design as a distributed realization of the Objective C
 (originally Smalltalk) message passing infrastructure: the first few bytes of every HTTP message are a method name: GET or POST. Uniform Resource Locator is just the result of squeezing the term object reference through the IETF standardization process.
I may be making a stretch asserting that this article shouldinfluence the decision for #1, but I think it makes sense.You aresending an edit message to an article that is uniquely identified bythe number 10.To me,
 http://yoursite/articles/10/editis a left-to-right logical expansion of the lookup, followed by themessage send: [[Article fromID: 10] edit];
Just my two cents.[1] http://www.w3.org/People/Connolly/9703-web-apps-essay.html--Jonathan LaCour
http://cleverdevil.org-- Swaroop C Hwww.swaroopch.info


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread anders pearson
Jeff Watkins [EMAIL PROTECTED] writes:

 I'm certain some will suggest this is unpythonic, but here goes:

 class CrudController(turbogears.Controller):
  [... snip a bunch of code ...]

actually, this is pretty similar to what i've been using for building
REST apps (in plain cherrypy; no turbogears yet):

   http://tasty.python-hosting.com/file/trunk/tasty/controller/rest_resource.py

it's a bit idiosyncratic to what i've been building lately and i'm sure
it could be made prettier, but it's been working nicely for me. 

-- 
anders pearson : http://www.columbia.edu/~anders/
   C C N M T L : http://www.ccnmtl.columbia.edu/
weblog : http://thraxil.org/


pgptMy8ZxUyMZ.pgp
Description: PGP signature


[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Andy-Kim Möller
For me the natural one is the 3 one. Could be that it is because i was programming 

over 8 years php, but for the first 2 possibillities how would you build a form like this:



form action="" href="http://yoursite/articles/edit" target="_blank" >http://yoursite/articles/edit method=GET

input type=text name=id value=

input type=submit name=edit

/form



Also for the first two it is not really clear how the application is styled. As example:

articles/10/edit could be:

object.object.object.index or 

objext.object.method or 

object.method.parameter or 

method.parameter.parameter or
index.parameter.parameter.parameter



Kim2005/12/6, Andy-Kim Möller [EMAIL PROTECTED]:
For me the natural one is the 3 one. Could be that it is because i was programming 
over 8 years php, but for the first 2 possibillities how would you build a form like this:

form action="" href="http://yoursite/articles/edit" target="_blank" >http://yoursite/articles/edit method=GET
input type=text name=id value=
input type=submit name=edit
/form

Also for the first two it is not really clear how the application is styled. As example:
articles/10/edit could be:
object.object.object.index or 
objext.object.method or 
object.method.parameter or 
method.parameter.parameter

Kim
2005/12/5, Kevin Dangoor [EMAIL PROTECTED]:

So, in a generic CRUD feature, what would you want your URLs to look like:1) http://yoursite/articles/10/edit
2) http://yoursite/articles/edit/10
3) http://yoursite/articles/edit?id=10the advantage to the first one is that it makes view look like this:
http://yoursite/articles/10
Kevin--Kevin DangoorAuthor of the Zesty News RSS newsreaderemail: [EMAIL PROTECTED]
company: http://www.BlazingThings.com
blog: http://www.BlueSkyOnMars.com




[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Matt Dimmic

Ian's right, this is a Bike Shed moment. But since I care what color
the bike shed is, +1 for #1. It feels the most pythonic to me:

x = Article(id=10)
x.edit(...)

But my chief hope is that TurboGears' BDFL makes some decision before
we get into an argument about what pythonic means. :)



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Claudio Torcato

+1 for #1. for you logic.



[TurboGears] Re: a triviality: how do you like your URLs?

2005-12-05 Thread Mike Orr

What's a Bike Shed?

--
Mike Orr [EMAIL PROTECTED]
([EMAIL PROTECTED] address is semi-reliable)