Re: Absolute path for static assets/ Get file modified time

2011-11-16 Thread Jay T
That worked. Thanks ! Jay On 11/16/11 5:46 PM, Michael Merickel wrote: You will need to use the pkg_resources api from the Python stdlib. Currently (this will be fixed in 1.3) there is no public API for computing paths. import pkg_resources asset_path = 'mypackage:static/favicon.ico' packa

Re: Absolute path for static assets/ Get file modified time

2011-11-16 Thread Michael Merickel
You will need to use the pkg_resources api from the Python stdlib. Currently (this will be fixed in 1.3) there is no public API for computing paths. import pkg_resources asset_path = 'mypackage:static/favicon.ico' package, file = asset_path.split(':', 1) abs_path = pkg_resources.resource_filename

Absolute path for static assets/ Get file modified time

2011-11-16 Thread Jay T
How do I get the absolute path for static assets ? The reason I need the absolute path is to determine the last modified time of a specific file so I can append it to my static resources like JS and CSS files. I wrote a Mako template def like this but it fails at : here = os.path.dirname(__file

Re: Looping throug lists in a template using a for loop produces a NameError

2011-11-16 Thread Eric Rasmussen
Hello, The Mako syntax looks right, but you're using a Chameleon file extension on your template. With the default renderer settings, Pyramid will attempt to render it as a Chameleon template and won't recognize the Mako formatting. It should work if you rename the template to listOfHosts.mako ins

Looping throug lists in a template using a for loop produces a NameError

2011-11-16 Thread David Eagle
I'm new to Pyramid and trying to get it to work with me, I've installed pyramid-1.2.1 in a virtualenv and I'm trying to loop through a simple list within a template but it seems to me that the statement "% for item in cisList" does not initialize the "item" variable but if I call ${cisList[0]['name

Re: Multiple transactions within request

2011-11-16 Thread Vlad K.
According to my tests it is, or at least the end result is savepoint release being emitted before final commit. For this code: sp = transaction.savepoint() ... do something session.flush() sp2 = transaction.savepoint() ... do something session.flush() # Oops, Integrit

Re: Multiple transactions within request

2011-11-16 Thread Michael Merickel
I will say that after looking at the SQLAlchemy documentation once again, it does say "For each begin_nested() call, a corresponding rollback() or commit() must be issued." and even from looking at the unit tests in zope.sqlalchemy I cannot tell where the required commit() is issued per savepoint.

Re: Multiple transactions within request

2011-11-16 Thread Vlad K.
Yes it actually works if I use session.flush() instead of transaction.commit() within the subtransaction. So I guess transaction.commit() and transaction.abort() close the entire transaction unlike session.commit() which when matched against session.begin_nested() releases the savepoint but k

Re: Multiple transactions within request

2011-11-16 Thread Chris McDonough
On Tue, 2011-11-15 at 11:44 -0600, Michael Merickel wrote: > It's been hard to follow what has actually been tried, but I just > wanted to point some stuff out about zope.sqlalchemy (the code for it > is literally 1 small file and shouldn't be talked about with such a > scary tone). > > > When do