web/propertysheet.py
author Julien Cristau <julien.cristau@logilab.fr>
Mon, 23 Nov 2015 17:58:10 +0100
changeset 10897 7c386161ebd6
parent 10686 a08d5a657836
child 10899 e0abfc3b4a10
permissions -rw-r--r--
[web] remove PropertySheet._cache Instead of remembering that a css file has been processed, we re-process it at every request. This prevents our cache getting out of date with the file system. Closes #6893185 While we're at it, write the file atomically so that we don't risk serving partial data.
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 = {}
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
    56
        self._sourcefile_mtime = {}
5444
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    57
f7fdb5dd82f6 [webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    58
    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
    59
        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
    60
        scriptglobals['__file__'] = fpath
10615
6c497fe389d2 [py3k] execfile → exec
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10614
diff changeset
    61
        with open(fpath, 'rb') as fobj:
6c497fe389d2 [py3k] execfile → exec
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10614
diff changeset
    62
            code = compile(fobj.read(), fpath, 'exec')
6c497fe389d2 [py3k] execfile → exec
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10614
diff changeset
    63
        exec(code, scriptglobals, self)
6000
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    64
        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
    65
            if name in self:
98ca82aae3a1 [uiprops] check that STYLESHEETS* and JAVASCRIPTS are lists
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5938
diff changeset
    66
                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
    67
                    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
    68
                    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
    69
        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
    70
        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
    71
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
    72
    def need_reload(self):
10662
10942ed172de [py3k] dict.iteritems → dict.items
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10615
diff changeset
    73
        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
    74
            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
    75
                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
    76
        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
    77
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
    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
    79
        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
    80
        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
    81
        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
    82
            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
    83
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
    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
    85
        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
    86
            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
    87
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
    88
    def process_resource(self, rdirectory, rid):
10897
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    89
        cachefile = osp.join(self._cache_directory, rid)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    90
        self.debug('processing %s/%s into %s',
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    91
                   rdirectory, rid, cachefile)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    92
        rcachedir = osp.dirname(cachefile)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    93
        if not osp.exists(rcachedir):
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    94
            os.makedirs(rcachedir)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    95
        sourcefile = osp.join(rdirectory, rid)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    96
        with open(sourcefile) as f:
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    97
            content = f.read()
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
    98
        # 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
    99
        # 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
   100
        try:
10897
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   101
            content = self.compile(content)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   102
        except ValueError as ex:
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   103
            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
   104
            adirectory = rdirectory
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   105
        else:
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   106
            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
   107
            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
   108
                stream.write(content)
10897
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   109
            os.rename(tmpfile, cachefile)
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   110
            adirectory = self._cache_directory
7c386161ebd6 [web] remove PropertySheet._cache
Julien Cristau <julien.cristau@logilab.fr>
parents: 10686
diff changeset
   111
        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
   112
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
    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
   114
        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
   115
7083
b8e35cde46e9 help pylint by explicitely defining some attributes
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6000
diff changeset
   116
    # 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
   117
    # 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
   118
    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
   119
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
   120
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
   121
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
   122
set_log_methods(PropertySheet, LOGGER)