[web2py] How do you manage your app repo with Mercurial

2012-01-10 Thread Jim Steil

Hi

I'm looking for input on how people manage their database connection 
when setting up your app in a Mercurial repository.


If I just add my app and db.py to my repository, then every time I setup 
a different development machine to access it, the app will, by default, 
point to the same database.  But, this database connection isn't correct 
when I'm working on my laptop or from a home workstation and therefore, 
I need a different way to specify my db connection info.


The solution I've come up with is to have a config file (using 
configobj) hold my db information, and read it in db.py to get the 
info.  But, then this causes even more overhead on each request.


Also, what do you do about your databases sub-directory?  I would think 
that I don't want to track any changes there, but when my repo gets 
cloned an empty databases directory should be placed there.


-Jim


Re: [web2py] How do you manage your app repo with Mercurial

2012-01-10 Thread Jonathan Lundell
On Jan 10, 2012, at 6:04 AM, Jim Steil wrote:

 I'm looking for input on how people manage their database connection when 
 setting up your app in a Mercurial repository.
 
 If I just add my app and db.py to my repository, then every time I setup a 
 different development machine to access it, the app will, by default, point 
 to the same database.  But, this database connection isn't correct when I'm 
 working on my laptop or from a home workstation and therefore, I need a 
 different way to specify my db connection info.
 
 The solution I've come up with is to have a config file (using configobj) 
 hold my db information, and read it in db.py to get the info.  But, then this 
 causes even more overhead on each request.
 
 Also, what do you do about your databases sub-directory?  I would think that 
 I don't want to track any changes there, but when my repo gets cloned an 
 empty databases directory should be placed there.

web2py should create the databases subdirectory for you if it's not there (at 
the beginning of the first request).

Re: [web2py] How do you manage your app repo with Mercurial

2012-01-10 Thread Jim Steil
Thank Jonathan, I didn't realize that it would be created 
automatically.  I'll just keep 'databases' out of the repo altogether then.


-Jim

On 1/10/2012 9:25 AM, Jonathan Lundell wrote:

On Jan 10, 2012, at 6:04 AM, Jim Steil wrote:


I'm looking for input on how people manage their database connection when 
setting up your app in a Mercurial repository.

If I just add my app and db.py to my repository, then every time I setup a 
different development machine to access it, the app will, by default, point to 
the same database.  But, this database connection isn't correct when I'm 
working on my laptop or from a home workstation and therefore, I need a 
different way to specify my db connection info.

The solution I've come up with is to have a config file (using configobj) hold 
my db information, and read it in db.py to get the info.  But, then this causes 
even more overhead on each request.

Also, what do you do about your databases sub-directory?  I would think that I 
don't want to track any changes there, but when my repo gets cloned an empty 
databases directory should be placed there.

web2py should create the databases subdirectory for you if it's not there (at 
the beginning of the first request).


Re: [web2py] How do you manage your app repo with Mercurial

2012-01-10 Thread Tim Alexander
I'm not sure there's a standard way of doing it if you're not using
sqlite, but I personally have the database pointing to a name in my
hosts file. So I'll configure configdbhost to be my configuration
database (in the hosts file on the box) and then have the lines (split
so that if the application is deployed on apptest application, it
points to a test database):
if request.application == 'apptest':
# Test db
db = DAL('postgres://configdbhost/apptest')
else:
# Prod DB
db = DAL('postgres://configdbhost/mydb')

