Conjunto de mudanças 6536 no repositório publico


Ignorar:
Timestamp:
21/06/2012 00:46:34 (9 anos atrás)
Autor:
mazza
Mensagem:

refatoracao: TemplateAware? eliminada, uma funcao basta

Localização:
PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis
Arquivos:
2 editados

Legenda:

Não Modificado
Adicionado
Removido
  • PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis/browser/boxes/manager.py

    r6535 r6536  
    2323provideAdapter(PersistentDictionaryField)
    2424
    25 template_factory = Environment(loader=PackageLoader(__name__))
     25_template_factory = Environment(loader=PackageLoader(__name__))
     26
     27def template(template_name):
     28    return _template_factory.get_template(template_name)
    2629
    2730
    28 class TemplateAware(object):
    29 
    30     @property
    31     def template(self):
    32         return template_factory.get_template(self.template_name)
    33 
    34 
    35 class BaseBox(TemplateAware):
     31class BaseBox(object):
    3632    """Base abstract class for editable boxes.
    3733    """
    38 
    39     template_name = 'basebox.html'
    4034
    4135    def __init__(self, permission=ModifyPortalContent):
     
    4337
    4438    def __call__(self, context):
    45         return self.template.render(
     39        return template('basebox.html').render(
    4640            box=self,
    4741            has_permission=self.has_permission(context),
     
    7872
    7973    def inner_render(self, context):
    80         template = template_factory.get_template(self.schema.__name__.lower() + '.html')
    81         return template.render(self.get_data_from(context))
     74        templ = template(self.schema.__name__.lower() + '.html')
     75        return templ.render(self.get_data_from(context))
    8276
    8377    def get_data_from(self, context):
     
    142136
    143137# ROWS
    144 class DtRow(TemplateAware):
    145 
    146     template_name = 'dtrow.html'
     138class DtRow(object):
    147139
    148140    def __init__(self, *row_spec):
     
    168160        `row_spec` is a sequence of cell specs: [(width, schema, number), ...]
    169161        """
    170         return self.template.render(cells=self.cells(context))
     162        return template('dtrow.html').render(cells=self.cells(context))
    171163
    172164
  • PortalInterlegis/produtos/il.portalinterlegis/trunk/src/il/portalinterlegis/tests/testunitboxes.py

    r6535 r6536  
    1313    def test_box_render_basic(self):
    1414
    15         with patch('il.portalinterlegis.browser.boxes.manager.template_factory', TemplateFactoryStub()):
     15        with patch('il.portalinterlegis.browser.boxes.manager._template_factory', TemplateFactoryStub()):
    1616
    1717            box = Box(IStubBox, 1)
     
    2626
    2727    def test_box_render_editable(self):
    28         with patch('il.portalinterlegis.browser.boxes.manager.template_factory', TemplateFactoryStub()):
     28        with patch('il.portalinterlegis.browser.boxes.manager._template_factory', TemplateFactoryStub()):
    2929            with patch('il.portalinterlegis.browser.boxes.manager.getSecurityManager') as security_mock:
    3030                security_mock.checkPermission.return_value = True
     
    7070    pass
    7171
    72 from il.portalinterlegis.browser.boxes.manager import template_factory, BaseBox
     72from il.portalinterlegis.browser.boxes.manager import _template_factory, BaseBox
    7373from jinja2 import Template
    7474
     
    8080            return Template("{{var}}")
    8181        elif name == "basebox.html":
    82             return template_factory.get_template(name)
     82            return _template_factory.get_template(name)
    8383        else:
    8484            raise AssertionError("Unexpected name: [%s]" % name)
Note: Veja TracChangeset para ajuda no uso do visualizador de conjunto de mudanças.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.