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-->
On Thu, 4 Mar 1999, Michel Pelletier wrote:
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)
I think Skip provided a better way to deal with this, but I am not sure if it has made it in the official DocumentTemplate release. Pavlos
participants (2)
-
Michel Pelletier -
Pavlos Christoforou