On Tue, Jan 10, 2012 at 9:25 AM, Jonathan Lundell jlund...@pobox.com wrote:
 On Jan 10, 2012, at 6:04 AM, Jim Steil wrote:

 I'm looking for input on how people manage their database connection when 
 setting up your app in a Mercurial repository.

 If I just add my app and db.py to my repository, then every time I setup a 
 different development machine to access it, the app will, by default, point 
 to the same database.  But, this database connection isn't correct when I'm 
 working on my laptop or from a home workstation and therefore, I need a 
 different way to specify my db connection info.

 The solution I've come up with is to have a config file (using configobj) 
 hold my db information, and read it in db.py to get the info.  But, then 
 this causes even more overhead on each request.

 Also, what do you do about your databases sub-directory?  I would think that 
 I don't want to track any changes there, but when my repo gets cloned an 
 empty databases directory should be placed there.

 web2py should create the databases subdirectory for you if it's not there (at 
 the beginning of the first request).


Re: [web2py] How do you manage your app repo with Mercurial

2012-01-10 Thread Jonathan Lundell
On Jan 10, 2012, at 7:32 AM, Jim Steil wrote:

 Thank Jonathan, I didn't realize that it would be created automatically.  
 I'll just keep 'databases' out of the repo altogether then.

For the benefit of other readers, the issue that Jim is referring to is that 
hg, like many source-management systems, doesn't track directories per se, only 
files, so in particular it will never have an empty directory in a repository. 
For this and related reasons, web2py makes sure that the following set of 
application subdirectories exists:

('models', 'views', 'controllers', 'databases', 'modules', 'cron', 'errors', 
'sessions', 'languages', 'static', 'private', 'uploads')

(web2py does try to be efficient about this test, so that it doesn't have to 
explicitly look for the directories on each request; ordinarily the actual test 
will happen only on the first request, so the normal overhead is negligible.)



 
-Jim
 
 On 1/10/2012 9:25 AM, Jonathan Lundell wrote:
 On Jan 10, 2012, at 6:04 AM, Jim Steil wrote:
 
 I'm looking for input on how people manage their database connection when 
 setting up your app in a Mercurial repository.
 
 If I just add my app and db.py to my repository, then every time I setup a 
 different development machine to access it, the app will, by default, point 
 to the same database.  But, this database connection isn't correct when I'm 
 working on my laptop or from a home workstation and therefore, I need a 
 different way to specify my db connection info.
 
 The solution I've come up with is to have a config file (using configobj) 
 hold my db information, and read it in db.py to get the info.  But, then 
 this causes even more overhead on each request.
 
 Also, what do you do about your databases sub-directory?  I would think 
 that I don't want to track any changes there, but when my repo gets cloned 
 an empty databases directory should be placed there.
 web2py should create the databases subdirectory for you if it's not there 
 (at the beginning of the first request).




Re: [web2py] How do you manage your app repo with Mercurial

2012-01-10 Thread Joseph Jude
I use the below:
is_local = request.client in ['127.0.0.1', 'localhost']
if is_local:
from local_settings import *
else:
from prod_settings import *

I got local_settings.py  prod_settings.py. Through hgignore, I ignore 
prod_settings.py so it doesn't go to my public repo.

P.S: since I run the site on webfaction where request.is_local returns true 
so I had to use the first line shortcut.

Joseph
http://www.jjude.biz


Re: [web2py] How do you manage your app repo with Mercurial

2012-01-10 Thread Jim Steil

Thanks for the input Joseph.  I can see how that would work for me too.

-Jim

On 1/10/2012 7:46 PM, Joseph Jude wrote:

I use the below:
is_local = request.client in ['127.0.0.1', 'localhost']
if is_local:
from local_settings import *
else:
from prod_settings import *

I got local_settings.py  prod_settings.py. Through hgignore, I ignore 
prod_settings.py so it doesn't go to my public repo.


P.S: since I run the site on webfaction where request.is_local returns 
true so I had to use the first line shortcut.


Joseph
http://www.jjude.biz

No virus found in this message.
Checked by AVG - www.avg.com http://www.avg.com
Version: 2012.0.1901 / Virus Database: 2109/4734 - Release Date: 01/10/12



--
Jim Steil
VP of Information Technology
Quality Liquid Feeds, Inc.
608.935.2345 office
608.341.9896 cell