List Info

Thread: Subdirectories and resource paths in Mako




Subdirectories and resource paths in Mako
country flaguser name
United States
2007-06-02 13:13:55
I tried using subdirectories to render templates in PYlons:

return render_response("/main/'standard.html")

this failed, how does one pass templates from other
directories or
subdirecotires?

Also, for static resources, like images or CSS files that
actually are
on the proxy server proxying for the Paster server, how can
I pass a
sort of "/media" path to my templates that would
always be resolved no
matter how deep the links are that are mapped?

Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Subdirectories and resource paths in Mako
country flaguser name
United States
2007-06-03 13:42:10
Okay, I dug...

I edited the load_enviroment to taste, but I still get
errors:

def load_environment(global_conf={}, app_conf={}):

    map = make_map(global_conf, app_conf)

    # Setup our paths

    root_path =
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

    paths = {'root_path': root_path,

             'controllers': os.path.join(root_path,
'controllers'),

             'templates': [os.path.join(root_path, path) for
path in 

                           ('components', 'templates',
'foo')],

             'static_files': os.path.join(root_path,
'public')

             }


the path foo is not recognized when I try to render a
template from
it:

render_response('foo/newtemplate.html')

could someone help me out?

thanks

On Jun 2, 8:13 pm, voltron <nhy...googlemail.com> wrote:
> I tried using subdirectories to render templates in
PYlons:
>
> return
render_response("/main/'standard.html")
>
> this failed, how does one pass templates from other
directories or
> subdirecotires?
>
> Also, for static resources, like images or CSS files
that actually are
> on the proxy server proxying for the Paster server, how
can I pass a
> sort of "/media" path to my templates that
would always be resolved no
> matter how deep the links are that are mapped?
>
> Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Subdirectories and resource paths in Mako
country flaguser name
United States
2007-06-03 13:49:24
ahhh, it should have read:

render_response('newtemplate.html')


foo just gets added to the searchpath

neat


On Jun 3, 8:42 pm, voltron <nhy...googlemail.com> wrote:
> Okay, I dug...
>
> I edited the load_enviroment to taste, but I still get
errors:
>
> def load_environment(global_conf={}, app_conf={}):
>
>     map = make_map(global_conf, app_conf)
>
>     # Setup our paths
>
>     root_path =
>
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
>
>     paths = {'root_path': root_path,
>
>              'controllers': os.path.join(root_path,
'controllers'),
>
>              'templates': [os.path.join(root_path,
path) for path in 
>
>                            ('components', 'templates',
'foo')],
>
>              'static_files': os.path.join(root_path,
'public')
>
>              }
>
> the path foo is not recognized when I try to render a
template from
> it:
>
> render_response('foo/newtemplate.html')
>
> could someone help me out?
>
> thanks
>
> On Jun 2, 8:13 pm, voltron <nhy...googlemail.com> wrote:
>
> > I tried using subdirectories to render templates
in PYlons:
>
> > return
render_response("/main/'standard.html")
>
> > this failed, how does one pass templates from
other directories or
> > subdirecotires?
>
> > Also, for static resources, like images or CSS
files that actually are
> > on the proxy server proxying for the Paster
server, how can I pass a
> > sort of "/media" path to my templates
that would always be resolved no
> > matter how deep the links are that are mapped?
>
> > Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Subdirectories and resource paths in Mako
user name
2007-06-07 04:18:00
> Also, for static resources, like images or CSS files
that actually are
> on the proxy server proxying for the Paster server, how
can I pass a
> sort of "/media" path to my templates that
would always be resolved no
> matter how deep the links are that are mapped?

Personally, I'm lazy, so I just use absolute paths for the
static
resources.  Hence, I do things like
"/images/foo.png".  I'm sure some
badly behaving proxy out in the wild will bite me one of
these days,
but it hasn't yet.

Best Regards,
-jj

-- 
http://jjinux.blogspot.co
m/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Subdirectories and resource paths in Mako
user name
2007-06-07 08:09:38
On 6/7/07, Shannon -jj Behrens < jjinuxgmail.com">jjinuxgmail.com> wrote:

> Also, for static resources, like images or CSS files that actually are
> on the proxy server proxying for the Paster server, how can I pass a
> sort of "/media" path to my templates that would always be resolved no
> matter how deep the links are that are mapped?

Personally, I'm lazy, so I just use absolute paths for the static
resources.&nbsp; Hence, I do things like "/images/foo.png".&nbsp; I&#39;m sure some
badly behaving proxy out in the wild will bite me one of these days,
but it hasn't yet.

