Re: Pylons Model approach vs simple sql?
Is there a reason I couldn't just create a simple model that uses a db connection string from the developer.ini conf file and then just make direct queries? We have a pretty big application using PostgreSQL + psycopg2 with no SqlAlchemy whatsoever, so it's definitely possible :-) -- 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: Problems making Routes Subdomains work on Pylons
yep. i mean foo.localhost :) On Jan 22, 3:44 am, Antoine Pitrou [EMAIL PROTECTED] wrote: You should probably add foo.localhost andwww.localhostto your hosts file as well. Le lundi 21 janvier 2008 à 13:34 -0800, Pavel Skvazh a écrit : That's exactly what I've got there. Running Windows by the way. On Jan 21, 4:53 pm, Dmitry Lipovoi [EMAIL PROTECTED] wrote: try to add 127.0.0.1 localhost to /etc/hosts --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
orm is abstraction over database query language. you can make queries in oo-terms. so your business logic stays clear and you dont care about object persistence. also with orm you can change backend (from MySQL to Postgre for ex.) just by edit config. if you work with native sql its not always possible. On Jan 22, 12:56 pm, Kevin Baker [EMAIL PROTECTED] wrote: I am new to Pylons. I love Mako, Routes and the View Controller concepts behind Pylons. I am a little unsure of the Model concepts though, and how tightly they are bound to SQLAlchemy. In general it seems like a lot of configuration to make simple SQL queries. Is there a reason I couldn't just create a simple model that uses a db connection string from the developer.ini conf file and then just make direct queries? I'm sure there is something I'm missing. Thanks tons, - Kevin --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
I am a little unsure of the Model concepts though, and how tightly they are bound to SQLAlchemy. They aren't. Actually, it seems you are not even obliged to use a Model at all. You can just write controllers and handle all the logic inside them if you want (although many people would probably recommend against this :-)). In general it seems like a lot of configuration to make simple SQL queries. Some of that configuration (the table declarations) replaces hand-written CREATE TABLE queries, though, and in a more portable way. Also, SQLAlchemy gives you transparent connection pooling, and other goodies. --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
Sent from my iPhone Please excuse any typos ;) On Jan 22, 2008, at 3:09 AM, Antoine [EMAIL PROTECTED] wrote: I am a little unsure of the Model concepts though, and how tightly they are bound to SQLAlchemy. They aren't. Actually, it seems you are not even obliged to use a Model at all. You can just write controllers and handle all the logic inside them if you want (although many people would probably recommend against this :-)). I should have mentioned I am not at all new to MVC or ORM, use them both in java apps often. I would always use a model unless maybe if there was no db. In general it seems like a lot of configuration to make simple SQL queries. Some of that configuration (the table declarations) replaces hand- written CREATE TABLE queries, though, and in a more portable way. So if I didnt need the portable scheme creation, can I just skip the table def in the model? Also if I don't plan on ORM, I wouldn't need the object map at all correct? Also, SQLAlchemy gives you transparent connection pooling, and other goodies. Can I use direct queries with engine.execute(select * from) and still take advantage of the goodies? I am interested in all pylons and sqlalch have to offer, but am exploring all options, as I'll likely want ORM on case by case basis and would want to skip the extra conf stuff if not needed. Thanks, - kevin --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
So if I didnt need the portable scheme creation, can I just skip the table def in the model? If you only plan to use raw (text) queries, yes. But then you would need to write your CREATE TABLE statements by hand, so I'm not sure it would buy you anything unless you have specific needs. Also if I don't plan on ORM, I wouldn't need the object map at all correct? No you wouldn't :-) Also, SQLAlchemy gives you transparent connection pooling, and other goodies. Can I use direct queries with engine.execute(select * from) and still take advantage of the goodies? Probably, you should read the SQLAlchemy doc (which is a bit thick ;-)) to be sure though. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Having some trouble getting started with Pylons
I have been trying to follow the install instructions here. http://wiki.pylonshq.com/display/pylonsdocs/Home Everything was going okay until I tried this: wb:/var/www/helloworld# paster serve --reload development.ini Starting subprocess with file monitor Starting server in PID 3751. 09:45:52,844 INFO [paste.httpserver.ThreadPool] Cannot use kill_thread_limit as ctypes/killthread is not available serving on 0.0.0.0:5000 view at http://127.0.0.1:5000 I am not doing this on my local system. I am using VPS hosting. I think the problem is with the 127.0.0.1 address. But I am not sure how to fix it. --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
Sent from my iPhone Please excuse any typos ;) On Jan 22, 2008, at 7:38 AM, Antoine [EMAIL PROTECTED] wrote: So if I didnt need the portable scheme creation, can I just skip the table def in the model? If you only plan to use raw (text) queries, yes. But then you would need to write your CREATE TABLE statements by hand, so I'm not sure it would buy you anything unless you have specific needs. Well I'm developing against a db that already exists. So I don't gain anything from the table def unless it was doing something other than create table. Also if I don't plan on ORM, I wouldn't need the object map at all correct? No you wouldn't :-) Also, SQLAlchemy gives you transparent connection pooling, and other goodies. Can I use direct queries with engine.execute(select * from) and still take advantage of the goodies? Probably, you should read the SQLAlchemy doc (which is a bit thick ;-)) to be sure though. --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
Antoine escreveu: Some of that configuration (the table declarations) replaces hand-written CREATE TABLE queries, though, and in a more portable way. It's one of those you have to see it before you believe it situations. I've smacked my forehead recently, for not having tried out the ORM before. A simpler life was waiting for me. -- Luís Bruno --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
On Jan 22, 2:33 am, Dmitry Lipovoi [EMAIL PROTECTED] wrote: orm is abstraction over database query language. you can make queries in oo-terms. so your business logic stays clear and you dont care about object persistence. also with orm you can change backend (from MySQL to Postgre for ex.) just by edit config. if you work with native sql its not always possible. True. But as I understand it, using an ORM means you take a performance hit. I wonder just how much it will affect performance to use SQLAlchemy? --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
Sent from my iPhone Please excuse any typos ;) On Jan 22, 2008, at 9:11 AM, walterbyrd [EMAIL PROTECTED] wrote: On Jan 22, 2:33 am, Dmitry Lipovoi [EMAIL PROTECTED] wrote: orm is abstraction over database query language. you can make queries in oo-terms. so your business logic stays clear and you dont care about object persistence. also with orm you can change backend (from MySQL to Postgre for ex.) just by edit config. if you work with native sql its not always possible. True. But as I understand it, using an ORM means you take a performance hit. I wonder just how much it will affect performance to use SQLAlchemy? Thus is part of why I an interested in this approach, but don't want to loose all if the advantages oh SA. I have no need for switching databases for this project and if I Did I have all SQL and connection string in one conf file so it would be very easy to alter I have no need for SA's object syntax for queries, I have most my SQL aleady defined from a previous version of the project. The same goes for ORM in this case. I do however need a model to seperate my logic out, plus the rest of pylons is perfect for my needs. I guess I am looking for best practices for a pylons model when not using SA. Thanks for all the help - kevin --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Template knowing the path to static files
I've got an app with the following ini: ... [app:main] use = egg:myapp filter-with = app-prefix ... [filter:app-prefix] use = egg:PasteDeploy#prefix prefix=/myapp I've been developing without the filter option, and now that I have it, my hard-coded image paths no longer work. (e.g. they're looking at http://127.0.0.1:5000/images/something.gif when they should be looking at http://127.0.0.1:5000/myapp/images/something.gif ) So, is there some helper (or config option that could let me write my own helper) that I can use in my templates for image urls? I wonder if a helper's the solution, though... because I reference images in my css file... and those image urls should work too. Is there a way to have requests to /images/something.gif go an get the images? Do I need to make a route, then a controller to serve up images? I'm thinking this is a common enough problem that there would be a more apparent solution. Thanks, Matt --~--~-~--~~~---~--~~ 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: Having some trouble getting started with Pylons
I meant to ask, which operating system and virtual server product is your ISP using? How do they provide Python? (I.e.,anything you know about who compiled Python, where it's located, and what kinds of Python add-ons the ISP provide? -- 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 Model approach vs simple sql?
On Jan 22, 2008 5:17 AM, Kevin Baker [EMAIL PROTECTED] wrote: On Jan 22, 2008, at 3:09 AM, Antoine [EMAIL PROTECTED] wrote: I would always use a model unless maybe if there was no db. I would use a model even if there weren't a db. It keeps your business objects from being too closely tied to the Pylons implementation, which makes them easier to use outside Pylons if the need should arise someday. The beauty of SQLAlchemy is you can program on multiple levels simultaneously. Define your schemas or autoload them from existing tables. Use the ORM, the SQL builder methods, and/or raw SQL queries whenever you wish. Like Luis, I was initially against the ORM because it's so magical, but I have seen how convenient and reliable it is, and now use it whenever possible. Also if I don't plan on ORM, I wouldn't need the object map at all correct? Correct. You won't need a session, classes, or mapper() calls. You will need a metadata and Table() calls. Either: Table(tablename, metadata, Column(...), ...) Or: Table(tablename, metadata, autoload=True, autoload_with=engine) If you someday mix ORM and non-ORM use in the same application, you will want to use session.execute() rather than engine.execute() for your non-ORM queries, so that they will be in the same transaction with the ORM queries. -- 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: Template knowing the path to static files
On Jan 22, 2008 11:11 AM, Matt Haggard [EMAIL PROTECTED] wrote: I've got an app with the following ini: ... [app:main] use = egg:myapp filter-with = app-prefix ... [filter:app-prefix] use = egg:PasteDeploy#prefix prefix=/myapp I've been developing without the filter option, and now that I have it, my hard-coded image paths no longer work. (e.g. they're looking at http://127.0.0.1:5000/images/something.gif when they should be looking at http://127.0.0.1:5000/myapp/images/something.gif ) So, is there some helper (or config option that could let me write my own helper) that I can use in my templates for image urls? I wonder if a helper's the solution, though... because I reference images in my css file... and those image urls should work too. Is there a way to have requests to /images/something.gif go an get the images? Do I need to make a route, then a controller to serve up images? I'm thinking this is a common enough problem that there would be a more apparent solution. Ideally you'd use h,url_for for this, and it would automatically adjust the URLs. However, the current version of Routes does not properly handle routes to the public directory (which are neither regular routes nor static named routes). This will be improved in the next version. In the meantime, you may be able to get by with: h.url_for(images/something.gif) but there's a possibility it may choose the wrong route and generate a different URL. Check back here if that doesn't work. Why do you need the prefix? Are you combining this app with other Pylons or Paste applications in the same site? If so, are they sharing the same process or each in their own processes? Or is this the only Python application in the site? Depending on your situation, I think there's a Python confing variable that sets the prefix without you having to use the convoluted app-prefix filter. The only time you absolutely have to use that filter is when combining multiple Paste applications in the same process. -- 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: Template knowing the path to static files
So what about images in CSS files? I can't use helper functions there... I'll try the h.url_for() in the templates and let you know On Jan 22, 1:34 pm, Mike Orr [EMAIL PROTECTED] wrote: On Jan 22, 2008 11:11 AM, Matt Haggard [EMAIL PROTECTED] wrote: I've got an app with the following ini: ... [app:main] use = egg:myapp filter-with = app-prefix ... [filter:app-prefix] use = egg:PasteDeploy#prefix prefix=/myapp I've been developing without the filter option, and now that I have it, my hard-coded image paths no longer work. (e.g. they're looking athttp://127.0.0.1:5000/images/something.gifwhen they should be looking athttp://127.0.0.1:5000/myapp/images/something.gif) So, is there some helper (or config option that could let me write my own helper) that I can use in my templates for image urls? I wonder if a helper's the solution, though... because I reference images in my css file... and those image urls should work too. Is there a way to have requests to /images/something.gif go an get the images? Do I need to make a route, then a controller to serve up images? I'm thinking this is a common enough problem that there would be a more apparent solution. Ideally you'd use h,url_for for this, and it would automatically adjust the URLs. However, the current version of Routes does not properly handle routes to the public directory (which are neither regular routes nor static named routes). This will be improved in the next version. In the meantime, you may be able to get by with: h.url_for(images/something.gif) but there's a possibility it may choose the wrong route and generate a different URL. Check back here if that doesn't work. Why do you need the prefix? Are you combining this app with other Pylons or Paste applications in the same site? If so, are they sharing the same process or each in their own processes? Or is this the only Python application in the site? Depending on your situation, I think there's a Python confing variable that sets the prefix without you having to use the convoluted app-prefix filter. The only time you absolutely have to use that filter is when combining multiple Paste applications in the same process. -- 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: Template knowing the path to static files
Matt Haggard wrote: So what about images in CSS files? I can't use helper functions there... Make them relative to the url the CSS file lives in, eg: .foos { background-image: url(../img/foo-bg.jpeg) } (assuming this css file is at public/css/style.css and the image at public/img/foo-bg.jpeg) Alberto --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
On 22 jan, 10:33, Dmitry Lipovoi [EMAIL PROTECTED] wrote: orm is abstraction over database query language. you can make queries in oo-terms. so your business logic stays clear and you dont care about object persistence. Bullshit. When using a RDBMS, the database schema is actually 90% (or more) of the business logic. Treating a relational database as an object persistance mean is just braindead. FWIW, if what you want is object persistance, then we have a pretty good Python OODBMS (the ZODB), which is quite easy to use with Pylons if you want to. Anyway, SQLAlchemy - while having some ORM features - is not an ORM but an attempt at a better integration of SQL into Python. And as far as I'm concerned, a mostly successful one. I used it - with and without the ORM part - on a couple projects, and it has proven to be really worth the extra configuration hassle and learning time. --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
On 22 jan, 14:17, Kevin Baker [EMAIL PROTECTED] wrote: Sent from my iPhone Please excuse any typos ;) On Jan 22, 2008, at 3:09 AM, Antoine [EMAIL PROTECTED] wrote: I am a little unsure of the Model concepts though, and how tightly they are bound to SQLAlchemy. They aren't. Actually, it seems you are not even obliged to use a Model at all. You can just write controllers and handle all the logic inside them if you want (although many people would probably recommend against this :-)). I should have mentioned I am not at all new to MVC or ORM, use them both in java apps often. I would always use a model unless maybe if there was no db. Even then, you probably want to separate the data (the model part) from the controller - FWIW, this doesn't necessarily require an OO domain layer. In general it seems like a lot of configuration to make simple SQL queries. Some of that configuration (the table declarations) replaces hand- written CREATE TABLE queries, though, and in a more portable way. So if I didnt need the portable scheme creation, can I just skip the table def in the model? SQLAlchemy can buid it's own stuff from the existing schema. Also if I don't plan on ORM, I wouldn't need the object map at all correct? Yeps. You can just use the lower level part of SQLAlchemy. Also, SQLAlchemy gives you transparent connection pooling, and other goodies. Can I use direct queries with engine.execute(select * from) and still take advantage of the goodies? Yeps again, but this is perhaps not the better thing to do. The nice point with SQLAlchemy is that it translates SQL queries into full- blown Python objects - which is most of the time far superior to plain strings. I am interested in all pylons and sqlalch have to offer, but am exploring all options, as I'll likely want ORM on case by case basis and would want to skip the extra conf stuff if not needed. The extra conf stuff is in my experience really worth the price. I strongly advise you to take a day learning the lower level part of SQLAlchemy (that is, everything before the ORM part). --~--~-~--~~~---~--~~ 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: Having some trouble getting started with Pylons
On Jan 22, 12:40 pm, Mike Orr [EMAIL PROTECTED] wrote: I meant to ask, which operating system and virtual server product is your ISP using? How do they provide Python? I'm sorry, I should have mentioned that. The OS is Debian Etch. I installed Python with a standard apt-get. I am using lighttpd - not apache. Up until this, the install was going very smoothly. --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
On Jan 22, 2008 1:34 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On 22 jan, 10:33, Dmitry Lipovoi [EMAIL PROTECTED] wrote: orm is abstraction over database query language. you can make queries in oo-terms. so your business logic stays clear and you dont care about object persistence. Bullshit. When using a RDBMS, the database schema is actually 90% (or more) of the business logic. Treating a relational database as an object persistance mean is just braindead. FWIW, if what you want is object persistance, then we have a pretty good Python OODBMS (the ZODB), which is quite easy to use with Pylons if you want to. Give him a break. :) English is clearly not his first language, so he's probably using oo and persistence in the general sense rather than a narrow Computer Science definition. If you read you don't care about object persistence as you don't have to worry about all the SQL details, he's correct. Persistence in Bruno's sense means pickling a complex data structure to a Binary column. That is not ideal but is appropriate in some circumstances, for instance if you're just storing an unknown structure like a Beaker session, or you have a small hierarchical object that's not worth mapping into related tables. But Bruno is right that some applications would benefit from an OO database like ZODB or Durus rather than SQLAlchemy. I made a (Quixote) application with a highly hierarchical model and complex searching. I used a database-neutral model with backends for Durus, SQLAlchemy/MySQL and SQLAlchemy/SQLite. The Durus version was significantly faster and more reliable than either of the others, used less memory than SQLite, and was the most distribution-friendly (embeddable, no third-party C libraries, and BSD-like license). So Durus won hands down for this particular dataset. -- 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 Model approach vs simple sql?
On Jan 22, 2008, at 12:11 PM, Mike Orr wrote: On Jan 22, 2008 5:17 AM, Kevin Baker [EMAIL PROTECTED] wrote: On Jan 22, 2008, at 3:09 AM, Antoine [EMAIL PROTECTED] wrote: I would always use a model unless maybe if there was no db. I would use a model even if there weren't a db. It keeps your business objects from being too closely tied to the Pylons implementation, which makes them easier to use outside Pylons if the need should arise someday. Agreed completely. The beauty of SQLAlchemy is you can program on multiple levels simultaneously. Define your schemas or autoload them from existing tables. Use the ORM, the SQL builder methods, and/or raw SQL queries whenever you wish. Like Luis, I was initially against the ORM because it's so magical, but I have seen how convenient and reliable it is, and now use it whenever possible. I've used ORM a bunch in Java, Hibernate and custom... all about it. However I want to develop a standard way to build Models that don't need it, so if it makes sense I can use it and if not I don't have to. In this case I already have a number of Flash applications that won't use it as my Flash apps are already setup to handle the db record results serialized to JSON. From scratch apps I am totally on board. Also if I don't plan on ORM, I wouldn't need the object map at all correct? Correct. You won't need a session, classes, or mapper() calls. You will need a metadata and Table() calls. Either: Table(tablename, metadata, Column(...), ...) Or: Table(tablename, metadata, autoload=True, autoload_with=engine) hmmm this sounds interesting autoload, I'm guessing this uses the table metadata to build the definition? would I find a link to that in the SQLAlchemy site? If you someday mix ORM and non-ORM use in the same application, you will want to use session.execute() rather than engine.execute() for your non-ORM queries, so that they will be in the same transaction with the ORM queries. Great advice, I will do that... on my first app I will likely reuse a lot of SQL I already have written. Cut and past for my deadline will be better than having to rewrite in SA query object notation. Thanks Mike... very helpful response, - Kevin -- 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 Model approach vs simple sql?
On Jan 22, 2008, at 1:46 PM, [EMAIL PROTECTED] wrote: On 22 jan, 14:17, Kevin Baker [EMAIL PROTECTED] wrote: Sent from my iPhone Please excuse any typos ;) On Jan 22, 2008, at 3:09 AM, Antoine [EMAIL PROTECTED] wrote: I am a little unsure of the Model concepts though, and how tightly they are bound to SQLAlchemy. They aren't. Actually, it seems you are not even obliged to use a Model at all. You can just write controllers and handle all the logic inside them if you want (although many people would probably recommend against this :-)). I should have mentioned I am not at all new to MVC or ORM, use them both in java apps often. I would always use a model unless maybe if there was no db. Even then, you probably want to separate the data (the model part) from the controller - FWIW, this doesn't necessarily require an OO domain layer. Yup In general it seems like a lot of configuration to make simple SQL queries. Some of that configuration (the table declarations) replaces hand- written CREATE TABLE queries, though, and in a more portable way. So if I didnt need the portable scheme creation, can I just skip the table def in the model? SQLAlchemy can buid it's own stuff from the existing schema. I'm just finding this out.. I'll dig into that... Also if I don't plan on ORM, I wouldn't need the object map at all correct? Yeps. You can just use the lower level part of SQLAlchemy. By lower level, are you referring to the query object notation? Is the main advantage of this abstraction from database specific features in SQL? I guess I see a huge advantage to the syntax if developer doesn't know SQL or if the DB could change... in my case I know SQL well and have an existing Database that will not be changing... not for the lifetime of this application anyway. Also, SQLAlchemy gives you transparent connection pooling, and other goodies. Can I use direct queries with engine.execute(select * from) and still take advantage of the goodies? Yeps again, but this is perhaps not the better thing to do. The nice point with SQLAlchemy is that it translates SQL queries into full- blown Python objects - which is most of the time far superior to plain strings. I am interested in all pylons and sqlalch have to offer, but am exploring all options, as I'll likely want ORM on case by case basis and would want to skip the extra conf stuff if not needed. The extra conf stuff is in my experience really worth the price. I strongly advise you to take a day learning the lower level part of SQLAlchemy (that is, everything before the ORM part). Thanks again for the advice, I will def take another look at the ORM, it certainly looks great, I guess I was a bit resistant to learning yet another programming syntax... but I'll have to learn it sometime being that I love the rest of Pylons. - Kevin --~--~-~--~~~---~--~~ 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 Model approach vs simple sql?
On Jan 22, 2008 4:00 PM, Kevin Baker [EMAIL PROTECTED] wrote: hmmm this sounds interesting autoload, I'm guessing this uses the table metadata to build the definition? would I find a link to that in the SQLAlchemy site? See reflecting tables in the first chapter of the SQLAlchemy manual. The manual is well written and worth spending a day with. Even if you can't grok everything in one sitting, you'll learn an immense set of tools that will help with problems you probably don't realize you have. -- 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: Template knowing the path to static files
On Tue, 2008-01-22 at 11:11 -0800, Matt Haggard wrote: I've been developing without the filter option, and now that I have it, my hard-coded image paths no longer work. (e.g. they're looking at http://127.0.0.1:5000/images/something.gif when they should be looking at http://127.0.0.1:5000/myapp/images/something.gif ) Why not just use a webserver (Nginx, Apache, etc) to serve them? Then you simply setup a handler for that location (/images) and your problem goes away.. You get the added benefit of things getting significantly faster. I strongly suspect (although I haven't tested) that using Pylons to serve static files isn't going to deploy well in the real world (unless you are expecting very little traffic). Regards, Cliff --~--~-~--~~~---~--~~ 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: Having some trouble getting started with Pylons
On Tue, 2008-01-22 at 11:38 -0800, Mike Orr wrote: On Jan 22, 2008 8:53 AM, walterbyrd [EMAIL PROTECTED] wrote: I have been trying to follow the install instructions here. http://wiki.pylonshq.com/display/pylonsdocs/Home Everything was going okay until I tried this: wb:/var/www/helloworld# paster serve --reload development.ini Starting subprocess with file monitor Starting server in PID 3751. 09:45:52,844 INFO [paste.httpserver.ThreadPool] Cannot use kill_thread_limit as ctypes/killthread is not available serving on 0.0.0.0:5000 view at http://127.0.0.1:5000 I am not doing this on my local system. I am using VPS hosting. I think the problem is with the 127.0.0.1 address. But I am not sure how to fix it. The message means your platform doesn't have a certain threading feature, or possibly that a C file was misconfigured at compilation. It looks like he doesn't have ctypes for some reason (probably Python 2.4). As an aside, once you've fixed this you'll start getting a different INFO message on occassion informing you that 0 threads were killed =) Regards, Cliff --~--~-~--~~~---~--~~ 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: Template knowing the path to static files
On Jan 22, 2008 7:04 PM, Cliff Wells [EMAIL PROTECTED] wrote: On Tue, 2008-01-22 at 11:11 -0800, Matt Haggard wrote: I've been developing without the filter option, and now that I have it, my hard-coded image paths no longer work. (e.g. they're looking at http://127.0.0.1:5000/images/something.gif when they should be looking at http://127.0.0.1:5000/myapp/images/something.gif ) Why not just use a webserver (Nginx, Apache, etc) to serve them? Then you simply setup a handler for that location (/images) and your problem goes away.. You get the added benefit of things getting significantly faster. I strongly suspect (although I haven't tested) that using Pylons to serve static files isn't going to deploy well in the real world (unless you are expecting very little traffic). You'll have to set up a handler for each file/directory in public if you want to do this, or put everything in a subdirectory of public which will appear in the URL (public/static/images - /static/images). Unless there's a way to make Apache fall back to the application if a static file doesn't exist. It's not well documented how to do this. You're not actually setting up a handler for the static files. You're setting up a handler for the Pylons app and then disabling it for certain sub-URLs. With mod_proxy it would be: DocumentRoot /myapp/myapp/public ProxyPass/ http://127.0.0.1:8080/ ProxyPass/images ! With mod_scgi you'd do something like: Location /images SCGIHandler Off /Location Each handler has a different way to disable itself. There may be some that can't be disabled at all. -- 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 -~--~~~~--~~--~--~---
pylons 10,000 foot overview
Hi, I'm looking for a clear, simple 10,000 foot overview of how pylons and its various components work together, preferably with some snazzy diagrams to point out things like client--server request flows and relationships between the various pylons components. As a brief introduction, I've been using pylons for a couple of months now, both for personal enrichment, and as part of what has become my defacto 'lead web developer' role at the small company where I work. I am fairly effective with the framework now, and have grown to like it quite a bit, despite my initial, overblown reservations about having to learn python. However, I still find that when I am asked specific questions about how pylons works, and how it processes requests in combination with a general purpose webserver like apache2, I don't quite now how to answer. Furthermore, I don't think I could draw a proper flow diagram which describes the path by which a client-side request is eventually processed by the appriate controller, and served using the corresponding template. My intuition in this regard, given my company's current setup, is to respond with something like, After our apache rewrite rule and proxy setup forward the client's request to 127.0.0.1:5000/our_app_prefix/${pagename} the request url is processed according to the map.connect directives in routing.py. Once the appropriate map.connect directive is determined, this is used to look up the corresponding controller, and the appropriate action and/or view, if specified. The action, which is simply a function of above controller class, then either returns raw html, or attempts to render a template if specified.(this leaves out concerns about other components like the model...) however, this 'understanding' is largely something I've come up with as a result of a little bit of early tutoring, which probably came too early, combined with a lot of tinkering, and I'm still not at all confident that it is complete, or even sufficiently accurate as it stands. Of course, I've also read through the basic documentation and tutorials on the main pylons site: http://wiki.pylonshq.com/display/pylonsdocs/Home These documents are very well written, easy to understand and easy to follow, however to my mind they only provide a component-wise explanation of all the various parts of pylons. This gives one an excellent understanding of where one ought to go, and what files one needs to edit in order to realize various different changes in an application, but dolt that I am, even after having read through the majority of these I still don't feel very well-informed as to how the various components actually interact, how paste really fits in, and how a client-side request is actually processed. I'll be the first to admit that this is probably be something that real developers, with comp-sci backgrounds simply take for granted, but it seems that it ought to be fairly simple to come up with a definitive diagram, or flow chart, which would once and for all help me, and others in my situation cement this information in our brains, and thereby enable us to buttress our otherwise prosaic and perhaps inaccurate explanations with a bit of accurate info which even a completely non-tech manager can quickly digest. My current approach, which combines explanations similar to the above, with extemporaneous tactical evasions: Well I can't completely explain the process, but give me a few minutes and I'll whip up an example. doesn't strike me as particularly inspirational, so I'd very much like to fill in the remaining gaps both for my own sake and for others! Apologies for the long-winded post, but I thought it was finally time to get this outstanding mental glitch fixed up. --~--~-~--~~~---~--~~ 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 10,000 foot overview
Thought I'd also add that it would be awesome if something like the diagram below were posted prominently somewhere near the beginning of the pylons docs! On Jan 23, 3:17 pm, kettle [EMAIL PROTECTED] wrote: Ok, so immediately following this lengthy post, I got to thinking, maybe I just haven't been searching for the right keywords. I found this, which is pretty much exactly what I was droning on about in the preceding paragraphs:http://spacepants.org/blog/pylons-paste-stack This is pretty much Exactly what I was looking for. I suppose the only addition I'd make in my own case would be to add my apache configuration as one more box at the bottom of the stack. Certainly writing the post was helpful for me though, and perhaps it will be of use to others in search of something similar. Cheers! On Jan 23, 3:10 pm, kettle [EMAIL PROTECTED] wrote: Hi, I'm looking for a clear, simple 10,000 foot overview of how pylons and its various components work together, preferably with some snazzy diagrams to point out things like client--server request flows and relationships between the various pylons components. As a brief introduction, I've been using pylons for a couple of months now, both for personal enrichment, and as part of what has become my defacto 'lead web developer' role at the small company where I work. I am fairly effective with the framework now, and have grown to like it quite a bit, despite my initial, overblown reservations about having to learn python. However, I still find that when I am asked specific questions about how pylons works, and how it processes requests in combination with a general purpose webserver like apache2, I don't quite now how to answer. Furthermore, I don't think I could draw a proper flow diagram which describes the path by which a client-side request is eventually processed by the appriate controller, and served using the corresponding template. My intuition in this regard, given my company's current setup, is to respond with something like, After our apache rewrite rule and proxy setup forward the client's request to 127.0.0.1:5000/our_app_prefix/${pagename} the request url is processed according to the map.connect directives in routing.py. Once the appropriate map.connect directive is determined, this is used to look up the corresponding controller, and the appropriate action and/or view, if specified. The action, which is simply a function of above controller class, then either returns raw html, or attempts to render a template if specified.(this leaves out concerns about other components like the model...) however, this 'understanding' is largely something I've come up with as a result of a little bit of early tutoring, which probably came too early, combined with a lot of tinkering, and I'm still not at all confident that it is complete, or even sufficiently accurate as it stands. Of course, I've also read through the basic documentation and tutorials on the main pylons site:http://wiki.pylonshq.com/display/pylonsdocs/Home These documents are very well written, easy to understand and easy to follow, however to my mind they only provide a component-wise explanation of all the various parts of pylons. This gives one an excellent understanding of where one ought to go, and what files one needs to edit in order to realize various different changes in an application, but dolt that I am, even after having read through the majority of these I still don't feel very well-informed as to how the various components actually interact, how paste really fits in, and how a client-side request is actually processed. I'll be the first to admit that this is probably be something that real developers, with comp-sci backgrounds simply take for granted, but it seems that it ought to be fairly simple to come up with a definitive diagram, or flow chart, which would once and for all help me, and others in my situation cement this information in our brains, and thereby enable us to buttress our otherwise prosaic and perhaps inaccurate explanations with a bit of accurate info which even a completely non-tech manager can quickly digest. My current approach, which combines explanations similar to the above, with extemporaneous tactical evasions: Well I can't completely explain the process, but give me a few minutes and I'll whip up an example. doesn't strike me as particularly inspirational, so I'd very much like to fill in the remaining gaps both for my own sake and for others! Apologies for the long-winded post, but I thought it was finally time to get this outstanding mental glitch fixed up. --~--~-~--~~~---~--~~ 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
Re: Template knowing the path to static files
On Tue, 2008-01-22 at 19:37 -0800, Mike Orr wrote: You'll have to set up a handler for each file/directory in public if you want to do this, or put everything in a subdirectory of public which will appear in the URL (public/static/images - /static/images). Unless there's a way to make Apache fall back to the application if a static file doesn't exist. It's not well documented how to do this. You're not actually setting up a handler for the static files. You're setting up a handler for the Pylons app and then disabling it for certain sub-URLs. With mod_proxy it would be: DocumentRoot /myapp/myapp/public ProxyPass/ http://127.0.0.1:8080/ ProxyPass/images ! With mod_scgi you'd do something like: Location /images SCGIHandler Off /Location Each handler has a different way to disable itself. There may be some that can't be disabled at all. I don't use Apache, but here's what I would do in Nginx: server { listen 1.2.3.4:80; server_name www.example.com; error_page 404 /404; # goes to Pylons app location / { proxy_pass http://127.0.0.1:8000$request_uri; include /etc/nginx/proxy.conf; } # static files location location ~* ^/(static|images|javascript|js|css|flash|media| downloads)/$ { root /path/to/public; } } and my directory layout just looks like: /path/to/public/static /path/to/public/images etc. If you wanted to preserve the requested URI to pass to your controller, you could use a conditional redirect instead: server { listen 1.2.3.4:80; server_name www.example.com; location / { proxy_pass http://127.0.0.1:8000$request_uri; include /etc/nginx/proxy.conf; } # static files location location ~* ^/(static|images|javascript|js|css|flash|media|downloads)/$ { root /path/to/public; if (!-f $request_filename) { rewrite (.*) /404?page=$request_uri redirect; } } } Personally, I let Nginx handle 404's for the most part. Bots (most of them checking for hackable versions of PHP apps it seems) can generate a ton of 404's. Hope that helps someone. Regards, Cliff --~--~-~--~~~---~--~~ 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 10,000 foot overview
I'm just going to continue using this post as my personal notepad, and add a couple more useful resources I've managed to dig up in the last hour: http://pythonpaste.org/archives/mindex/[EMAIL PROTECTED]/message/20070307.035711.786edbb1.en.html http://pythonpaste.org/archives/mindex/[EMAIL PROTECTED]/message/20070306.215339.19920008.en.html Unfortunately I'm still not 100% sure how paste works, but perhaps it's OK to leave that as a black box for now. On Jan 23, 3:28 pm, kettle [EMAIL PROTECTED] wrote: Thought I'd also add that it would be awesome if something like the diagram below were posted prominently somewhere near the beginning of the pylons docs! On Jan 23, 3:17 pm, kettle [EMAIL PROTECTED] wrote: Ok, so immediately following this lengthy post, I got to thinking, maybe I just haven't been searching for the right keywords. I found this, which is pretty much exactly what I was droning on about in the preceding paragraphs:http://spacepants.org/blog/pylons-paste-stack This is pretty much Exactly what I was looking for. I suppose the only addition I'd make in my own case would be to add my apache configuration as one more box at the bottom of the stack. Certainly writing the post was helpful for me though, and perhaps it will be of use to others in search of something similar. Cheers! On Jan 23, 3:10 pm, kettle [EMAIL PROTECTED] wrote: Hi, I'm looking for a clear, simple 10,000 foot overview of how pylons and its various components work together, preferably with some snazzy diagrams to point out things like client--server request flows and relationships between the various pylons components. As a brief introduction, I've been using pylons for a couple of months now, both for personal enrichment, and as part of what has become my defacto 'lead web developer' role at the small company where I work. I am fairly effective with the framework now, and have grown to like it quite a bit, despite my initial, overblown reservations about having to learn python. However, I still find that when I am asked specific questions about how pylons works, and how it processes requests in combination with a general purpose webserver like apache2, I don't quite now how to answer. Furthermore, I don't think I could draw a proper flow diagram which describes the path by which a client-side request is eventually processed by the appriate controller, and served using the corresponding template. My intuition in this regard, given my company's current setup, is to respond with something like, After our apache rewrite rule and proxy setup forward the client's request to 127.0.0.1:5000/our_app_prefix/${pagename} the request url is processed according to the map.connect directives in routing.py. Once the appropriate map.connect directive is determined, this is used to look up the corresponding controller, and the appropriate action and/or view, if specified. The action, which is simply a function of above controller class, then either returns raw html, or attempts to render a template if specified.(this leaves out concerns about other components like the model...) however, this 'understanding' is largely something I've come up with as a result of a little bit of early tutoring, which probably came too early, combined with a lot of tinkering, and I'm still not at all confident that it is complete, or even sufficiently accurate as it stands. Of course, I've also read through the basic documentation and tutorials on the main pylons site:http://wiki.pylonshq.com/display/pylonsdocs/Home These documents are very well written, easy to understand and easy to follow, however to my mind they only provide a component-wise explanation of all the various parts of pylons. This gives one an excellent understanding of where one ought to go, and what files one needs to edit in order to realize various different changes in an application, but dolt that I am, even after having read through the majority of these I still don't feel very well-informed as to how the various components actually interact, how paste really fits in, and how a client-side request is actually processed. I'll be the first to admit that this is probably be something that real developers, with comp-sci backgrounds simply take for granted, but it seems that it ought to be fairly simple to come up with a definitive diagram, or flow chart, which would once and for all help me, and others in my situation cement this information in our brains, and thereby enable us to buttress our otherwise prosaic and perhaps inaccurate explanations with a bit of accurate info which even a completely non-tech manager can quickly digest. My current approach, which combines explanations similar to the above, with extemporaneous tactical evasions: Well I can't completely