Re: [pylons-discuss] check if mako template exists

2013-10-17 Thread Laurent DAVERIO
> if os.path.exists():

Oops, I meant:

if os.path.exists(path):

Laurent.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [pylons-discuss] check if mako template exists

2013-10-17 Thread Laurent DAVERIO
Le 17/10/13 09:34, cropr a écrit :
> Does anybody know how one can check in Pyramid  if a mako template
> exists without rendering it, assuming that the mako.directiories is
> correctly set up?

I think you need this:

http://pyramid.readthedocs.org/en/latest/api/path.html?highlight=assetresolver#pyramid.path.AssetResolver

import os
from pyramid.path import AssetResolver

ar = AssetResolver()

path = ar.resolve('mypackage:templates/mytemplate.mako').abspath()

if os.path.exists():
  ...


Laurent.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/groups/opt_out.