Hi,
For some reason the final redirect comand in saveAddCea() does not
seem to work in my production envirenment:
@expose(template="projects.templates.commitment.addCommitment")
@require(predicates.in_any_group('admin','mgr','pm',
msg='Unauthorised Access'))
def add(self, projectfundingid=0, *args, **kw):
"""Display the add commitment form."""
try:
pf =
DBSession.query(ProjectFunding).filter(ProjectFunding.projectfundingid==int(projectfundingid)).one()
except:
pf =
DBSession.query(ProjectFunding).filter(ProjectFunding.projectfundingid==int(kw['projectfundingid'])).one()
r = 0
sites = []
if pylons.c.form_errors and kw['resource'] and
int(kw['resource'] > 0):
try:
r =
DBSession.query(Resource).filter(Resource.resourceid==int(kw['resource'])).one()
sites = DBSession.query(Site.siteid,
Site.name).filter(Site.resourceid==r.resourceid).all()
except:
flash(_('Unable to retrieve resource details!'),
'error')
redirect(url('/commitment'))
sites.insert(0,['',''])
resources = DBSession.query(Resource.resourceid,
Resource.name).order_by(Resource.name).all()
resources.insert(0,['',''])
currencies = [[c.currencyid, '%s (%s)' % (c.code, c.rate)] for
c in pf.currencies]
currencies.insert(0,['',''])
if pf.cea:
tmpl_context.form = addCeaCommitmentForm
type = 'cea'
else:
tmpl_context.form = addOpexCommitmentForm
type = 'opex'
return dict(sites=sites, group='project', pg='addCommitment',
msee='show', projectfunding=pf, currencies=currencies,
resources=resources, type=type,
value={'projectfundingid':pf.projectfundingid, 'currencyid':0})
@validate(form=addCeaCommitmentForm, error_handler=add)
@expose()
@require(predicates.in_any_group('admin','mgr','pm',
msg='Unauthorised Access'))
def saveAddCea(self, **kw):
"""Handle submission from the add commitment form and save the
commitment record."""
try:
currency =
DBSession.query(Currency).filter(Currency.currencyid==int(kw['currency'])).one()
site =
DBSession.query(Site).filter(Site.siteid==int(kw['site'])).one()
task =
DBSession.query(Task).filter(Task.taskid==int(kw['task'])).one()
organisation =
app_globals.get_organisation(kw['organisation'])
except:
flash(_('Unable to retrieve commitment details!'),
'error')
redirect(url('/commitment'))
commitment = Commitment()
commitment.contractref = kw['contractref']
commitment.amount = round(float(kw['amount']), 2)
commitment.description = kw['description']
commitment.taxcode = app_globals.get_taxCode(kw['tax'])
commitment.datecommited = kw['datecommited']
commitment.organisation = organisation
commitment.site = site
commitment.currency = currency
commitment.task = task
DBSession.add(commitment)
try:
DBSession.flush()
except:
DBSession.rollback()
flash(_('Unable to add commitment!'), 'error')
redirect(url('/commitment'))
flash(_('Commitment has been added'), 'ok')
redirect(url('/projectfunding/display/%d' %
(commitment.currency.projectfunding.projectfundingid)))
This code works fine in development, however when I try it in
production the page never gets redirected after the record has been
saved. There is no exception, just "The page cannot be displayed".
Does anyone recognise any issues with this code? FYI - the form has tw
widgets CascadingSingleSelectField and SingleSelectField (if that's
relevant).
Rgds,
Michael
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.