import logging 

from pylons import tmpl_context as c, config

from .. import helpers as h
from ..cache import memoize

log = logging.getLogger(__name__)

class BaseTile(object):
    
    @classmethod
    def prop_has_perm(cls, perm):
        return lambda self: h.has_permission(perm)


from time import time

def render_tile(template_name, def_name, tile, cached=False, **kwargs):
    from .. import templating 
    begin_time = time()
    render = lambda: templating.render_def(template_name, def_name, tile=tile, **kwargs)
    rendered = ""
    if cached and config.get('adhocracy.cache_tiles', True):
        @memoize('tile_cache' + template_name + def_name, 84600/4)
        def _cached(**kwargs):
            return render()
        rendered = _cached(locale=c.locale, **kwargs)
    else:
        rendered = render()
    #log.debug("Rendering tile %s:%s took %sms" % (template_name, def_name, (time()-begin_time)*1000))
    return rendered
@@ -7,17 +7,38 @@
  logging
- 
+%0Afrom time import time
 %0A%0Afrom p
@@ -86,37 +86,21 @@
 rom 
-.. import helpers as h%0Afrom .
+adhocracy.lib
 .cac
@@ -153,16 +153,17 @@
 ame__)%0A%0A
+%0A
 class Ba
@@ -186,134 +186,45 @@
     
+'''
 %0A    
-@classmethod%0A    def prop_has_perm(cls, perm):%0A        return lambda self: h.has_permission(perm)%0A%0A%0Afrom time import time
+Base class for tiles%0A    '''%0A
 %0A%0Ade
@@ -306,10 +306,21 @@
 rom 
-..
+adhocracy.lib
  imp
@@ -333,17 +333,16 @@
 mplating
- 
 %0A    beg
@@ -362,28 +362,41 @@
 e()%0A
+%0A
     
+def 
 render
- = lambda:
+():%0A        return
  tem
@@ -434,24 +434,61 @@
 e, def_name,
+%0A                                    
  tile=tile, 
@@ -643,9 +643,11 @@
 4600
-/
+ / 
 4)%0A 
@@ -800,13 +800,31 @@
 r()%0A
+%0A
     
-#
+if False:%0A        
 log.
@@ -865,16 +865,29 @@
 sms%22 %25 (
+%0A            
 template
@@ -914,9 +914,11 @@
 me()
--
+ - 
 begi
@@ -928,16 +928,19 @@
 ime)
-*
+ * 
 1000))%0A
+%0A
     
@@ -946,16 +946,17 @@
  return rendered
+%0A

Remove unused method BaseTile.prop_has_perm()