XSLTools

XSLForms/Resources/Common.py

687:ae7bdbf61e32
2009-06-22 Paul Boddie Added some error handling to the questionnaire application.
     1 #!/usr/bin/env python     2      3 """     4 Common resource class functionality.     5      6 Copyright (C) 2005 Paul Boddie <paul@boddie.org.uk>     7      8 This program is free software; you can redistribute it and/or modify it under     9 the terms of the GNU Lesser General Public License as published by the Free    10 Software Foundation; either version 3 of the License, or (at your option) any    11 later version.    12     13 This program is distributed in the hope that it will be useful, but WITHOUT    14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS    15 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more    16 details.    17     18 You should have received a copy of the GNU Lesser General Public License along    19 with this program.  If not, see <http://www.gnu.org/licenses/>.    20 """    21     22 import os    23     24 class CommonResource:    25     26     "Common resource methods."    27     28     document_resources = {}    29     resource_dir = None    30     31     def prepare_document(self, document_identifier):    32     33         """    34         Prepare a document using the given 'document_identifier'.    35     36         Return the full path of the document for use either as the source    37         document or as a reference with 'send_output' or 'get_result'.    38         """    39     40         filename = self.document_resources[document_identifier]    41         return os.path.abspath(os.path.join(self.resource_dir, filename))    42     43 # vim: tabstop=4 expandtab shiftwidth=4