On Feb 6, 2011, at 4:47 PM, Gabriel wrote:
>
> Hi, I have this json service:
>
> app/default.py
> ...
> @service.json
> def create(model, fields):
> return dict(id=get_model_or_404(model).insert(**json.loads(fields)))
>
> and I am trying to map this:
>
> routes_in = (
> ('/service/$model/create', '/app/default/call/json/create?model=
> $model'),
> )
>
> With this I'd want to do:
>
> curl --data-urlencode 'fields={"name": "test"}' "http://localhost:8000/
> app/person/create"
>
> and in the create function get model="person" and in fields='{"name":
> "test"}'
> But it does not work, it is redirecting to default page.
> In httpserver.log I get
>
> 127.0.0.1, 2011-02-06 20:41:12, POST, , HTTP/1.1, 200, 0.330055
>
> If I do:
> curl --data-urlencode 'fields={"name": "test"}' "http://localhost:
> 8000/app/default/call/json/create?model=person"
> it works, so I think the problem is the routing.
>
> Any help about what I'm doing wrong?
Is it as simple as 'app' in your incoming URL not matching 'service' in the
routes pattern?
> Thanks for advance.