import openerpweb.ast
import openerpweb.nonliterals
+from babel.messages.pofile import read_po
# Should move to openerpweb.Xml2Json
class Xml2Json:
'css': css
}
return r
+
+ @openerpweb.jsonrequest
+ def translations(self, req, mods, lang):
+ transs = {}
+ for addon_name in mods:
+ transl = {"messages":[]}
+ transs[addon_name] = transl
+ f_name = os.path.join(openerpweb.path_addons, addon_name, "po", lang + ".po")
+ if not os.path.exists(f_name):
+ continue
+ try:
+ with open(f_name) as t_file:
+ po = read_po(t_file)
+ except:
+ continue
+ for x in po:
+ if x.id:
+ transl["messages"].append({'id': x.id, 'string': x.string})
+ return {"modules": transs}
+
class Database(openerpweb.Controller):
_cp_path = "/base/database"
@openerpweb.jsonrequest
def login(self, req, db, login, password):
req.session.login(db, login, password)
+ ctx = req.session.get_context()
return {
"session_id": req.session_id,
"uid": req.session._uid,
+ "context": ctx
}
@openerpweb.jsonrequest
""" Parses an arbitrary string containing a domain, transforms it
to either a literal domain or a :class:`openerpweb.nonliterals.Domain`
- :param domain: the domain to parse, if the domain is not a string it is assumed to
- be a literal domain and is returned as-is
+ :param domain: the domain to parse, if the domain is not a string it
+ is assumed to be a literal domain and is returned as-is
:param session: Current OpenERP session
:type session: openerpweb.openerpweb.OpenERPSession
"""
""" Parses an arbitrary string containing a context, transforms it
to either a literal context or a :class:`openerpweb.nonliterals.Context`
- :param context: the context to parse, if the context is not a string it is assumed to
- be a literal domain and is returned as-is
+ :param context: the context to parse, if the context is not a string it
+ is assumed to be a literal domain and is returned as-is
:param session: Current OpenERP session
:type session: openerpweb.openerpweb.OpenERPSession
"""