From: Rimon B. <ba...@cs...> - 2003-04-02 14:16:42
|
Hi Oliver, I'm excited to hear about this. It's something needed and useful. I think that it will nicely complement the tagging functionality. Note that the tags are undergoing a general overhaul. Another Spyce user has been using them quite a bit and has noticed a few problems with the way that they are currently designed. For example, they do not nest deeply, because of a seemingly arbitrary nesting limitation of Python. I have not had the time to look into these problems, but I will within the next month. Nevertheless, the basic idea will not change much - you'll just have to make a few tweaks to existing tag libraries for them to work. With regard to your question: it *is* possible to select and load a tag library dynamically. You can not do it via the tag directive, as you wrote below. The reason for this is that directives are processed at parse/compile time. You can't do any expansion there (Python doesn't have a notion of constants!) However, you can acheive that which you are looking for, via a function in the tag module, while the interpretter is actually running. Simply import the taglib module (it's automatically loaded, only in the case that some tag library is loaded, but you can load it explicitly as well), and write: [[ taglib.load(libname, libfrom, libas) ]] where: libname - is the name of the tag library class libfrom - is the name of the tag library file (=libname by default) libas - is the prefix to load it under (=libname by default) As with modules, the tag libraries can be located anywhere in the Spyce path, or in the current document directory (in the case that people want to create custom tag libraries, as you are suggesting). The rest of the taglib module is documented at: http://spyce.sourceforge.net/doc-mod_taglib.html All the best, Rimon. On Wed, 2 Apr 2003, Borgers, Oliver wrote: >Hi there, > >I'm just playing around with Spyce to test the possibility of building kind of Python version of PHP-Nuke ;) > >It would be nice if you could use theme-specific taglibs but to do so the only way I see is the following: > >[[.taglib name=theme_taglib from "%s/theme_taglib.py" % (general.getTheme()[2])]] >(the function general.getTheme returns (themename,__init__-module of themepackage,themepath)) >and this will not function for me?! > >Maybe I missed something.....just at the beginning of my "Spyceharvest".... > >Greets and thanks for such great piece of Python:) > >Oliver Borgers > |