~openerp-dev/openobject-client-web/trunk-bug-733089-jra

« back to all changes in this revision

Viewing changes to addons/openerp/controllers/utils.py

  • Committer: Xavier Morel
  • Date: 2011-03-17 10:57:00 UTC
  • Revision ID: xmo@openerp.com-20110317105700-ldgi8by0chijxy9l
[FIX] database filters: don't match on whole domain, only its first section (e.g. subdomain)

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
    dbfilter = cherrypy.request.app.config['openerp-web'].get('dblist.filter')
46
46
    if dbfilter:
47
 
        hostname = urlparse.urlsplit(cherrypy.request.base).hostname
 
47
        base, _ = urlparse.urlsplit(cherrypy.request.base)\
 
48
                    .hostname.split('.', 1)
48
49
 
49
50
        if dbfilter == 'EXACT':
50
51
            if dblist is None:
51
 
                db = hostname
 
52
                db = base
52
53
                dblist = [db]
53
54
            else:
54
 
                dblist = [d for d in dblist if d == hostname]
 
55
                dblist = [d for d in dblist if d == base]
55
56
 
56
57
        elif dbfilter == 'UNDERSCORE':
57
 
            base = hostname + '_'
58
58
            if dblist is None:
59
 
                if db and not db.startswith(base):
 
59
                if db and not db.startswith(base + '_'):
60
60
                    db = None
61
61
            else:
62
 
                dblist = [d for d in dblist if d.startswith(base)]
 
62
                dblist = [d for d in dblist if d.startswith(base + '_')]
63
63
 
64
64
        elif dbfilter == 'BOTH':
65
65
            if dblist is None:
66
 
                if db and db != hostname and not db.startswith(hostname + '_'):
 
66
                if db and db != base and not db.startswith(base + '_'):
67
67
                    db = None
68
68
            else:
69
 
                dblist = [d for d in dblist if d.startswith(hostname + '_') or d == hostname]
 
69
                dblist = [d for d in dblist if d.startswith(base + '_') or d == base]
70
70
 
71
71
    info = None
72
72
    try: