~txerpa-openerp/openobject-client-web/txerpa

« back to all changes in this revision

Viewing changes to addons/openerp/validators.py

  • Committer: Biel - txerpa.com
  • Date: 2013-08-09 12:30:58 UTC
  • mfrom: (4670.2.245 openobject-client-web)
  • Revision ID: biel.massot@txerpa.com-20130809123058-892zu673ti1j8yjd
Actualizo a la ultima revision de trunk. Hay muchos bugs correjidos desde 2012. Elimino la revision 4873 por problemas de rendimiento en el dashboard de Contabilidad

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import re
26
26
import time
27
27
 
 
28
BINARY_FIELD_STORAGE_CLASS = cgi.FieldStorage
 
29
try:
 
30
    # binary data send/get with cherrypy >= 3.2.X
 
31
    # are wrapper inside 'Part' class
 
32
    from cherrypy._cpreqbody import Part
 
33
    BINARY_FIELD_STORAGE_CLASS = ( cgi.FieldStorage, Part )
 
34
except ImportError:
 
35
    pass
 
36
 
28
37
import formencode.validators
29
38
import formencode.api
30
39
 
159
168
        if isinstance(value, list):
160
169
            value = value[0]
161
170
 
162
 
        if isinstance(value, cgi.FieldStorage):
 
171
        if isinstance(value, BINARY_FIELD_STORAGE_CLASS):
163
172
            if value.filename:
164
173
                return base64.encodestring(value.file.read())
165
174
            elif self.not_empty:
206
215
 
207
216
class many2many(BaseValidator):
208
217
 
209
 
    if_empty = [(6, 0, [])]
 
218
    @property
 
219
    def if_empty(self):
 
220
        return [(6, 0, [])]
210
221
 
211
222
    def _to_python(self, value, state):
212
223
 
239
250
    
240
251
class one2many(formencode.validators.FancyValidator):
241
252
    
242
 
    if_empty = []
 
253
    @property
 
254
    def if_empty(self):
 
255
        return []
243
256
 
244
257
 
245
258
# Let some FormEncode strings goes into message catalog.