Best Regards,
-jj

I actually came across this last week. ; If for some reason, you want to install a Pylons application mapped to a subdirectory via mod_proxy and Paster, such as on WebFaction, you'll see that the 404 error breaks (in that no images show up).  I guess Paster doesn't see that it's under a subdirectory, so it spits out the wrong absolute path. ; I don't really have an answer to that yet, since I'm still fairly new to Pylons, but you could use a subdomain as well, which could work better.&nbsp; Maybe.

Dan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "pylons-discuss&quot; group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: Subdirectories and resource paths in Mako
country flaguser name
United States
2007-06-07 18:38:34

On Jun 7, 2007, at 6:09 AM, Daniel Tang wrote:

> On 6/7/07, Shannon -jj Behrens <jjinuxgmail.com> wrote:
>
> > Also, for static resources, like images or CSS
files that  
> actually are
> > on the proxy server proxying for the Paster
server, how can I pass a
> > sort of "/media" path to my templates
that would always be  
> resolved no
> > matter how deep the links are that are mapped?
>
> Personally, I'm lazy, so I just use absolute paths for
the static
> resources.  Hence, I do things like
"/images/foo.png".  I'm sure some
> badly behaving proxy out in the wild will bite me one
of these days,
> but it hasn't yet.
>
> Best Regards,
> -jj
>
> I actually came across this last week.  If for some
reason, you  
> want to install a Pylons application mapped to a
subdirectory via  
> mod_proxy and Paster, such as on WebFaction, you'll see
that the  
> 404 error breaks (in that no images show up).  I guess
Paster  
> doesn't see that it's under a subdirectory, so it spits
out the  
> wrong absolute path.  I don't really have an answer to
that yet,  
> since I'm still fairly new to Pylons, but you could use
a subdomain  
> as well, which could work better.  Maybe.
>

Use url_for and the WebHelper functions such as image_tag as
they  
will always prefix urls with the appropriate SCRIPT_NAME
value.

Then when deployed on a subdir behind a reverse proxy, use 

PrefixMiddleware:

http://pylonshq.com/d
ocs/0.9.5/ 
application_configuration.html#prefixmiddleware

--
Philip Jenvey



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Subdirectories and resource paths in Mako
user name
2007-06-08 00:36:16
On 6/7/07, Philip Jenvey <pjenveygroovie.org> wrote:
>
>
> On Jun 7, 2007, at 6:09 AM, Daniel Tang wrote:
>
> > On 6/7/07, Shannon -jj Behrens <jjinuxgmail.com> wrote:
> >
> > > Also, for static resources, like images or
CSS files that
> > actually are
> > > on the proxy server proxying for the Paster
server, how can I pass a
> > > sort of "/media" path to my
templates that would always be
> > resolved no
> > > matter how deep the links are that are
mapped?
> >
> > Personally, I'm lazy, so I just use absolute paths
for the static
> > resources.  Hence, I do things like
"/images/foo.png".  I'm sure some
> > badly behaving proxy out in the wild will bite me
one of these days,
> > but it hasn't yet.
> >
> > Best Regards,
> > -jj
> >
> > I actually came across this last week.  If for
some reason, you
> > want to install a Pylons application mapped to a
subdirectory via
> > mod_proxy and Paster, such as on WebFaction,
you'll see that the
> > 404 error breaks (in that no images show up).  I
guess Paster
> > doesn't see that it's under a subdirectory, so it
spits out the
> > wrong absolute path.  I don't really have an
answer to that yet,
> > since I'm still fairly new to Pylons, but you
could use a subdomain
> > as well, which could work better.  Maybe.
> >
>
> Use url_for and the WebHelper functions such as
image_tag as they
> will always prefix urls with the appropriate
SCRIPT_NAME value.
>
> Then when deployed on a subdir behind a reverse proxy,
use
> PrefixMiddleware:
>
> http://pylonshq.com/d
ocs/0.9.5/
> application_configuration.html#prefixmiddleware

On the subject of PrefixMiddleware, did any committers get a
chance to
check out my code submission here:

http://www.webwareforpython.org
/archives/message/20070509.232518.f56c4bb7.en.html

It even came with tests! 

Best Regards,
-jj

-- 
http://jjinux.blogspot.co
m/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-discussgooglegroups.com
To unsubscribe from this group, send email to
pylons-discuss-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )