Another solution is to use a list representation of those strings (inspired by Scheme syntax), example here: http://dpaste.org/ZJey/ This representation is of course more verbose (and more difficult to read for a human) that the current implementation but provides a solution that is easier to parse for non-python software. This would allow to interact easily with the Tryton server in any language (currently any external program need to understand strings like: "company' in context and '=' or '!=' ", "context.get('company')", etc).
As you can see the tree_eval fct is also easy to extend and as any other list of string it can be serialized with json, xml, etc. Bertrand On Dec 14, 4:15 pm, Cédric Krier <[email protected]> wrote: > To be more indepedent about the python on the client side, we should improve > the syntax of the evaluated strings. > > First, we need a syntax to represent data that is indepedent of Python and > that can handle list, dictionnary, string, number etc. > We thought about json which seems to be implemented in many languages and is > extendable. > Here is some examples: > > A domain from ir.action.act_window: > > [('parent', '=', False)] => [{'__class__': 'eval', 'v': "['parent', '=', > False]"}] > > A context from ir.action.act_window: > > {'company': company} => {'company': {'__class__': 'eval', 'v': "company > or False"}} > > A digits from a Float: > > (16, currency_digits) => {'__class__': 'eval', 'v': "[16, > currency_digits]"} > > A states like currency in account.invoice: > > bool(lines) => {'__class__': 'eval', 'v': "len(lines) and True > or False"} > > As you can see, we define a new class of object "eval" which represents the > strings > that must be evaluated on the client side. > > Second, we need an easy and simple syntax that can be implemented in other > languages. So we will restrict it to the use of: > > Type: > str, int/long, list > > Operators: > and, or > > Functions: > contains, getitem, len > > Functions could be added later depending of the needs. > > -- > Cédric Krier > > B2CK SPRL > Rue de Rotterdam, 4 > 4000 Liège > Belgium > Tel: +32 472 54 46 59 > Email: [email protected] > Jabber: [email protected] > Website:http://www.b2ck.com/ > twitter:http://twitter.com/cedrickrier > identi.ca:http://identi.ca/cedrickrier > > application_pgp-signature_part > < 1KViewDownload -- [email protected] mailing list
