~ubuntu-branches/ubuntu/natty/tryton-server/natty-security

« back to all changes in this revision

Viewing changes to trytond/model/fields/binary.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann, Daniel Baumann, Mathias Behrle
  • Date: 2009-04-21 19:27:00 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090421192700-hmiosex03jt5qf01
Tags: 1.2.0-1
[ Daniel Baumann ]
* Merging upstream version 1.2.0.
* Tidy rules files.
* Updating version information in manpage.
* Updating copyright file for new upstream release.
* Including TODO file in docs.

[ Mathias Behrle ]
* Updating application description.

[ Daniel Baumann ]
* Correcting wrapping of control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#This file is part of Tryton.  The COPYRIGHT file at the top level of
 
2
#this repository contains the full copyright notices and license terms.
 
3
 
 
4
from trytond.model.fields.field import Field
 
5
 
 
6
 
 
7
class Binary(Field):
 
8
    '''
 
9
    Define a binary field (``str``)
 
10
    '''
 
11
    _type = 'binary'
 
12
 
 
13
    def get(self, cursor, user, ids, model, name, values=None, context=None):
 
14
        '''
 
15
        Convert the binary value into ``str``
 
16
 
 
17
        :param cursor: the database cursor
 
18
        :param user: the user id
 
19
        :param ids: a list of ids
 
20
        :param model: a string with the name of the model
 
21
        :param name: a string with the name of the field
 
22
        :param values: a dictionary with the readed values
 
23
        :param context: the context
 
24
        :return: a dictionary with ids as key and values as value
 
25
        '''
 
26
        if values is None:
 
27
            values = {}
 
28
        res = {}
 
29
        for i in values:
 
30
            res[i['id']] = i[name] and str(i[name]) or None
 
31
        for i in ids:
 
32
            res.setdefault(i, None)
 
33
        return res