Perform some action before pserve

71 views
Skip to first unread message

Mark Huang

unread,
Oct 24, 2012, 11:01:55 AM10/24/12
to pylons-...@googlegroups.com
Hi,

I want to set some environment variables on my Ubuntu machine before I run pserve command.  Reason that it's not set in the ini file is because a particular python file in my Pyramid web application has no access to request parameter to retrieve the settings.

I was thinking of overriding pserve command to add the environment variables in before it starts the application.

Any way to do this?  Couldn't find much about this topic in the docs.  The closest thing to this was to use a setup script for pshell.....but then again....it's for the pshell command and not the pserve.

Regards,
Mark Huang

薛 斌雷

unread,
Oct 24, 2012, 12:37:03 PM10/24/12
to pylons-...@googlegroups.com
http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/narr/environment.html#environment-chapter

something like this.
$ PYRAMID_DEBUG_AUTHORIZATION=1 PYRAMID_RELOAD_TEMPLATES=1 \
       bin/paster serve MyProject.ini
does it meet your requirements?

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pylons-discuss/-/_7kroRdiFdQJ.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.

Jonathan Vanasco

unread,
Oct 24, 2012, 2:44:53 PM10/24/12
to pylons-discuss
For staging/production, I tend to write startup scripts per machine.
For a while i was doing shell scripts, but then I started using
Fabric.

For local development, i have a 'source' file , that typically does
this:

1. cd path_to_pyramidapp
2. source path_to_virtualenv/bin/activate
3. handle any variables

whenever i need to start working on a project:

$ source go_myapp.source

and then i'm in the right directory, with the right virtualenv, and
all the right env vars

Benjamin Sims

unread,
Oct 24, 2012, 4:00:13 PM10/24/12
to pylons-...@googlegroups.com, pylons-discuss
For this purpose, I use virtualenvwrapper. You can then put everything into your postactivate file (in /bin) and it will be run automatically.

-- Sent from my phone
> --
> You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
Message has been deleted

Mark Huang

unread,
Oct 25, 2012, 2:51:13 AM10/25/12
to pylons-...@googlegroups.com
Thanks for your answer Jonathan.  I agree with you.  For staging/production, fabric is the way to go, even though I haven't taken time to learn it properly yet.  

For development, ....our team is really young and new to Python, linux for that matter.  I'm in China, everyone uses Windows here.  I wanted a one step solution such that it doesn't change their workflow as to how they start up their development Pyramid application (they still continue to use pserve --reload development.ini).  

I think I'll combine your answer with `somewhattofftheway` and add it to the postactivate file of virtualenvwrapper.

Thanks everyone!
Reply all
Reply to author
Forward
0 new messages