Tryton RESTful server

176 views
Skip to first unread message

Sharoon Thomas

unread,
May 10, 2014, 9:36:22 AM5/10/14
to tryton-...@googlegroups.com
Hello folks,

We have released version 0.1 of Tryton Restful [1], a simple wsgi app that
allows you to use your favorite rest/http clients to talk to Tryton models.

The README [2] includes a few examples using the popular requests
python library.

Feel free to fork and contribute


Happy hacking,


Sharoon Thomas
CEO & Chief Software Architect
Openlabs Technologies & Consulting (P) Limited

w: http://www.openlabs.co.in
m: +1 813.793.6736 (OPEN) Extn. 200
t: @sharoonthomas 

- We win when our customers win

signature.asc

Cédric Krier

unread,
May 10, 2014, 11:00:13 AM5/10/14
to tryton-...@googlegroups.com
On 10 May 19:06, Sharoon Thomas wrote:
> Hello folks,
>
> We have released version 0.1 of Tryton Restful [1], a simple wsgi app that
> allows you to use your favorite rest/http clients to talk to Tryton models.

I don't understand why not re-use flask-tryton [1] nor a flask
authentication plugin like flask-login [2].
Also I see you are using jsonify, how do you deal with tryton data
type that are not jsonable like datetime?
I think it will be better for security to cast record_id to int.

[1] https://pypi.python.org/pypi/flask_tryton
[2] https://pypi.python.org/pypi/Flask-Login

--
Cédric Krier - B2CK SPRL
Email/Jabber: cedric...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Sharoon Thomas

unread,
May 10, 2014, 1:09:33 PM5/10/14
to Cédric Krier, tryton-...@googlegroups.com

On May 10, 2014, at 8:30 PM, Cédric Krier <cedric...@b2ck.com> wrote:

> On 10 May 19:06, Sharoon Thomas wrote:
>> Hello folks,
>>
>> We have released version 0.1 of Tryton Restful [1], a simple wsgi app that
>> allows you to use your favorite rest/http clients to talk to Tryton models.
>
> I don't understand why not re-use flask-tryton [1] nor a flask
> authentication plugin like flask-login [2].

I had tried using flask-tryton and the primary issue with it it’s dependence on
a single database. The transaction decorator in flask-tryton was the most
motivating reason to use it and the design of transaction decorator in
tryton restful is based on that.

Flask-Login is an overkill for the situation because:

1. tryton restful has no session (cookie) support. It requires ir.session id to be sent on every request
just as the tryton client would do. Flask-Login is heavily designed around sessions (nereid
uses this).
2. In addition this requires a User object which implements the User Mixin [1] for current_use local
proxy to work. While, tryton-restful only needs the ID of the currently logged in user.
3. There is no login_view etc. which a regular browser based app would need and flask-login is
designed for.


> Also I see you are using jsonify, how do you deal with tryton data
> type that are not jsonable like date time?

Updated the code to use the tryton encoder and decoder.

Do you plan on making the javascript version of tryton json encode/decoder available as a
separate library ?

> I think it will be better for security to cast record_id to int.

Fixed.

Thanks for your feedback.

[1] http://flask-login.readthedocs.org/en/latest/#your-user-class
signature.asc

Cédric Krier

unread,
May 10, 2014, 2:26:37 PM5/10/14
to tryton-...@googlegroups.com
On 10 May 22:39, Sharoon Thomas wrote:
>
> On May 10, 2014, at 8:30 PM, Cédric Krier <cedric...@b2ck.com> wrote:
>
> > On 10 May 19:06, Sharoon Thomas wrote:
> >> Hello folks,
> >>
> >> We have released version 0.1 of Tryton Restful [1], a simple wsgi app that
> >> allows you to use your favorite rest/http clients to talk to Tryton models.
> >
> > I don't understand why not re-use flask-tryton [1] nor a flask
> > authentication plugin like flask-login [2].
>
> I had tried using flask-tryton and the primary issue with it it’s dependence on
> a single database. The transaction decorator in flask-tryton was the most
> motivating reason to use it and the design of transaction decorator in
> tryton restful is based on that.

flask-tryton is on purpose not multi-database because:

- it just adds complexity for no benefit
("Simple is better than complex.")
- it is slower, trytond has to manage a lots of locks to be safe for
database creation and drop

I bet that one day we will remove the multi-database from trytond. But
before that, we have to improve the command line of trytond to be able
to do everything done from the client on database management. I see only
1 point the installation of module.

> Flask-Login is an overkill for the situation because:
>
> 1. tryton restful has no session (cookie) support. It requires ir.session id to be sent on every request
> just as the tryton client would do. Flask-Login is heavily designed around sessions (nereid
> uses this).

But it is a session and it could be a cookie.

> 2. In addition this requires a User object which implements the User Mixin [1] for current_use local
> proxy to work. While, tryton-restful only needs the ID of the currently logged in user.

Not a real issue.

