Hi All.

I develop CMS using pyramid.  CMS consist of core and some plugins.
Application which use CMS looks like:

from pyramid.config import Configurator
def main(global, **settings):
    config = Configurator(settings=settings)
    config.include('mycms.core')
    config.include('mycms.plugin')


I use Mako as renderer.  Global templates (such as layouts) are stored
in application package and local (plugin) templates are stored in
plugin packages.  To use global templates (for inheritance) in local
ones I specified in application ini-files the line:

mako.directories = application:templates


Plugin includeme function looks like:

def includeme(config):
    config.add_view('.views.someview', context='.resource.Resource',
renderer=':templates/someview.mak')


When I specified renderer name as full asset spec
'mycms.plugin:templates/someview.mak' it works fine.  But in relative
form (like in example of code) I got ValueError: Empty module name.

So, after update __init__ method of pyramid.renderers.RendererHelper
both forms are operational:

class RendererHelper(object):
    implements(IRendererInfo)
    def __init__(self, name=None, package=None, registry=None):
        if name and '.' in name:
            rtype = os.path.splitext(name)[1]
        else:
            rtype = name

        # Begin of my additional code *******************************
        if (name.startswith('.') or name.startswith(':')) and package:
            if isinstance(package, basestring):
                name = package + name
            else:
                name = package.__name__ + name
        # End of my additional code *********************************

        if registry is None:
            registry = get_current_registry()

        self.name = name
        self.package = package
        self.type = rtype
        self.registry = registry


So, is it bug of pyramid.renderers.RendererHelper and what can be
broken after my fix?  I'm not sure, that this is appropriate place to
fix it.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to