Re: Newbie question about ERRest
Le 2011-09-02 à 08:49, Philippe Rabier a écrit : Hi all, We are starting using ERRest in our team and I have a first question: The default way to get an object (in our case a Project) is : GET /ra/Project/id But suppose we have our own globalUID that is not the primary key or if we want to use something else (for example login for a user as we suppose the login is unique), how can we achieve that? You need to add routes in the request handler, something like this: routeRequestHandler.addRoute(new ERXRoute(Project.ENTITY_NAME, /Project/{uid:String}, ERXRoute.Method.GET, ProjectController.class)); And in your controller: String uid = routeObjectForKey(uid); Project aProject = Project.fetchProject(editingContext, Project.UID.eq(uid)); We look at the ERRestExample source and we saw in the PersonController class, method Person(): person= routeObjectForKey(Person); So the fetch must be handled by routeObjectForKey, I guess… and we have to change something around. Other philosophical question about Rest: does it make sense to get a person with their login? I'm more confident with the globalUID if we don't want to expose the primary key. What do you mean with their login? By passing the username and password to a route? ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Newbie question about ERRest
Thanks Pascal but we are still a little bit confused. I answer the last Q first which is simple: it was not the idea to pass the username and password as in your WOWODC slide. I thought about the login value like www.wocommunity.org/ra/user/probert if probert is your login. But not sure it's a good option to do that. Regarding the uid, so I should write (based on the ERRestExample) something like that: Project project() { String uid = routeObjectForKey(uid); Project aProject = Project.fetchProject(editingContext, Project.UID.eq(uid)); return aProject; } Is that right? So by convention and I should say, the default implementation, everything has been designed to get object based on their primary key, isn't it? Philippe On 2 sept. 2011, at 14:59, Pascal Robert wrote: Le 2011-09-02 à 08:49, Philippe Rabier a écrit : Hi all, We are starting using ERRest in our team and I have a first question: The default way to get an object (in our case a Project) is : GET /ra/Project/id But suppose we have our own globalUID that is not the primary key or if we want to use something else (for example login for a user as we suppose the login is unique), how can we achieve that? You need to add routes in the request handler, something like this: routeRequestHandler.addRoute(new ERXRoute(Project.ENTITY_NAME, /Project/{uid:String}, ERXRoute.Method.GET, ProjectController.class)); And in your controller: String uid = routeObjectForKey(uid); Project aProject = Project.fetchProject(editingContext, Project.UID.eq(uid)); We look at the ERRestExample source and we saw in the PersonController class, method Person(): person= routeObjectForKey(Person); So the fetch must be handled by routeObjectForKey, I guess… and we have to change something around. Other philosophical question about Rest: does it make sense to get a person with their login? I'm more confident with the globalUID if we don't want to expose the primary key. What do you mean with their login? By passing the username and password to a route? ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Newbie question about ERRest
Le 2011-09-02 à 09:28, Philippe Rabier a écrit : Thanks Pascal but we are still a little bit confused. I answer the last Q first which is simple: it was not the idea to pass the username and password as in your WOWODC slide. I thought about the login value like www.wocommunity.org/ra/user/probert if probert is your login. But not sure it's a good option to do that. Everything is an option :-) It mainly depends what you have at the client side, eg if you don't know the primary key of a User, well it would be hard to fetch that based on the primary key :-) Regarding the uid, so I should write (based on the ERRestExample) something like that: Project project() { String uid = routeObjectForKey(uid); Project aProject = Project.fetchProject(editingContext, Project.UID.eq(uid)); return aProject; } Is that right? That's right, and you call project() in showAction(). So by convention and I should say, the default implementation, everything has been designed to get object based on their primary key, isn't it? Exact. Philippe On 2 sept. 2011, at 14:59, Pascal Robert wrote: Le 2011-09-02 à 08:49, Philippe Rabier a écrit : Hi all, We are starting using ERRest in our team and I have a first question: The default way to get an object (in our case a Project) is : GET /ra/Project/id But suppose we have our own globalUID that is not the primary key or if we want to use something else (for example login for a user as we suppose the login is unique), how can we achieve that? You need to add routes in the request handler, something like this: routeRequestHandler.addRoute(new ERXRoute(Project.ENTITY_NAME, /Project/{uid:String}, ERXRoute.Method.GET, ProjectController.class)); And in your controller: String uid = routeObjectForKey(uid); Project aProject = Project.fetchProject(editingContext, Project.UID.eq(uid)); We look at the ERRestExample source and we saw in the PersonController class, method Person(): person= routeObjectForKey(Person); So the fetch must be handled by routeObjectForKey, I guess… and we have to change something around. Other philosophical question about Rest: does it make sense to get a person with their login? I'm more confident with the globalUID if we don't want to expose the primary key. What do you mean with their login? By passing the username and password to a route? ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Newbie question about ERRest
So by convention and I should say, the default implementation, everything has been designed to get object based on their primary key, isn't it? yes, the default impl is PK ... you can write a custom IERXRestDelegate implementation that uses something other than PK, though, but it means you will be using that everywhere this entity is used. ms ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Newbie question about ERRest
Thanks Mike. I deduced that when I read the source code of your example. Philippe Sent from my iPhone On 2 sept. 2011, at 16:55, Mike Schrag msch...@pobox.com wrote: So by convention and I should say, the default implementation, everything has been designed to get object based on their primary key, isn't it? yes, the default impl is PK ... you can write a custom IERXRestDelegate implementation that uses something other than PK, though, but it means you will be using that everywhere this entity is used. ms ___ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com