web/propertysheet.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Dec 2015 17:44:16 +0100
changeset 10999 adc46197b8c9
parent 10899 e0abfc3b4a10
child 11434 f6ba947c11ee
permissions -rw-r--r--
[migration] test addition of a cube providing a custom final type This does not work yet. Related to #7569998
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5444
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
# copyright 2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
#
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
# This file is part of CubicWeb.
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
#
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     9
# any later version.
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    10
#
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    14
# details.
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
#
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
"""property sheets allowing configuration of the web ui"""
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
__docformat__ = "restructuredtext en"
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    22
import re
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    23
import os
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    24
import os.path as osp
10897
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    25
import tempfile
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    26
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    27
6000
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    28
TYPE_CHECKS = [('STYLESHEETS', list), ('JAVASCRIPTS', list),
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    29
               ('STYLESHEETS_IE', list), ('STYLESHEETS_PRINT', list),
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    30
               ]
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    31
5938
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    32
class lazystr(object):
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    33
    def __init__(self, string, context):
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    34
        self.string = string
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    35
        self.context = context
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    36
    def __str__(self):
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    37
        return self.string % self.context
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    38
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    39
5444
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    40
class PropertySheet(dict):
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    41
    def __init__(self, cache_directory, **context):
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    42
        self._cache_directory = cache_directory
5467
57372dbfd114 [https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5466
diff changeset
    43
        self.context = context
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    44
        self.reset()
5444
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    45
        context['sheet'] = self
5938
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    46
        context['lazystr'] = self.lazystr
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    47
        self._percent_rgx = re.compile('%(?!\()')
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    48
5938
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    49
    def lazystr(self, str):
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    50
        return lazystr(str, self)
9cb13d1b2ce4 [uiprops] introduce lazystr to get a chance to change style without having to change all properties
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5467
diff changeset
    51
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    52
    def reset(self):
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    53
        self.clear()
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    54
        self._ordered_propfiles = []
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    55
        self._propfile_mtime = {}
5444
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    56
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    57
    def load(self, fpath):
5467
57372dbfd114 [https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5466
diff changeset
    58
        scriptglobals = self.context.copy()
5444
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    59
        scriptglobals['__file__'] = fpath
10615
6c497fe389d2 [py3k] execfile → exec
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10614
diff changeset
    60
        with open(fpath, 'rb') as fobj:
6c497fe389d2 [py3k] execfile → exec
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10614
diff changeset
    61
            code = compile(fobj.read(), fpath, 'exec')
6c497fe389d2 [py3k] execfile → exec
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10614
diff changeset
    62
        exec(code, scriptglobals, self)
6000
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    63
        for name, type in TYPE_CHECKS:
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    64
            if name in self:
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    65
                if not isinstance(self[name], type):
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    66
                    msg = "Configuration error: %s.%s should be a %s" % (fpath, name, type)
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    67
                    raise Exception(msg)
10505
a9becf2cce8b [web] Stop using negative indices with os.stat results
Rémi Cardona <remi.cardona@logilab.fr>
parents: 8695
diff changeset
    68
        self._propfile_mtime[fpath] = os.stat(fpath).st_mtime
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    69
        self._ordered_propfiles.append(fpath)
5444
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    70
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    71
    def need_reload(self):
10662
10942ed172de [py3k] dict.iteritems → dict.items
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10615
diff changeset
    72
        for fpath, mtime in self._propfile_mtime.items():
10505
a9becf2cce8b [web] Stop using negative indices with os.stat results
Rémi Cardona <remi.cardona@logilab.fr>
parents: 8695
diff changeset
    73
            if os.stat(fpath).st_mtime > mtime:
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    74
                return True
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    75
        return False
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    76
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    77
    def reload(self):
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    78
        ordered_files = self._ordered_propfiles
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    79
        self.reset()
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    80
        for fpath in ordered_files:
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    81
            self.load(fpath)
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    82
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    83
    def reload_if_needed(self):
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    84
        if self.need_reload():
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    85
            self.reload()
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    86
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    87
    def process_resource(self, rdirectory, rid):
10897
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    88
        cachefile = osp.join(self._cache_directory, rid)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    89
        self.debug('processing %s/%s into %s',
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    90
                   rdirectory, rid, cachefile)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    91
        rcachedir = osp.dirname(cachefile)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    92
        if not osp.exists(rcachedir):
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    93
            os.makedirs(rcachedir)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    94
        sourcefile = osp.join(rdirectory, rid)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    95
        with open(sourcefile) as f:
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    96
            content = f.read()
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    97
        # XXX replace % not followed by a paren by %% to avoid having to do
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    98
        # this in the source css file ?
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
    99
        try:
10897
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   100
            content = self.compile(content)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   101
        except ValueError as ex:
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   102
            self.error("can't process %s/%s: %s", rdirectory, rid, ex)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   103
            adirectory = rdirectory
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   104
        else:
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   105
            tmpfd, tmpfile = tempfile.mkstemp(dir=rcachedir, prefix=osp.basename(cachefile))
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   106
            with os.fdopen(tmpfd, 'w') as stream:
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
   107
                stream.write(content)
10897
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   108
            os.rename(tmpfile, cachefile)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   109
            adirectory = self._cache_directory
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   110
        return adirectory
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
   111
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
   112
    def compile(self, content):
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
   113
        return self._percent_rgx.sub('%%', content) % self
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
   114
7083
b8e35cde46e9 help pylint by explicitely defining some attributes
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6000
diff changeset
   115
    # these are overridden by set_log_methods below
b8e35cde46e9 help pylint by explicitely defining some attributes
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6000
diff changeset
   116
    # only defining here to prevent pylint from complaining
b8e35cde46e9 help pylint by explicitely defining some attributes
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6000
diff changeset
   117
    info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None
b8e35cde46e9 help pylint by explicitely defining some attributes
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6000
diff changeset
   118
5445
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
   119
from cubicweb.web import LOGGER
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
   120
from logilab.common.logging_ext import set_log_methods
4467ed43d97d [web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5444
diff changeset
   121
set_log_methods(PropertySheet, LOGGER)