Example #1
0
    def test_layout2(self):
        template="""
        <:slot head:>

        <:slot main:>

        <:slot foot:>

        """
        tp=S.getTemplatePath()
        translated=translate_path(Cfg.componentRoot, tp)
        os.makedirs(os.path.dirname(translated))
        open(translated, 'w').write(template)
        d=os.path.join(Cfg.componentRoot, '/nougat')
        os.mkdir(translate_path(Cfg.componentRoot, d))
        fp=open(os.path.join(translate_path(Cfg.componentRoot, d), 'slotconf.pydcmp'), 'w')
        fp.write("raise ReturnValue(dict(head='HEAD', main='MAIN', foot='FOOT'))\n")
        fp.close()
        fp=C.docroot_open('/nougat/frenchie.stml', 'w')
        fp.write("<:calltemplate:>")
        fp.close()
        res=C.stringcomp('/nougat/frenchie.stml') 
        assert 'HEAD' in res
        assert 'MAIN' in res
        assert 'FOOT' in res
Example #2
0
 def test_layout1(self):
     template='<:compargs SLOTS=`{}`:><:for `"first second third".split()` name:><:slot `name`:><:/for:>'
     templatePath=S.getTemplatePath()
     translated=translate_path(Cfg.componentRoot, templatePath)
     d=os.path.dirname(translated)
     os.makedirs(d)
     open(translated, 'w').write(template)
     res=C.stringcomp(templatePath).strip()
     assert res=='', "expected empty, got %s" % res
Example #3
0
 def test_buffet1(self):
     template="""
     <:slot slot1:>
     <:slot slot2:>
     """
     tp=S.getTemplatePath()
     translated=translate_path(Cfg.componentRoot, tp)
     os.makedirs(os.path.dirname(translated))
     open(translated, 'w').write(template)
     plugin=S.BuffetPlugin()
     res=plugin.render(info=dict(SLOTS=dict(slot1='hello', slot2='goodbye')))
     assert 'hello' in res
     assert 'goodbye' in res
Example #4
0
 def check_path(self, path):
     """
     takes a request path and looks for a real path related to it.
     returns the path (possibly corrected), the translated path, and
     stat() info. If is can be determined that the correct status code
     for this resource is not 200, it will raise a webob.exc.HTTPException
     here.
     """
     componentRoot = Configuration.componentRoot
     realpath = translate_path(componentRoot, path)
     try:
         s = os.stat(realpath)
     except (OSError, IOError), oy:
         if oy.errno == errno.ENOENT:
             raise get_http_exception(httplib.NOT_FOUND)
         elif oy.errno == errno.EACCES:
             raise get_http_exception(httplib.FORBIDDEN)
         # anything else?
         else:
             # let a more general 500 handler clean up.
             raise
Example #5
0
def docroot_open(path, flags='r'):
    realpath=translate_path(Configuration.componentRoot, path)
    return open(realpath, flags)
Example #6
0
 def fget(self):
     return translate_path(Configuration.componentRoot, self.filename)