Foo, typo. My bad.
Line should be this:
if 'W2PYENV' in environ.keys() and environ['W2PYENV'] == 'dev':
On Thursday, May 24, 2012 2:22:50 PM UTC-4, Cliff Kachinske wrote:
>
> If your development environment is Linux, you can set and read an
> environment variable to take care of this.
>
> As sudo or su, add the following line to /etc/environment:
> W2PYENV="dev"
>
> Python only loads the environment once, so I had to kill all the python
> instances. I just rebooted.
>
> Then, in db.py:
>
> from os import environ
> ## the 'get permission' method of avoiding a missing key exception
> ## a try..except block will also work
> if 'W2PYENV' in environ.keys() and keys['W2PYENV'] == 'dev':
> con = 'sqlite....
> else:
> con = 'postgres
>
> By the way, I don't recommend this. SQLite and Postgres are not plug
> compatible and you may get surprised.
>
> On Wednesday, May 23, 2012 7:53:09 PM UTC-4, Jonathan Lundell wrote:
>>
>> On May 23, 2012, at 8:40 AM, Anthony wrote:
>>
>> If you use the built-in Rocket server in development but another server
>> (e.g., Apache, Nginx) on production, you could also do:
>>
>> if request.env.server_software.startswith('Rocket'):
>> con = 'sqlite://...'
>> etc.
>>
>>
>>
>> The only real problem with these schemes is that they tend to be
>> installation-dependent (not a fatal problem, but potentially tricky). You
>> *might* be using Rocket for production too, either directly (presumably
>> not a great idea) or behind mod_proxy, in which case the is_local test
>> would fail as well.
>>
>> This seems like a case (again) where it'd be nice to be able to drop a
>> line into a config file to set up the environment in an otherwise
>> configuration-independent way.
>>
>> Anthony
>>
>> On Wednesday, May 23, 2012 11:14:18 AM UTC-4, rochacbruno wrote:
>>>
>>> if request.is_local():
>>> con = "sqlite://....."
>>> else:
>>> con = "postgres://..."
>>>
>>> db = DAL(con)
>>>
>>> On Wed, May 23, 2012 at 12:06 PM, Jason Brower <[email protected]>
>>> wrote:
>>>
>>>> Locally I only want to use SQLite. And on the deployment I want to use
>>>> Postgres.
>>>> Is there a way to make this happen automatically?
>>>> BR,
>>>> Jason Brower
>>>>
>>>
>>
>>
>>