Re: Pylons as a WSGI application under Apache
On Jan 4, 7:02 am, artyom.shalkhakov [EMAIL PROTECTED] wrote: Hello, I've tried to run Pylons as a WSGI application using apache2.2 and mod_wsgi2.0. So far simple 'hello world' applications work fine (Pylons through paste serve works okay, too). When I try to run Pylons under mod_wsgi, I get the following error: [Fri Jan 04 12:36:00 2008] [error] [client 127.0.0.1] DistributionNotFound: mysite.com The app.wsgi looks like this: from paste.deploy import loadapp # yes, everything is under my home directory application = loadapp('config:development.ini', relative_to='home/ artyom/public_html/mysite.com/') What can be wrong here? Note that this works as expected: def application(environ, start_response): status = '200 OK' output = 'Hello World!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output] Regards, Artyom Shalkhakov Try to append ''home/artyom/public_html to sys.path One of mine app.wsgi's: http://paste.ufsoft.org/5 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Handling unique constraints
I've just posted this same question on the sqlalchemy group... I don't know where it belongs: I'm using SQLAlchemy with Pylons and am having trouble validating data. I have an App object mapped to a table with a unique constraint on App.number. Here's some code: q = Session.query(App) if app_id: q = q.filter_by(id=app_id).first() if q: c.app = q number = request.params.get('number') notes = request.params.get('notes') if appmodel and number: try: q.number = number q.notes = notes Session.save(q) Session.commit() c.message = 'Record updated' except: # restore pre-form data ?? how?? c.message = 'Error updating record' return render('index.mtl') else: return self.index() My questions are: 1) When I do the try statement, the value of q.number changes to whatever the user passed in via the form -- even if it's invalid, so that when I render the page, the invalid value is used. How do I reset the object to have the values it had before I did the try? Do I have to get it afresh from the db? 2) How do I let the user know which value caused the record not to update? What information does SQLAlchemy provide back that I can use to say: You're number must be unique... and such-and-such must be greater than 0, etc..? Thanks, Matt Haggard --~--~-~--~~~---~--~~ 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: New wiki spaces
On Jan 4, 2008 2:46 AM, zunzun [EMAIL PROTECTED] wrote: If this is the curve and surface fitting tutorial, I couldn't get it into the CookBook initially. How can I move it? Maybe Ben can move it. Otherwise the only way I know is to create a new page and copy the title and content of the old page into it. Can you edit in the Cookbook now? -- Mike Orr [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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: Pylons as a WSGI application under Apache
Graham Dumpleton wrote: On Jan 4, 6:02 pm, artyom.shalkhakov [EMAIL PROTECTED] wrote: Hello, I've tried to run Pylons as a WSGI application using apache2.2 and mod_wsgi2.0. So far simple 'hello world' applications work fine (Pylons through paste serve works okay, too). When I try to run Pylons under mod_wsgi, I get the following error: [Fri Jan 04 12:36:00 2008] [error] [client 127.0.0.1] DistributionNotFound: mysite.com The app.wsgi looks like this: from paste.deploy import loadapp # yes, everything is under my home directory application = loadapp('config:development.ini', relative_to='home/ artyom/public_html/mysite.com/') What can be wrong here? Run your application once using 'paster serve' before trying to run it under mod_wsgi. I haven't looked into what 'paster serve' does yet, but it seems to do some once off initialisation to set up the site directories properly. There is possibly some other command which will do the same thing rather than you actually have to run up the server itself. I was going to investigate and document this, but got side tracked. :-) It doesn't do much. The logging stuff has some customizations (in paste.script.util.logging_config), but I must admit I don't know quite what they are about; Philip Jenvy did those. This sounds like something to do with the actual application loading (any logging stuff isn't being loaded at all). paster serve really doesn't do much there. It adds 'config:' to the start of the config file if you don't give it, and can take an explicit app name/section argument (instead of #section) and passes that as the 'name' keyword to loadapp. But that's it. It might be hard to see in all the daemonization, reloading, etc stuff in paster serve, but the actual loading and serving of apps is just a very small bit of code. Out of curiosity, I grabbed the original version of the command (just the implementation) before it grew so large: def command(self): app_spec = self.args[0] app_name = self.options.app_name if not self._scheme_re.search(app_spec): app_spec = 'config:' + app_spec server_name = self.options.server_name if self.options.server: server_spec = 'egg:PasteScript' assert server_name is None server_name = self.options.server else: server_spec = app_spec base = os.getcwd() server = loadserver(server_spec, name=server_name, relative_to=base) app = loadapp(app_spec, name=app_name, relative_to=base) server(app) -- Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org --~--~-~--~~~---~--~~ 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: Pylons as a WSGI application under Apache
On Jan 4, 6:02 pm, artyom.shalkhakov [EMAIL PROTECTED] wrote: Hello, I've tried to run Pylons as a WSGI application using apache2.2 and mod_wsgi2.0. So far simple 'hello world' applications work fine (Pylons through paste serve works okay, too). When I try to run Pylons under mod_wsgi, I get the following error: [Fri Jan 04 12:36:00 2008] [error] [client 127.0.0.1] DistributionNotFound: mysite.com The app.wsgi looks like this: from paste.deploy import loadapp # yes, everything is under my home directory application = loadapp('config:development.ini', relative_to='home/ artyom/public_html/mysite.com/') What can be wrong here? Run your application once using 'paster serve' before trying to run it under mod_wsgi. I haven't looked into what 'paster serve' does yet, but it seems to do some once off initialisation to set up the site directories properly. There is possibly some other command which will do the same thing rather than you actually have to run up the server itself. I was going to investigate and document this, but got side tracked. :-) Graham --~--~-~--~~~---~--~~ 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: Pylons as a WSGI application under Apache
On Jan 5, 11:46 am, Ian Bicking [EMAIL PROTECTED] wrote: Graham Dumpleton wrote: On Jan 4, 6:02 pm, artyom.shalkhakov [EMAIL PROTECTED] wrote: Hello, I've tried to run Pylons as a WSGI application using apache2.2 and mod_wsgi2.0. So far simple 'hello world' applications work fine (Pylons through paste serve works okay, too). When I try to run Pylons under mod_wsgi, I get the following error: [Fri Jan 04 12:36:00 2008] [error] [client 127.0.0.1] DistributionNotFound: mysite.com The app.wsgi looks like this: from paste.deploy import loadapp # yes, everything is under my home directory application = loadapp('config:development.ini', relative_to='home/ artyom/public_html/mysite.com/') What can be wrong here? Run your application once using 'paster serve' before trying to run it under mod_wsgi. I haven't looked into what 'paster serve' does yet, but it seems to do some once off initialisation to set up the site directories properly. There is possibly some other command which will do the same thing rather than you actually have to run up the server itself. I was going to investigate and document this, but got side tracked. :-) It doesn't do much. The logging stuff has some customizations (in paste.script.util.logging_config), but I must admit I don't know quite what they are about; Philip Jenvy did those. This sounds like something to do with the actual application loading (any logging stuff isn't being loaded at all). paster serve really doesn't do much there. It adds 'config:' to the start of the config file if you don't give it, and can take an explicit app name/section argument (instead of #section) and passes that as the 'name' keyword to loadapp. But that's it. It might be hard to see in all the daemonization, reloading, etc stuff in paster serve, but the actual loading and serving of apps is just a very small bit of code. Out of curiosity, I grabbed the original version of the command (just the implementation) before it grew so large: def command(self): app_spec = self.args[0] app_name = self.options.app_name if not self._scheme_re.search(app_spec): app_spec = 'config:' + app_spec server_name = self.options.server_name if self.options.server: server_spec = 'egg:PasteScript' assert server_name is None server_name = self.options.server else: server_spec = app_spec base = os.getcwd() server = loadserver(server_spec, name=server_name, relative_to=base) app = loadapp(app_spec, name=app_name, relative_to=base) server(app) Hmmm, odd. I tried a fresh new site and didn't have the same problem as OP this time, not needing to run paster serve first to make it work. The only difference was that this was the second site created from the virtualenv setup I was using. Certainly something odd going on as I know I saw the problem for first site created against this virtualenv setup. I'll definitely have to dig into it later when I get a chance. Graham --~--~-~--~~~---~--~~ 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: Pylons as a WSGI application under Apache
On Jan 5, 12:55 pm, Graham Dumpleton [EMAIL PROTECTED] wrote: On Jan 5, 11:46 am, Ian Bicking [EMAIL PROTECTED] wrote: Graham Dumpleton wrote: On Jan 4, 6:02 pm, artyom.shalkhakov [EMAIL PROTECTED] wrote: Hello, I've tried to run Pylons as a WSGI application using apache2.2 and mod_wsgi2.0. So far simple 'hello world' applications work fine (Pylons through paste serve works okay, too). When I try to run Pylons under mod_wsgi, I get the following error: [Fri Jan 04 12:36:00 2008] [error] [client 127.0.0.1] DistributionNotFound: mysite.com The app.wsgi looks like this: from paste.deploy import loadapp # yes, everything is under my home directory application = loadapp('config:development.ini', relative_to='home/ artyom/public_html/mysite.com/') What can be wrong here? Run your application once using 'paster serve' before trying to run it under mod_wsgi. I haven't looked into what 'paster serve' does yet, but it seems to do some once off initialisation to set up the site directories properly. There is possibly some other command which will do the same thing rather than you actually have to run up the server itself. I was going to investigate and document this, but got side tracked. :-) It doesn't do much. The logging stuff has some customizations (in paste.script.util.logging_config), but I must admit I don't know quite what they are about; Philip Jenvy did those. This sounds like something to do with the actual application loading (any logging stuff isn't being loaded at all). paster serve really doesn't do much there. It adds 'config:' to the start of the config file if you don't give it, and can take an explicit app name/section argument (instead of #section) and passes that as the 'name' keyword to loadapp. But that's it. It might be hard to see in all the daemonization, reloading, etc stuff in paster serve, but the actual loading and serving of apps is just a very small bit of code. Out of curiosity, I grabbed the original version of the command (just the implementation) before it grew so large: def command(self): app_spec = self.args[0] app_name = self.options.app_name if not self._scheme_re.search(app_spec): app_spec = 'config:' + app_spec server_name = self.options.server_name if self.options.server: server_spec = 'egg:PasteScript' assert server_name is None server_name = self.options.server else: server_spec = app_spec base = os.getcwd() server = loadserver(server_spec, name=server_name, relative_to=base) app = loadapp(app_spec, name=app_name, relative_to=base) server(app) Hmmm, odd. I tried a fresh new site and didn't have the same problem as OP this time, not needing to run paster serve first to make it work. The only difference was that this was the second site created from the virtualenv setup I was using. Certainly something odd going on as I know I saw the problem for first site created against this virtualenv setup. I'll definitely have to dig into it later when I get a chance. The problem I saw may actually have been something totally different as I note the OP uses: application = loadapp('config:development.ini', relative_to='home/ artyom/public_html/mysite.com/') whereas I don't use relative_to and instead use just the 'config:' string with a full path. What does the relative_to option do? Maybe the sys.path suggested by someone else was all that was wrong. Need to know for sure if that was the OPs complete WSGI application script file. The instructions at: http://code.google.com/p/modwsgi/wiki/IntegrationWithPylons show the need for the sys.path setup, but was that actually done, or does this relative_to option somehow cause a problem? Graham --~--~-~--~~~---~--~~ 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: Pylons as a WSGI application under Apache
Graham Dumpleton wrote: On Jan 5, 12:55 pm, Graham Dumpleton [EMAIL PROTECTED] wrote: On Jan 5, 11:46 am, Ian Bicking [EMAIL PROTECTED] wrote: Graham Dumpleton wrote: On Jan 4, 6:02 pm, artyom.shalkhakov [EMAIL PROTECTED] wrote: Hello, I've tried to run Pylons as a WSGI application using apache2.2 and mod_wsgi2.0. So far simple 'hello world' applications work fine (Pylons through paste serve works okay, too). When I try to run Pylons under mod_wsgi, I get the following error: [Fri Jan 04 12:36:00 2008] [error] [client 127.0.0.1] DistributionNotFound: mysite.com The app.wsgi looks like this: from paste.deploy import loadapp # yes, everything is under my home directory application = loadapp('config:development.ini', relative_to='home/ artyom/public_html/mysite.com/') What can be wrong here? Run your application once using 'paster serve' before trying to run it under mod_wsgi. I haven't looked into what 'paster serve' does yet, but it seems to do some once off initialisation to set up the site directories properly. There is possibly some other command which will do the same thing rather than you actually have to run up the server itself. I was going to investigate and document this, but got side tracked. :-) It doesn't do much. The logging stuff has some customizations (in paste.script.util.logging_config), but I must admit I don't know quite what they are about; Philip Jenvy did those. This sounds like something to do with the actual application loading (any logging stuff isn't being loaded at all). paster serve really doesn't do much there. It adds 'config:' to the start of the config file if you don't give it, and can take an explicit app name/section argument (instead of #section) and passes that as the 'name' keyword to loadapp. But that's it. It might be hard to see in all the daemonization, reloading, etc stuff in paster serve, but the actual loading and serving of apps is just a very small bit of code. Out of curiosity, I grabbed the original version of the command (just the implementation) before it grew so large: def command(self): app_spec = self.args[0] app_name = self.options.app_name if not self._scheme_re.search(app_spec): app_spec = 'config:' + app_spec server_name = self.options.server_name if self.options.server: server_spec = 'egg:PasteScript' assert server_name is None server_name = self.options.server else: server_spec = app_spec base = os.getcwd() server = loadserver(server_spec, name=server_name, relative_to=base) app = loadapp(app_spec, name=app_name, relative_to=base) server(app) Hmmm, odd. I tried a fresh new site and didn't have the same problem as OP this time, not needing to run paster serve first to make it work. The only difference was that this was the second site created from the virtualenv setup I was using. Certainly something odd going on as I know I saw the problem for first site created against this virtualenv setup. I'll definitely have to dig into it later when I get a chance. The problem I saw may actually have been something totally different as I note the OP uses: application = loadapp('config:development.ini', relative_to='home/ artyom/public_html/mysite.com/') whereas I don't use relative_to and instead use just the 'config:' string with a full path. What does the relative_to option do? Nothing much, just uses that to interpret relative paths in config: URIs. It's really just to avoid ever implicitly using cwd as the relative path for filenames (to use cwd you must explicitly pass it as relative_to, which is what paster does). Perhaps the problem had to do with cwd. Probably when running paster serve the cwd is the location of the app, with a Something.egg-info directory. Then even though the application is not installed, since '.' (aka '') is on the path it'll still load. But the cwd is going to be different in mod_wsgi. It's *possible* that somehow running paster serve gets the application properly installed. But it shouldn't, and I can't really think how that would happen. -- Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---