[ZDP] FAQ Submission
Michel Pelletier
michel@digicool.com
Thu, 04 Mar 1999 12:06:42 -0500
How does my Folder Product load default documents?
Create a list of tuples containing filenames (without '.dtml') and title
pairs:
self.defaultDocs = [
('index', 'NotMail'),
('address', 'Address Book'),
('attach', 'Attach a File'),
('composer', 'Compose a Message'),
('contact', 'Contact Developers'),
('search', 'Search Your Mailboxes'),
('results', 'Your Search Results'),
('folder', 'Mailbox'),
('message', 'Message'),
('help', 'Help'),
('lookup', 'Lookup Users'),
('standard_footer', 'Standard HTML Footer'),
('standard_header', 'Standard HTML Header'),
('noto', 'Message must have at least one recipient.'),
('reminders', 'Your Reminders'),
('save', 'Save Message'),
('logout', 'You have been logged out'),
('GPL', 'The GNU General Public License'),
('sentmail', 'Mail was sent')]
# Then iterate over them and create each one
for id,title in self.defaultDocs:
try:
self.defaultDocFile(id, title, id)
except:
pass
# defaultDocFile is a handy little function:
def defaultDocFile(self, id, title, file):
f=open('%s/Products/NotMail/%s.dtml'
% (SOFTWARE_HOME, file))
file=f.read()
f.close()
self.manage_addDocument(id, title, file)
When your debugging your DTML, it's a pain to keep deleting and creating
new instances of your object in order to load the new dtml files off of
the disk. This function comes in handy:
def refresh_docs(self, REQUEST):
""" refresh documents from disk (for debug purposes) """
for id,title in self.defaultDocs:
try:
self._delObject(id)
except:
pass
try:
self.defaultDocFile(id, title, id)
except:
pass
return self.manage_main(self, REQUEST)
Then, assuming your object has an attribute 'debug' you can define some
DTML like so in your manage_main screen:
<!--#if debug-->
<p><a href="refresh_docs">Refresh Documents from disk</a></p>
<!--#/if debug-->