Elixir has its own SessionContext
On Mar 23, 7:37 pm, __wyatt [EMAIL PROTECTED] wrote: Note: I couldn't reply directly to the original message[1] in the group, so I'm creating a new post. [1]http://groups.google.com/group/pylons-discuss/browse_frm/thread/1f05f... On Dec 30 2006, 12:56 am, Ben Bangert [EMAIL PROTECTED] wrote: On Dec 29, 2006, at 11:08 PM, Jose Galvez wrote: Any chance we could get a short example showing how to use the new sqlalchemyfeatures Sure, the two methods of interest are in pylons.database here:http://pylonshq.com/docs/0.9.4/module-pylons.database.html#create_eng... Since aSQLAlchemyengine is a pooled connection, only one of them needs to be created for your application. The create_engine stores the connection pool in your 'g' object. From my reading of the code, ``create_engine`` *doesn't* store the connection pool in ``g`` but ``make_session`` does. Also, from what I can tell from your example, you never use ``create_engine`` (the one from pylons.database), and it's not clear where you create your engine. I think that's because when pylons.database is imported, ``pylons.database.session_context`` is automatically created and in the process calls ``make_session``, which in turn calls ``create_engine``. That engine is accessible by doing something like this: from pylons.database import session_context engine = session_context.current.bind_to I do that in my model so I can call metadata.connect(model.engine) in my ``BaseController`` (aside: Elixir's metadata currently requires doing this). It seems like (in a basic setup) all you have to do is import pylons.database at some point during app initialization (probably in your model) and clear ``pylons.database.session_context.current`` on every request, using one of these methods: pylons.database.session_context.current = make_session() # This next one is suggested by pjenvey in this post: #http://groups.google.com/group/pylons-discuss/msg/0fb2b9f789b341ea # It has the advantage of not having to import # ``pylons.database.make_session`` del pylons.database.session_context.current # May be slower than the two above pylons.database.session_context.current.clear() You can import ``session_context`` in your ``models.__init__`` to make things a little simpler. This is what my current setup looks like: # development.ini [app:main] # other stuff sqlalchemy.dburi = mysql://wyatt:[EMAIL PROTECTED]/wyatt_dev sqlalchemy.echo = true # models/__init__.py from pylons.database import session_context from elixir import metadata engine = session_context.current.bind_to class SomeEntity(Entity): has_field('title', String) # etc. # lib/base.py def __call__(self, environ, start_response): del model.session_context.current model.metadata.connect(model.engine) return WSGIController.__call__(self, environ, start_response) And that's everything I have related to setting up SQLAlchemy for use in my app. I struggled with this a bit, so I hope this helps somebody (and I hope it really works!). Any corrections appreciated. Elixir has its own SessionContext that it uses with assign_mapper [1], and what I wrote above doesn't seem to work very well with Elixir (i.e., objects aren't refreshed). Here's what seems to be working now (showing only the relevant parts): # old models/__init__.py from pylons.database import session_context from elixir import metadata engine = session_context.current.bind_to class SomeEntity(Entity): has_field('title', String) # etc. # new improved models/__init__.py from elixir import metadata, objectstore session_context = objectstore.context class SomeEntity(Entity): has_field('title', String) # etc. # old lib/base.py def __call__(self, environ, start_response): del model.session_context.current model.metadata.connect(model.engine) return WSGIController.__call__(self, environ, start_response) # new improved lib/base.py from pylons.database import make_session def __call__(self, environ, start_response): db_session = make_session() session_context.current = db_session metadata.connect(db_session.bind_to) __wyatt [1] http://elixir.ematia.de/elixir/entity.py.html#165 --~--~-~--~~~---~--~~ 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 Pylons site launched
Congratulations Robert and thanks for sharing the setup with the rest of us! James Robert Leftwich wrote: Just thought I'd let everyone know that after much hard work we have finally publicly launched our Pylons-based site - http://www.marketshares.com.au Apologies for the (semi-)spam, but I think it is a good advertisement for the power of Pylons as it is a fairly large site with daily data on more than 600 companies. It is a heavy user of Myghty with more than 160 template/component files. Each trading night it processes around 2GB of additional data into the postgres db via SQLAlchemy and creates more than 55,000 individual graphs which are available over more than 3 years (totalling 250G). We are using nginx as the web server/load balancer. I am indebted to the Pylons and SQLAlchemy people (and the many related projects, such as Paste, FormBuild, Authkit, and more) as it would have been a lot more difficult to get to where we are without these excellent projects to build on. Robert --~--~-~--~~~---~--~~ 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: AuthKit using database for users, groups, roles?
Hi Chris, Chris Shenton wrote: My implementation may not be the cleanest and I'm still uncertain about doing auth in my account.py controller versus doing something with valid() in app_globals.py. Well, you only need to use valid() if you want the AuthKit middleware to handle the authentication. Since you are using the forward method your application has to handle authentication itself so your setup is correct! I've written a HOWTO on what I did at http://pylonshq.com/project/pylonshq/wiki/PylonsWithAuthKitDatabase This is really useful actually, thanks! I'm going to see if I can find a simple way to package it up so that it can form part of AuthKit itself, perhaps using Elixir and ToscaWidgets to make it look a bit simpler. Cheers, James --~--~-~--~~~---~--~~ 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: Proxy helper
On 3/25/07, ram [EMAIL PROTECTED] wrote: I've got a requirement to have our Pylons app act as an occasional proxy to a different web service. In one case, we're going to proxy to an instance of Microsoft report server to fetch the results of report runs. The service has a straightforward URL request mechanism that simply streams the bytes of the results (in our case, a PDF file) back to the caller. As you might imagine some of these results are rather large, and we'd rather not have the server get too involved in buffering the result, as it might consume all available memory, or having to write a disk version and then read that back to the originating client. Conceptually, I see this as two pipes that could simply be connected -- the client is an open socket that is reading, waiting for results. The proxied URL request is a socket that wants to pump out bytes. Is there any simple way to simply connect the two pipes and let the bytes flow without having to have the application do the work of moving bytes from one pipe to another? There's proxying code in Paste to do this sort of stuff, but I tend to rely on Apache for this. That is, I have Apache in front of a bunch of different apps, many of which are Pylons apps. I'm sure other Pasters will be online later to tell you more about using Paste's proxying code if that's the route you wish to take. Happy Hacking! -jj -- http://jjinux.blogspot.com/ --~--~-~--~~~---~--~~ 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: Proxy helper
Rick, If I couldn't use a regular proxy in front of such an application, I'd rather go for paste.proxy instead of trying to implement it on Pylons level. On Mar 25, 5:31 pm, ram [EMAIL PROTECTED] wrote: I've got a requirement to have our Pylons app act as an occasional proxy to a different web service. In one case, we're going to proxy to an instance of Microsoft report server to fetch the results of report runs. The service has a straightforward URL request mechanism that simply streams the bytes of the results (in our case, a PDF file) back to the caller. As you might imagine some of these results are rather large, and we'd rather not have the server get too involved in buffering the result, as it might consume all available memory, or having to write a disk version and then read that back to the originating client. Conceptually, I see this as two pipes that could simply be connected -- the client is an open socket that is reading, waiting for results. The proxied URL request is a socket that wants to pump out bytes. Is there any simple way to simply connect the two pipes and let the bytes flow without having to have the application do the work of moving bytes from one pipe to another? Thanks, Rick --~--~-~--~~~---~--~~ 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: Extending an application into another
On Mar 26, 2007, at 4:10 PM, Bob Van Zant wrote: What youve described about a generic gallery application follows what is called an application service provider model. One application runs many sites. Another site I wrote in Aquarium, remembering-you.org does this. One instance of the code powers a few subdomains that are assigned to customers. I've done this sort of thing in Zope. I wrote the Photo/PhotoFolder product for Zope2 years ago, and I'm still using it in some capacity on various sites that I host. I'm using a modified version on the photographer's site (with watermarking features added), but only for public galleries. There are no features for customer shoot management or purchasing. Im not too sure I want to hand this off as open source for something where it seems clear youll be making money (the photographer in me). Id be happy to be here for you to bounce ideas off of but without further negotiation Im not too keen on handing over the code. I have no plans to make money on it (directly). The photographer is my wife, and it's her business that will profit from this, so I guess I could profit from it indirectly. If it happens to be something I can market to other photographers, that might be nice, but that's not my current plan. I would, however, like to develop it in such a way that it could be adapted to various photographers' needs. That might be more difficult than I know, but if my wife wants to change the way she does things, I'd like for that to be possible without a lot of rewriting. Right now, she has a hodge-podge of what I wrote in Zope2 and a commercial PHP application that handles online ordering. While it's not a bad product, it lacks a number of features we would like to have and the code is a disaster, so I'm not interested in extending it. Note that the market for what youre talking about is huge. You may already know this. There are no good- places for good photographers to sell their images on their own like this. If this is where youre headed, and youve already chosen Python, Im listening. I've definitely already chosen Python, and from what I've seen and read (quite a bit), Pylons. My wife is big on using the Internet and what she has in place has already helped considerably (despite its problems and limitations), so the project should be both useful and fun. Having a fair amount of experience with Python and PIL, as well as database driven commerce sites in Python/Zope, I have a pretty good idea of what it will take. My question about Pylons was more about organizing the parts to maximize code reuse. Perhaps explaining my Zope Photo product would help. It may be that I've been in Zope world so much that I'm overlooking something basic. The Zope photo product is essentially two objects: a Photo object and a PhotoFolder object that contains Photo objects. The Photo object provides for automatically creating and storing various customizable sizes that can be viewed by name (eg, small, medium, large). The PhotoFolder object provides methods for managing contained photos. There is no default view for displaying a PhotoFolder. The user of the product would create their own templates using the Photo API to retrieve the list of photos, desired display sizes and other metadata associated with the photo. I would like to accomplish basically the same thing in Pylons, using SQLAlchemy for photo and gallery object data (minus the raw image data, which would be on the filesystem) and providing some sort of web-based management interface for adding/removing/editing galleries and photos. However, when it comes to viewing the gallery, I'd prefer the site developer build their own templates and layout the thumbnails, navigation, desired metadata to display, etc. as they wish. I don't want to dictate that part (except as a user integrating the product into my own sites). What that would give me is the ability to use the photo product as the backend to a very basic personal photo gallery, a complex customer shoot management and ordering system, or anywhere in between. Does this make more sense? Is this something that can/should be done in Pylons? Or perhaps a Python module that uses SQLAlchemy (or whatever) would be more reasonable, and then I would just use that module in my Pylons applications. Since I don't yet fully understand the glue that is Pylons, I'm not sure if/how a Pylons application would make use of another Pylons application this way. -- Ron --~--~-~--~~~---~--~~ 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
XMLRPCController and None values
Acording to Python manual (http://docs.python.org/lib/module- xmlrpclib.html) it is possible to send None via XML-RPC protoco but it does not work in Pylons. I found (http://docs.python.org/lib/ node658.html) that xmlrpclib.dumps() requires one more parameter (allow_none=True) which can fix this problem. pylons/controllers.py old line 295 response = xmlrpclib.dumps(raw_response, methodresponse=True) fixed line 295: response = xmlrpclib.dumps(raw_response, methodresponse=True, allow_none=True) -- Jaroslaw Zabiello http://blog.zabiello.com --~--~-~--~~~---~--~~ 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: AuthKit using database for users, groups, roles?
On Thu, 2007-03-22 at 18:48 -0400, Chris Shenton wrote: I've written a HOWTO on what I did at http://pylonshq.com/project/pylonshq/wiki/PylonsWithAuthKitDatabase Feedback, sanity checks and corrections welcomed. I'm sure it's far from optimal but hope it will help other folks get started with this common chore. Very minor nit. You specify that the username is unique in the model, but then explicitly test in valid() whether more than one user is returned (which is theoretically impossible). 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: XMLRPCController and None values
On Mar 26, 2007, at 4:18 PM, Jaroslaw Zabiello wrote: Acording to Python manual (http://docs.python.org/lib/module- xmlrpclib.html) it is possible to send None via XML-RPC protoco but it does not work in Pylons. I found (http://docs.python.org/lib/ node658.html) that xmlrpclib.dumps() requires one more parameter (allow_none=True) which can fix this problem. pylons/controllers.py old line 295 response = xmlrpclib.dumps(raw_response, methodresponse=True) fixed line 295: response = xmlrpclib.dumps(raw_response, methodresponse=True, allow_none=True) I've just added this, but as an option: http://pylonshq.com/project/pylonshq/changeset/1916 It defaults to False like dumps. Thanks! -- 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 -~--~~~~--~~--~--~---
Questions About using Wiki Pylons Information for (Pyschool)
I have a question for everyone. Would it be ok if I used some of the information provided in the Wiki (Example: Concepts of Pylons http:// pylonshq.com/project/pylonshq/wiki/ConceptsOfPylons) as a part of my web based Introduction to Pylons Workshop graduate school project (PySchool)? Unfortunately I will not have enough time to finish the complete workshop before I graduate. I will only be able to cover: 1. Introduction to Pylons 2. Pylons Installation 3. Pylons Project creations 4. Working with Models, Controllers, and Views. I will finish the workshop once I have completed my graduate work. I would have finished the website about a month ago but I have been running into a lot of major life obstacles. I hope to help educate more people about how great Pylons and Python are for web development. Any information would be appreciated. Thanks Rob J In case anyone wants see what the final PySchool site will look like take a look at the following URL: http://robj.110mb.com/ The final site will not be at this URL. This is just where I have been working on the site to show my professor. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---