Martin Dougiamas wrote:
Martijn Faassen wrote:
Probably some mild level of Zope Zen is needed to realize fully that *folders* are acquired by subfolders too -- recently I faced similar organizational issues as well, and used this to good effect.
I had the same setup with a root folder and a number of sub folders, and common SQL methods in the root folder so that they were acquired. As I had quite a few SQL methods this started to get messy. So I made a subfolder called 'sql' and moved all SQL methods to that place. Now I have a nice and clean root folder.
Zen: All the sub folders acquire this SQL folder.
Of course I had to adapt my DTML documents in the subfolders from things like:
<!--#call "insert_whatever(REQUEST)"-->
to:
<!--#call "sql.insert_whatever(REQUEST)"-->
so it's easier to set this up the right way in the beginning.
You can use the same strategy for any common documents.
I really like the sound of this, and I've been re-organising my Zope application organisation, but I've hit a snag.
I used to call DTML documents with
<!--#var myfunction-->
so now, since they are in a sibling folder under the root folder, (eg /myapp) I tried:
<!--#var myapp.myfunction-->
But it doesn't work any more - keeps giving KeyErrors.
The funny thing is that
<!--#var "myapp.myfunction"-->
correctly returns all the raw content of the DTML document, so it *can* find it OK.
Any ideas?
Sure. See my response to Paul. The bottom line is that you have to call the document template explicitly when you use it in a (Python) expression: <!--#var "myapp.myfunction(None, _)"--> This is the way that DocumentTemplates call other document templates when they aren't used in expressions. It is important to pass the current document template namespace, '_' as the second argument. This provides access to the current namespace to the document template being called. The first argument, 'None', is just a placeholder, since these arguments are positional. Jim -- Jim Fulton mailto:jim@digicool.com Python Powered! Technical Director (888) 344-4332 http://www.python.org Digital Creations http://www.digicool.com http://www.zope.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.