Re: response status when form validation fails
On Tue, Aug 19, 2008 at 1:17 PM, Jonathan Vanasco [EMAIL PROTECTED] wrote: i'm not sure if i like the idea of this. the 400 error is for bad/malformed syntax and the request can't be fulfilled. in this situation, the http level request is most certainly understood and authorized -- the error is in the application logic and should be served on such -- not pushed into the http level. a non-browser, or browser, app can just expect a json packet as such: status: error / success success: more info error: detailed info or hash of info additional_fields and have all the information needed to intereact with pylons. i don't see how saying that a 'good request' is a bad request will make things easier. Returning 400 for form validation error is recommended by Leonard Richardson and Sam Ruby in the book RESTful Web Services. Here's an excerpt from one of the examples in the book: If the client sends bad or incomplete data, the ActiveRecord validation rules (defined in the User) model) fail, and the call to User#save returns false. The response code then is 400 (Bad Request). Also, according to the specifications for OpenID and OAuth, both of them return 400 for bad or missing parameters. I don't see any difference between an OAuth service provider implemented using pylons and my custom pylons web app. If the former shall return 400 for bad or missing parameters, why can't the later? By the way, structs has a bug report for the same issue that was resolved as Not A Problem, forcing their users to resort to subclassing. So I guess it's OK if you don't like the idea :) Regards, Yap --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: response status when form validation fails
By the way, structs has a bug report for the same issue that was resolved as Not A Problem, forcing their users to resort to subclassing. Of course, I mean struts instead of structs. Here's the URL: https://issues.apache.org/struts/browse/STR-2119 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: response status when form validation fails
On Tue, Aug 19, 2008 at 8:20 AM, Sok Ann Yap [EMAIL PROTECTED] wrote: Returning 400 for form validation error is recommended by Leonard Richardson and Sam Ruby in the book RESTful Web Services. Here's an excerpt from one of the examples in the book Also if they didn't say it... it's just that 200 OK is plain wrong to signal an error condition. That's what 4xx and 5xx codes are for. -- Lawrence, stacktrace.it - oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: response status when form validation fails
On Tue, Aug 19, 2008 at 1:08 AM, Lawrence Oluyede [EMAIL PROTECTED] wrote: On Tue, Aug 19, 2008 at 8:20 AM, Sok Ann Yap [EMAIL PROTECTED] wrote: Returning 400 for form validation error is recommended by Leonard Richardson and Sam Ruby in the book RESTful Web Services. Here's an excerpt from one of the examples in the book Also if they didn't say it... it's just that 200 OK is plain wrong to signal an error condition. That's what 4xx and 5xx codes are for. Even though I agree in principle, there is no 4xx code to signal an error in the value of the parameters, please remember that http is a transport protocol, and from that perspective it was a successful transfer. I believe that trying to return http status codes for application logic is violating the TCP layer division that has held us in place for so long. Building up on the json example, it should be read as, the request was successful and everything when ok (http:200) now it seems you fail with supplying the correct values (statusCode:xxx) as for the webservices reference, I don't think that applies to web-browsers, they could even interpret the 400 as something totally different. That said if enough people find this useful I'll say add a config option where you can switch it and leave it as 200 for default. -- Lawrence, stacktrace.it - oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: response status when form validation fails
On Tue, Aug 19, 2008 at 11:17 AM, Jorge Vargas [EMAIL PROTECTED] wrote: On Tue, Aug 19, 2008 at 1:08 AM, Lawrence Oluyede [EMAIL PROTECTED] wrote: On Tue, Aug 19, 2008 at 8:20 AM, Sok Ann Yap [EMAIL PROTECTED] wrote: Returning 400 for form validation error is recommended by Leonard Richardson and Sam Ruby in the book RESTful Web Services. Here's an excerpt from one of the examples in the book Also if they didn't say it... it's just that 200 OK is plain wrong to signal an error condition. That's what 4xx and 5xx codes are for. Even though I agree in principle, there is no 4xx code to signal an error in the value of the parameters, please remember that http is a transport protocol, and from that perspective it was a successful transfer. I believe that trying to return http status codes for application logic is violating the TCP layer division that has held us in place for so long. I disagree. TCP is the transport protocol (which resides at the transport level of the stack). HTTP is an application protocol (which resides on top of the stack), and I'm pretty sure that the creators of HTTP intended to use 400 BAD REQUEST also for such cases. As the spec says: The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. Nothing forbids to explain _why_ in the body of the response but if you want to create a seamless web where 200 means ok what you asked worked correctly returning 200 for an error is not the most compatible way to go. Remember also there are automatic clients, non-desktop-web clients, mobile browsers and so on. If you want maximum compatibility I think that returning an error code for an error situation is not also smart to do but should be mandatory. There is really no point in returning a OK status code with something that didn't go as it should. Imagine a situation when I do subsequently PUT of a resource like /book/summer. If the server replied 200 with a wrong content (or wrong content type) how do I know that I'm doing something wrong? Looking at the body searching for the error word is not feasible, that's what status codes are for. Building up on the json example, it should be read as, the request was successful and everything when ok (http:200) now it seems you fail with supplying the correct values (statusCode:xxx) So the request did not suceed because the GOAL was not to test that the server is there and alive but that the next time I access to the resource it will be there. Not that I'll found out in 10 minutes that the request I made 10 minutes ago didn't work altough the server told me it did. That's quite byzarre. as for the webservices reference, I don't think that applies to web-browsers, they could even interpret the 400 as something totally different. Web browser are web clients of web services. There shouldn't definitely be a difference in status codes among which kind of client I could get. There can be a difference in response format (based on Accept or suffixes) but it's insane to return different status codes based on the UserAgent. It reminds of the old day of UA sniffing to render different pages. My suggestion is to read something about HTTP and REST in general. Why bend the rules when these are the basic scenarios where HTTP shines? I can be wrong about the correct status code but returning 200 for an error situations is asking for troubles and asking for more and more work for the people who needs to access that web service in the future: be that a browser, a programming language, a mobile phone or whatever. Some web standards are so good because if you do things correctly they can last and work with clients that are nowhere but in the minds of future developers. -- Lawrence, stacktrace.it - oluyede.org - neropercaso.it It is difficult to get a man to understand something when his salary depends on not understanding it - Upton Sinclair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
nosetests can't find packages?
I'm trying to run nosetests, and I keep getting package not found errors. I tried just making the sample blog app from http://wiki.pylonshq.com/display/pylonscookbook/Making+a+Pylons+Blog and started following the instructions for testing it at http://wiki.pylonshq.com/display/pylonsdocs/Unit+Testing. When I run nosetests --with-pylons=test.ini I get an error that ends with: File /usr/lib/python2.5/site-packages/PasteDeploy-1.3.1-py2.5.egg/ paste/deploy/loadwsgi.py, line 542, in get_context object_type, name=name) File /usr/lib/python2.5/site-packages/PasteDeploy-1.3.1-py2.5.egg/ paste/deploy/loadwsgi.py, line 562, in find_egg_entry_point pkg_resources.require(self.spec) File /usr/lib/python2.5/site-packages/pkg_resources.py, line 626, in require needed = self.resolve(parse_requirements(requirements)) File /usr/lib/python2.5/site-packages/pkg_resources.py, line 524, in resolve raise DistributionNotFound(req) # XXX put more info here pkg_resources.DistributionNotFound: MyBlog This seems like the kind of stupid pilot-error that I should be able to spot, but I'm stumped. Phred --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
how can I ensure that several statements occur on the same connection?
I'm using Pylons with SQLAlchemy Elixir. I need to run three SQL commands in sequence, but I have to be certain that all three are done on the same connection. So something like this in my controller class from sqlalchemy import text model.metadata.bind.execute(text(set enable_seqscan=off)) model.metadata.bind.execute(text(select * from foo where bar = :bar), bar=1) model.metadata.bind.execute(text(set enable_seqscan=on)) Is there a way for me to be sure that all three of these commands would occur on the same connection? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: how can I ensure that several statements occur on the same connection?
My guess is that a transaction should handle that. -r. On Tue, Aug 19, 2008 at 4:47 PM, Chris Curvey [EMAIL PROTECTED] wrote: I'm using Pylons with SQLAlchemy Elixir. I need to run three SQL commands in sequence, but I have to be certain that all three are done on the same connection. So something like this in my controller class from sqlalchemy import text model.metadata.bind.execute(text(set enable_seqscan=off)) model.metadata.bind.execute(text(select * from foo where bar = :bar), bar=1) model.metadata.bind.execute(text(set enable_seqscan=on)) Is there a way for me to be sure that all three of these commands would occur on the same connection? -- http://twitter.com/rpf http://rickflosi.blogspot.com/ The issue is always the same: the government or the market. There is no third solution. - Ludwig von Mises, Planned Chaos Capitalism tends toward a productive orientation when the capitalist entrepreneurs can neither use coercion for the purpose of parasitic exploitation, nor are so devoid of strength as to be exposed to exploitation themselves -- in other words, when businessmen are too weak to prey upon the other classes, but too strong to be preyed upon. Such a situation -- which in my previous books I proposed to call equidependency -- requires a certain degree of balance of power between the business elite and the political elite. An important application of the principle of equidependency is that capitalism can function beneficently only in a society where money cannot buy everything, because if it can, then the power of wealth can have no counterweight and a parasitic involution ensues. - Stanislav Andreski --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: how can I ensure that several statements occur on the same connection?
W liście Chris Curvey z dnia wtorek 19 sierpnia 2008: I'm using Pylons with SQLAlchemy Elixir. I need to run three SQL commands in sequence, but I have to be certain that all three are done on the same connection. So something like this in my controller class from sqlalchemy import text model.metadata.bind.execute(text(set enable_seqscan=off)) model.metadata.bind.execute(text(select * from foo where bar = :bar), bar=1) model.metadata.bind.execute(text(set enable_seqscan=on)) If your bind object is an engine, then you can fetch a connection out of it: conn = model.metadata.bind.connect() conn.execute(first query) conn.execute(second query) ... conn.close() # returns the connection to the pool See here: http://www.sqlalchemy.org/docs/05/dbengine.html#dbengine_connections Note this is for 0.5, you might want to read 0.4 docs instead. -- Paweł Stradomski --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Anyone using Ingrid (jquery based grid) with Pylons?
I am using the Python DBI (postgres) directly and I would like to use a nice grid, but I am not sure which one I should use or how to get it working. Suggestions welcome :-) Thanks, Snorkel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: nosetests can't find packages?
On Aug 19, 2008, at 12:24 PM, Phredward wrote: I'm trying to run nosetests, and I keep getting package not found errors. I tried just making the sample blog app from http://wiki.pylonshq.com/display/pylonscookbook/Making+a+Pylons+Blog and started following the instructions for testing it at http://wiki.pylonshq.com/display/pylonsdocs/Unit+Testing. When I run nosetests --with-pylons=test.ini I get an error that ends with: File /usr/lib/python2.5/site-packages/pkg_resources.py, line 524, in resolve raise DistributionNotFound(req) # XXX put more info here pkg_resources.DistributionNotFound: MyBlog Is your project's egg-info directory still intact? If not, try running 'python setup.py egg_info' before nosetests. If that's the solution, we may need to make the with-pylons nose plugin run egg_info every time, or maybe only if it notices a DistributionNotFound exception. -- Philip Jenvey --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com 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 -~--~~~~--~~--~--~---