Tried 2.09 nightly build on a completely different (redhat) server and still getting redirect, while post works as expected on a local rocket.
Any hint where to look for a problem please? using: curl --user [email protected]:pass -d "FirstName=Tim5&LastName=Json"http ://crm.domain.com/api/customer.json You are being redirected <a href="/crm/default/user/login?_next=/crm/webservices/api/customer.json Thanks, Adnan On Wed, Oct 10, 2012 at 10:46 AM, Adi <[email protected]> wrote: > This is an example from book, where authentication and posting into > database work good on a local server. > > Once I moved the code to production redhat linux server, where we have > routes.py as bellow all I get as result is a login redirect: > You are being redirected <a href= > "/user/login?_next=/webservices/api/customer.json%3FFirstName%3DTim5%26LastName%3DJson" > >here</a> > > If I remove authentication (@auth.requires_login() and > @auth.requires_permission('insert customer through webservice')) on > production server, records are inserted properly. > > Tried adding default and webservices controllers into application specific > routes.py, but it didn't help. > > Any suggestions what should I do? > > Thanks, > Adnan > > tried in both, default.py and webservices.py controllers: > > auth.settings.allow_basic_login = True > @auth.requires_login() > @auth.requires_permission('insert customer through webservice') > @request.restful() > def api(): > response.view = 'generic.'+request.extension > > def GET(*args,**vars): > patterns = [ > "/members[customer]", > "/member_fn/{customer.FirstName.startswith}", > "/member_ln/{customer.LastName.startswith}", > "/member/{customer.FirstName}/:field", > > "/member/{customer.FirstName}/orders[customer_order.customer_id]", > > "/member/{customer.FirstName}/order[customer_order.customer_id]/{ > customer_order.id}", > > "/member/{customer.FirstName}/order[customer_order.customer_id]/{ > customer_order.id}/:field" > ] > parser = db.parse_as_rest(patterns,args,vars) > if parser.status == 200: > return dict(content=parser.response) > else: > raise HTTP(parser.status,parser.error) > def POST(table_name,**vars): > if table_name == 'customer': > return db.customer.validate_and_insert(**vars) > elif table_name == 'customer_order': > return db.customer_order.validate_and_insert(**vars) > else: > raise HTTP(400) > return locals() > > > > > > web2py folder: routes.py > routers = dict( > # base router > BASE = dict( > default_application = 'welcome', domains = {'crm.domain.com': > 'crm' } > ), > ) > > > > crm app folder: routes.py (deleted) > > > Terminal test: > > > asm21:~ adnan$ curl --user [email protected]:pass -d > "FirstName=Tim5&LastName=Json" http://crm.domain.com/api/customer.json > Result: You are being redirected <a href= > "/user/login?_next=/api/customer.json%3FFirstName%3DTim5%26LastName%3DJson" > >here</a> > > asm21:~ adnan$ curl --user [email protected]:pass -d > "FirstName=Tim5&LastName=Json" http://crm.domain.com/webservices/api/ > customer.json > Result: You are being redirected <a href= > "/user/login?_next=/webservices/api/customer.json%3FFirstName%3DTim5%26LastName%3DJson" > >here</a> > > > > > > --

