~openerp-dev/openobject-client-web/6.0-opw-591397-xal

« back to all changes in this revision

Viewing changes to openobject/validators/_base.py

  • Committer: ame (Tiny)
  • Date: 2010-01-07 07:47:47 UTC
  • Revision ID: ame@tinyerp.com-20100107074747-sqc1cmm24gofqmuh
[REF] separating base API to openobject
[REF] removed all openerp related stuffs from base api

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
###############################################################################
 
2
#
 
3
# Copyright (C) 2007-TODAY Tiny ERP Pvt Ltd. All Rights Reserved.
 
4
#
 
5
# $Id$
 
6
#
 
7
# Developed by Tiny (http://openerp.com) and Axelor (http://axelor.com).
 
8
#
 
9
# The OpenERP web client is distributed under the "OpenERP Public License".
 
10
# It's based on Mozilla Public License Version (MPL) 1.1 with following
 
11
# restrictions:
 
12
#
 
13
# -   All names, links and logos of Tiny, Open ERP and Axelor must be
 
14
#     kept as in original distribution without any changes in all software
 
15
#     screens, especially in start-up page and the software header, even if
 
16
#     the application source code has been changed or updated or code has been
 
17
#     added.
 
18
#
 
19
# -   All distributions of the software must keep source code with OEPL.
 
20
#
 
21
# -   All integrations to any other software must keep source code with OEPL.
 
22
#
 
23
# If you need commercial licence to remove this kind of restriction please
 
24
# contact us.
 
25
#
 
26
# You can see the MPL licence at: http://www.mozilla.org/MPL/MPL-1.1.html
 
27
#
 
28
###############################################################################
 
29
 
 
30
from formencode.validators import *
 
31
from formencode.schema import Schema
 
32
from formencode.foreach import ForEach
 
33
 
 
34
 
 
35
class BaseValidator(FancyValidator):
 
36
    pass
 
37
 
 
38
 
 
39
class DefaultValidator(BaseValidator):
 
40
    pass
 
41
 
 
42
 
 
43
class Schema(Schema):
 
44
    """Modified Schema validator.
 
45
 
 
46
    A schema validates a dictionary of values, applying different validators
 
47
    (by key) to the different values.
 
48
 
 
49
    This modified Schema allows fields that do not appear in the fields
 
50
    parameter of your schema, but filters them out from the value dictionary.
 
51
    You might want to set filter_extra_fields to True when you're building a
 
52
    dynamic form with unpredictable keys and need these values.
 
53
 
 
54
    """
 
55
 
 
56
    filter_extra_fields = True
 
57
    allow_extra_fields = True
 
58
    if_key_missing = None
 
59
 
 
60
    def from_python(self, value, state=None):
 
61
        # The Schema shouldn't do any from_python conversion because
 
62
        # adjust_value already takes care of that for all childs.
 
63
        return value
 
64