> 3. There is no login_view etc. which a regular browser based app would need and flask-login is
> designed for.

Flask-Login was just a suggestion, there are many others extension for
authentication.

> > Also I see you are using jsonify, how do you deal with tryton data
> > type that are not jsonable like date time?
>
> Updated the code to use the tryton encoder and decoder.
>
> Do you plan on making the javascript version of tryton json encode/decoder available as a
> separate library ?

rpc.js is almost a library.

Raimon Esteve

unread,
May 11, 2014, 3:22:04 AM5/11/14
to tryton-...@googlegroups.com

> I bet that one day we will remove the multi-database from trytond.

IMHO is regresition feature. I know users to manage multidatabase and one trytond server (same port to connect multidatabases)
Ñ
5 cents

Cédric Krier

unread,
May 11, 2014, 4:40:23 AM5/11/14
to tryton-...@googlegroups.com
And for me it will be a major improvement.

Sharoon Thomas

unread,
May 12, 2014, 3:37:04 AM5/12/14
to Cédric Krier, tryton-...@googlegroups.com

On May 11, 2014, at 2:10 PM, Cédric Krier <cedric...@b2ck.com> wrote:

> On 11 May 09:22, Raimon Esteve wrote:
>>> I bet that one day we will remove the multi-database from trytond.
>>
>> IMHO is regresition feature. I know users to manage multidatabase and one
>> trytond server (same port to connect multidatabases)
>
> And for me it will be a major improvement.

Can you explain what your thoughts are ?
If you have said this before, perhaps a link ?

Thanks & Regards

Sharoon Thomas
signature.asc

Cédric Krier

unread,
May 12, 2014, 4:02:39 AM5/12/14
to tryton-...@googlegroups.com
It adds complexity for no benefit. Multi-DB is a infrastructure problem
which tries to solve it at the programming level. A lot of things will
be easier and faster without it.
Also removal will fix this for example:
https://bugs.tryton.org/issue3360
Otherwise there are no other easy fix.

Raimon Esteve

unread,
May 12, 2014, 4:41:58 AM5/12/14
to tryton-...@googlegroups.com
> https://bugs.tryton.org/issue3360

You are not allowed to view this page.




--
Raimon Esteve
// Tryton y OpenERP en la nube: http://www.zzsaas.com
// Documentación: http://doc.zzsaas.com
www.zikzakmedia.com

Sergi Almacellas Abellana

unread,
May 12, 2014, 4:49:25 AM5/12/14
to tryton-...@googlegroups.com
El 10/05/14 15:36, Sharoon Thomas ha escrit:
> Hello folks,
>
> We have released version 0.1 of Tryton Restful [1], a simple wsgi app that
> allows you to use your favorite rest/http clients to talk to Tryton
> models.
Just for curiosity, do you use (or plan to use) it with restangular [1] ?



[1] https://github.com/mgonto/restangular

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Cédric Krier

unread,
May 12, 2014, 4:49:44 AM5/12/14
to tryton-...@googlegroups.com
On 12 May 10:41, Raimon Esteve wrote:
> > https://bugs.tryton.org/issue3360
>
> You are not allowed to view this page.

It is a security issue.

Raimon Esteve

unread,
May 12, 2014, 5:10:21 AM5/12/14
to tryton-...@googlegroups.com
2014-05-12 10:49 GMT+02:00 Cédric Krier <cedric...@b2ck.com>:
On 12 May 10:41, Raimon Esteve wrote:
> > https://bugs.tryton.org/issue3360
>
> You are not allowed to view this page.

It is a security issue.

Ok. Not all could read it?

Sharoon Thomas

unread,
May 12, 2014, 5:35:15 AM5/12/14
to Sergi Almacellas Abellana, tryton-...@googlegroups.com

On May 12, 2014, at 2:19 PM, Sergi Almacellas Abellana <se...@koolpi.com> wrote:

> El 10/05/14 15:36, Sharoon Thomas ha escrit:
>> Hello folks,
>>
>> We have released version 0.1 of Tryton Restful [1], a simple wsgi app that
>> allows you to use your favorite rest/http clients to talk to Tryton models.
> Just for curiosity, do you use (or plan to use) it with restangular [1] ?
>
> [1] https://github.com/mgonto/restangular

Yes,

At the moment it would not work out of the box with restangular, but future versions
should.

Thanks & regards

Sharoon Thomas

signature.asc

Guillem Barba Domingo

unread,
May 12, 2014, 2:40:20 PM5/12/14
to tryton-...@googlegroups.com


El 12/05/2014 10:49, "Cédric Krier" <cedric...@b2ck.com> va escriure:


>
> On 12 May 10:41, Raimon Esteve wrote:
> > > https://bugs.tryton.org/issue3360
> >
> > You are not allowed to view this page.
>
> It is a security issue.

Can you make us a summary of the issue to follow the debate?

Reply all
Reply to author
Forward
0 new messages