First release of Proteus

ced cedric.krier at b2ck.com
Mon Jan 3 20:05:26 CET 2011


Proteus is a Python library to access Tryton [1] server.  (Tryton is a
three-tiers high-level general purpose application platform)

It can be used through XML-RPC or by using trytond as module and
provides an
Active Record pattern enabling you to interact pythonically with your
Tryton
server.

Its common usages are:
    - scripting for automatic actions
    - scenario testing
    - automatic setup
    - basement for a CLI (with iPython, bpython etc.)
    - basement for a minimal client

Here is some example usage:

At first you import the necessary functions

    >>> from proteus import config, Model, Wizard

Then you can create a database and install the `party` module into it

    >>> config = config.set_trytond(':memory:',
database_type='sqlite')
    >>> Module = Model.get('ir.module.module')
    >>> party, = Module.find([('name', '=', 'party')])
    >>> Module.button_install([party.id], config.context)
    >>> Wizard('ir.module.module.install_upgrade').execute('start')

We will then create a party, set her name and even her language

    >>> Party = Model.get('party.party')
    >>> party = Party()
    >>> party.name = 'ham'
    >>> party.save()
    >>> party.name
    u'ham'
    >>> party.id > 0
    True

Notice how addresses (which are a One2Many field for the party model)
are
handled just like Python list objects:

    >>> Address = Model.get('party.address')
    >>> address = Address()
    >>> party.addresses.append(address)
    >>> party.save()
    >>> party.addresses #doctest: +ELLIPSIS
    [proteus.Model.get('party.address')(...)]

More on http://pypi.python.org/pypi/proteus/1.8.0

[1] http://www.tryton.org/


More information about the Python-announce-list mailing list