Thread: [Rest2web-develop] Getting the current page object
Brought to you by:
mjfoord
From: martin f k. <ma...@ma...> - 2006-08-05 18:16:58
|
I am getting closer to my goal. Two remaining questions now are - how can I get the page object (indextree node) of the page currently being rendered? Do I really have to do a recursive search through the tree until thispage is true? - I saw the target value, which is the URL of any page relative to the one currently being rendered. I wonder whether it is possible to get the URL of the currently rendered page relative to the root as well? So page_url:target:base_url triplets would be (for foo/index.txt) /index.html:../index.html /bar.html:../bar.html /foo/index.html:index.html /foo/bar.html:bar.html Thanks, --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 linux: because a pc is a terrible thing to waste |
From: martin f k. <ma...@ma...> - 2006-08-05 19:31:28
|
also sprach martin f krafft <ma...@ma...> [2006.08.05.1917 +0100]: > - how can I get the page object (indextree node) of the page > currently being rendered? Do I really have to do a recursive > search through the tree until thispage is true? Ah, there is 'thispage', which you can use just like 'indextree'. Sorry, didn't spot that earlier. > - I saw the target value, which is the URL of any page relative to > the one currently being rendered. I wonder whether it is > possible to get the URL of the currently rendered page relative > to the root as well? So page_url:target:base_url triplets would > be (for foo/index.txt) This is still an issue though. --=20 martin; (greetings from the heart of the sun.) \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net@madduck =20 spamtraps: mad...@ma... =20 "those are my principles, and if you don't like them... well, I have others." -- groucho marx |
From: Michael F. <fuz...@vo...> - 2006-08-06 12:54:00
|
martin f krafft wrote: > I am getting closer to my goal. Two remaining questions now are > > - how can I get the page object (indextree node) of the page > currently being rendered? Do I really have to do a recursive > search through the tree until thispage is true? > > - I saw the target value, which is the URL of any page relative to > the one currently being rendered. I wonder whether it is > possible to get the URL of the currently rendered page relative > to the root as well? So page_url:target:base_url triplets would > be (for foo/index.txt) > > /index.html:../index.html > /bar.html:../bar.html > /foo/index.html:index.html > /foo/bar.html:bar.html > I've just committed some changes to SVN. These add to the namespace, *and* to pages in the indextree, various pieces of information about the pages : 'source_file': The source file for the page 'current_dir': The current directory being processed - this can be turned into an absolute filepath by doing os.path.join(os.getcwd(), current_dir) 'target_dir': The target file directory (as an absolute file path) being rendered into. Note if the file has a target specified it may not be put in this directory. Use os.path.dirname(target_file) instead. 'full_page_url': The full url (starting with '/') for the current page 'target_file': The full filename of the page being rendered I've also nailed a tricky bug with the finding of 'thispage'. Now to nail the unicode bug, and possibly add an 'include_rest' function. Michael http://www.voidspace.org.uk/python/index.shtml > Thanks, > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > ------------------------------------------------------------------------ > > _______________________________________________ > Rest2web-develop mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/rest2web-develop > |
From: Gael V. <gae...@no...> - 2006-08-06 13:39:17
|
> These add to the namespace, *and* to pages in the indextree, various=20 > pieces of information about the pages : > 'source_file': The source file for the page > 'current_dir': The current directory being processed - this can be=20 > turned into an absolute filepath by doing os.path.join(os.getcwd(),=20 > current_dir) > 'target_dir': The target file directory (as an absolute file path) bein= g=20 > rendered into. Note if the file has a target specified it may not be pu= t=20 > in this directory. Use os.path.dirname(target_file) instead. > 'full_page_url': The full url (starting with '/') for the current page > 'target_file': The full filename of the page being rendered Now that _is_ useful ! Can I suggest another change : for each page, variables created in one code block are kept and accessible for the next code blocks. You can have a look at what I do in pyreport ( http://gael-varoquaux.info/computers/pyreport ) to see how I do something similar. Check out the function executeBlock: I save the namespace at the end of the function call and reinject it later in my "exec" call. This would be really useful and would allow to avoid to much code duplication in "template.txt" and in the different files processed. Cheers, Ga=EBl |
From: Michael F. <fuz...@vo...> - 2006-08-06 14:50:55
|
Gael Varoquaux wrote: >> These add to the namespace, *and* to pages in the indextree, various >> pieces of information about the pages : >> > > > >> 'source_file': The source file for the page >> > > >> 'current_dir': The current directory being processed - this can be >> turned into an absolute filepath by doing os.path.join(os.getcwd(), >> current_dir) >> > > >> 'target_dir': The target file directory (as an absolute file path) being >> rendered into. Note if the file has a target specified it may not be put >> in this directory. Use os.path.dirname(target_file) instead. >> > > >> 'full_page_url': The full url (starting with '/') for the current page >> > > >> 'target_file': The full filename of the page being rendered >> > > Now that _is_ useful ! > > Hello Gael, > Can I suggest another change : for each page, variables created in > one code block are kept and accessible for the next code blocks. You can > have a look at what I do in pyreport ( > http://gael-varoquaux.info/computers/pyreport ) to see how I do > something similar. Check out the function executeBlock: I save the > namespace at the end of the function call and reinject it later in my > "exec" call. > > The code that executes templates uses a single namespace. If you modify that namespace (create variables etc) then they should persist for that whole page - in the order that they are created in the page. *However*, up until about five minutes ago eval was done before exec. That meant that you couldn't do : <# xyz = 3 #> <% xyz %> (<% .. %> was always done first.) I've just reversed the order - so that should work now. > This would be really useful and would allow to avoid to much code > duplication in "template.txt" and in the different files processed. > > By the way Gael: You may find the journal/blog style parts of your site easier to administer with `Firedrop2 <http://www.voidspace.org.uk/python/firedrop2/>`_. You can still make entries with ReST - but it handles archives/RSS/categories etc for you, and lets you administer each entry separately. Just a thought. :-) Fuzzyman http://www.voidspace.org.uk/python/index.shtml > Cheers, > > Gaël > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Rest2web-develop mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/rest2web-develop > > |
From: Gael V. <gae...@no...> - 2006-08-06 22:21:27
|
On Sun, Aug 06, 2006 at 03:54:19PM +0100, Michael Foord wrote: > The code that executes templates uses a single namespace. If you modify= =20 > that namespace (create variables etc) then they should persist for that= =20 > whole page - in the order that they are created in the page. Good, useful. > By the way Gael: You may find the journal/blog style parts of your site= =20 > easier to administer with `Firedrop2=20 > <http://www.voidspace.org.uk/python/firedrop2/>`_. You can still make=20 > entries with ReST - but it handles archives/RSS/categories etc for you,= =20 > and lets you administer each entry separately. Just a thought. :-) Yeah, maybe, one day... You know, I don't like GUIs. Thats clearly one thing I like about rest2web: it is fully based on what is on the disk, which allow to make it work on directories synchronised between different boxes in different places. The danger of course is coding to many things myself and reinventing the wheel. This is why I should try investing more time in testing/giving feedback to rest2web. But xurrently not only am I overloaded by my day job, but I also have a sore wrist from spending to much time in front of a computer ;->. Anyway, I think you a doing a great job with rest2web and I really look forwards to the release in which the compiling of the web site will be done in two passes (this does seems like the Right Thing). Cheers, --=20 Ga=EBl |