Navigation Menu

Skip to content

Commit

Permalink
using production mode from environment, use the same for writerep too
Browse files Browse the repository at this point in the history
  • Loading branch information
asldevi committed Oct 13, 2008
1 parent b9e969d commit 2dba2db
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config.py
Expand Up @@ -3,5 +3,5 @@
#from address in mails sent by watchdog
from_address = '"watchdog.net" <info@watchdog.net>'
maildir_path = '/home/wathdog/Maildir'
production_site = False
send_errors_to = 'bugs@watchdog.net'
test_email = 'test@watchdog.net' #wyr test emails to go to this
1 change: 1 addition & 0 deletions settings.py
Expand Up @@ -6,6 +6,7 @@
render_plain = web.template.render('templates/') #without base, useful for sending mails
db = web.database(dbn=os.environ.get('DATABASE_ENGINE', 'postgres'),
db=os.environ.get('WATCHDOG_TABLE', 'watchdog_dev'))
production_mode = os.environ.get('PRODUCTION_MODE', False)

#@@@@ is temp directory really okay for sessions??
sess_store = tempfile.mkdtemp()
Expand Down
15 changes: 7 additions & 8 deletions utils/writerep.py
Expand Up @@ -12,13 +12,12 @@

import web
import captchasolver, forms, helpers, auth
from settings import db, render
from settings import db, render, production_mode
from users import fill_user_details, update_user_details
from wyrutils import * #@@@ put all the list here
from config import test_email

PRODUCTION_MODE = False
TEST_MODE = (not PRODUCTION_MODE) and True
TEST_EMAIL = 'test@watchdog.net'
test_mode = (not production_mode)

urls = (
'', 'redir',
Expand Down Expand Up @@ -57,10 +56,10 @@ def writerep_email(pol_email, pol, zipcode, state, prefix, fname, lname,
name = '%s. %s %s' % (prefix, fname, lname)
from_addr = '%s <%s>' % (name, email)

if PRODUCTION_MODE:
if production_mode:
to_addr = pol_email.lstrip('mailto:')
elif TEST_MODE:
to_addr = TEST_EMAIL
elif test_mode:
to_addr = test_email
#@@@@ msg has to be composed
web.sendmail(from_addr, to_addr, subject, msg)
return True
Expand Down Expand Up @@ -318,7 +317,7 @@ def get_from_input(self, key, input=None):
return input.get(k)
def POST(self):
i = web.input()
to_addr = TEST_EMAIL
to_addr = test_email
from_addr = self.get_from_input('email', i) or ''
subject = self.get_from_input('issue', i) or ''
msg = self.get_from_input('message', i) or ''
Expand Down
6 changes: 3 additions & 3 deletions utils/wyrutils.py
Expand Up @@ -126,11 +126,11 @@ def __getattr__(self, x):
return getattr(self.f, x)

def production_click(self):
from writerep import PRODUCTION_MODE, TEST_MODE
if PRODUCTION_MODE:
from writerep import production_mode, test_mode
if production_mode:
request = self.f.click()
response = urlopen(request.get_full_url(), request.get_data())
elif TEST_MODE:
elif test_mode:
self.f.action = web.ctx.homedomain + '/writerep/test'
request = self.f.click()
response = urlopen(request.get_full_url(), request.get_data())
Expand Down
4 changes: 2 additions & 2 deletions webapp.py
Expand Up @@ -7,7 +7,7 @@
import blog
import petition
import settings
from settings import db, render
from settings import db, render, production_mode
import schema
import config

Expand Down Expand Up @@ -338,7 +338,7 @@ def GET(self, path):
return file('data/' + path).read()

app = web.application(urls, globals())
if config.production_site:
if production_mode:
app.internalerror = web.emailerrors(config.send_errors_to, web.debugerror)
settings.setup_session(app)

Expand Down

0 comments on commit 2dba2db

Please sign in to comment.