Access layout file in another application

42 views
Skip to first unread message

curiouslearn

unread,
Aug 23, 2012, 10:08:09 AM8/23/12
to web...@googlegroups.com
Hello,

I searched on the forums here and it appears that the suggested solution for accessing a layout file is to create links (hard links or soft links?). 

I have two questions in this regard:

(i) Is this solution robust to changes in where the application is hosted? Would the links works regardless of whether I have it hosted on EC2, or dotcloud, or pythonanywhere etc.

(ii) Is it possible to do this using the {{extend ...}} command? If so, I would appreciate an example. 

For example, suppose I am in application called participants and I want to use the layout file in application myadminapp (in myadminapp the layout file is in views/default/). I tried doing the following, but none of these work. 

{{extend URL(a='myadminapp', c='  ', f='views/default/mylayout.html')}}  results in /myadminapp/ /views/default/mylayout.html

{{extend URL(a='myadminapp', f='views/default/mylayout.html')}}  results in /myadminapp/default/views/default/mylayout.html

I also tried:
{{extend '/myadminapp/views/default/mylayout.html'}}, which gives the following error:

<type 'exceptions.IOError'>([Errno 2] No such file or directory: '/myadminapp/views/default/mylayout.html')

This error is strange because there does exist an application myadminapp, with folder views with folder default with file mylayout.html.

Thanks.

Anthony

unread,
Aug 23, 2012, 10:30:33 AM8/23/12
to web...@googlegroups.com
{{extend ...}} takes a file path, not a URL, and it needs to be relative to the current application's /views folder. So you can use directory traversal to get to the other layout:

{{extend '../../myadminapp/views/default/mylayout.html'}}

The ../../ will go up two levels from /applications/current_app/views to /applications, and then the rest of the path follows from there.

Anthony

curiouslearn

unread,
Aug 23, 2012, 10:54:11 AM8/23/12
to web...@googlegroups.com
Thank you, Anthony. That worked well. 

Do you have an opinion on which is a better method (in terms of easier to maintain, less problems that I cannot foresee given my lack of experience building web apps): the links of using extend as suggested?

Thanks again.

Anthony

unread,
Aug 23, 2012, 11:05:44 AM8/23/12
to web...@googlegroups.com
I think I would use the method I showed rather than links.

Anthony

curiouslearn

unread,
Aug 23, 2012, 12:27:10 PM8/23/12
to web...@googlegroups.com
Thanks, Anthony. I will also go with the method you showed.
Reply all
Reply to author
Forward
0 new messages