Re: [Rest2web-develop] Re: Enhancement suggestion to rest2web
Brought to you by:
mjfoord
From: Michael F. <fuz...@vo...> - 2006-04-09 22:27:23
|
Gaël Varoquaux wrote: > On Sun, Apr 09, 2006 at 10:42:26PM +0100, Michael Foord wrote: > >>> * A inlined function, such as <# print(2*2) #> should be able to add >>> files to the restindex['file'] list. That should probably be >>> rather easy to add. >>> > > > >> There are several ways of doing this (including writing your own >> function and just importing it in the template). >> > > I am reluctant to modify the rest2web files. But maybe I missed a > way of doing this without modifying them. Currently I am only coding > embedded code in the template. > > But you can import anything inside the templates - so keep it in an external file somewhere on ``sys.path`` (e.g. your ``site-packages`` folder) and import it. If you wanted to make this easily available, the file to add it to is functions.py. If you write a general enough function I will add it to the distribution. Ah.. I can see below that you are aware of this file. >> Where do you want to move files from and to ? Currently the 'file' >> keyword only moves files into the same directory as the target file >> being created. Is this what you want to do ? >> > > You mean if the file keyword is "foo/bar" rest2web won't create a > foo subdirectory in the target directory and copy bar there ? If so then > I think it would be an interesting feature to add. > > I *don't* do this so that you can copy relative files into the target directory using the ``file`` keyword. I think it would be easy enough to create a standard function that does this - so modifying the file keyword shouldn't be necessary. >> I'm sure there is an easy function you could write to do this - I would >> be happy to include it in the set of standard functions if it was >> general enough. >> > I have been trying to, but I cannot find a way of retrieving the > target directory with embedded code. Are you suggesting that I modify > function.py to add such a function and send you a patch ? I'll have a > look at that. > If you can give me some advice on implementing that I am more then > happy to do it. > > The full path to the page being generated is ``pagepath``. You should find that ``os.path.dirname(pagepath)`` gives you the directory. Let me know how you get on with this. >> I've been planning to add hashing for a while. >> >> I am now busy implementing it - it jumped the queue ! >> >> It might still take a couple of weeks to get right, maybe less. >> > The more I think about it the more I think there is a certain amount > of work. But I think it will be a very useful feature. > > Thanks for such quick feedback (I joined the sourceforge mailing > list and saw your mail). > > Well, I've started work on it. It might not be that easy because I need to pickle the data structures in use by rest2web. This means I need to check that there are no complicated cross references that won't be restored properly if I just copy data for individual pages from the pickle. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml |