how do others handle SqlAlchemy / etc maintenance in your Pyramid apps ?

84 views
Skip to first unread message

Jonathan Vanasco

unread,
Jan 24, 2013, 8:36:57 PM1/24/13
to pylons-discuss
I've had to run a few 'maintenance' routines on one of my apps :
- we changed a few db fields
- we needed to clear the cache
- the functions that created some db field data were updated, so
everything needed to be tested for compliance and possibly regenerated

i couldn't figure out a good way to handle this .
- with an independent script , i'd lose a lot of the functionality
tied to the app/pyramid
- using the commandline / shell for pyramid , i couldn't figure out
how to run everything with a request object ( as many functions are
tied to that )

so i've ended up creating a few views, lock them down, and then turn
them off after I run them.

nothing has caused a timeout, yet, but i'd like a better option. can
someone point me in the right direction ?

Michael Merickel

unread,
Jan 24, 2013, 10:40:08 PM1/24/13
to Pylons

Not sure what else to say here.. your use case is why p.paster.bootstrap exists.



--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.



Andreas Jung

unread,
Jan 25, 2013, 1:46:06 AM1/25/13
to pylons-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I think using "alembic" seems to be the way to go for
upgrading/downgrading database schemas.

- -aj
- --
ZOPYX Limited | Python | Zope | Plone | MongoDB
Hundskapfklinge 33 | Consulting & Development
D-72074 T�bingen | Electronic Publishing Solutions
www.zopyx.com | Scalable Web Solutions
- --------------------------------------------------
Produce & Publish - www.produce-and-publish.com


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJRAiotAAoJEADcfz7u4AZjBCELwMrDKGl/AMwzQ+JNXpq9z8wb
Ee+2QOZPqszLkgb4vqO0Vh5qV6Yx/T2f+ThRTw1YfxauRbFXo5j8vfyjQOxB9gZo
r2vi4o5xZDGWdeOJ//Z8EiK+agOOuQl57MfCogoAei8aIK9uRabHF4qcshNwjgeL
tbKy1N3+sK4WammXZDhw5jcE/euUqpNQXTuSdj9t7BW9QHtO5HgQ05sIjVQ0kL/n
kP0VicLkGt3H4ozjabnZe9H3KZZzbDrBnXqFBqW0AbsuebW9mVwsMHepx+vVNi7L
XksmEo+XPyJMu+R5bNiu4R47IlUfuL3UZ5STcbnSKKRhFX67KE0M43MdXGhFyVAd
eXH7U7cXdUQr7Kf8gwdRX9Py+xbfkvJxY7scyzVWMwUX2kiauaWorwqMgfS+h4wi
Fb3QyneJZj6XXXMNqyyTzQyiq634BHRWcvdcL/57gWhHyYYwwXKgInq5u93tH/NO
YfGuJAlq+fzjQDw6hbQ65w0GaEE/Js4=
=yBzl
-----END PGP SIGNATURE-----
lists.vcf

Jonathan Vanasco

unread,
Jan 25, 2013, 10:28:52 AM1/25/13
to pylons-discuss


On Jan 24, 10:40 pm, Michael Merickel <mmeri...@gmail.com> wrote:
> http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/narr/com...
>
> Not sure what else to say here.. your use case is why p.paster.bootstrap
> exists.

I had no idea it exists. It's exactly what I needed. I missed the
changelog on this 2 years ago!


from pyramid.paster import bootstrap
from pyramid.request import Request

import myapp
import myapp.lib.handlers
import myapp.models.core

class BootstrappedHandler( myapp.lib.handlers._CoreHandler ) :
def __init__( self , request ):
self.request = request
self._setupDbWriter()

env = bootstrap('MyApp/development.ini')

bootstrapped = BootstrappedHandler( env['request'] )
print bootstrapped
print bootstrapped.request.dbSession.writer

print
bootstrapped.request.dbSession.writer.query( myapp.models.core.Useraccount ).all()


env['closer']()

Jonathan Vanasco

unread,
Jan 25, 2013, 10:32:34 AM1/25/13
to pylons-discuss

On Jan 25, 1:46 am, Andreas Jung <li...@zopyx.com> wrote:

> I think using "alembic" seems to be the way to go for
> upgrading/downgrading database schemas.

It is the best for database schema migrations.

But our maintenance largely has to do with internal functions changing
how/where things are stored. A few items didn't have the correct
permalink structure , and things like that. The database isn't
changed, just the data in them ( because we improved something, or
found an edge-case to protect against and fix ).
Reply all
Reply to author
Forward
0 new messages