Show
Ignore:
Timestamp:
01/21/08 21:00:58 (16 years ago)
Author:
jerome
Message:

Made the CGI scripts work again.
Moved even more functions to the utils module.
Removed the cgifuncs module, moved (and changed) content into utils.
If no output encoding defined, use UTF-8 : when wget is used to try
the CGI scripts, it doesn't set by default the accepted charset and
language headers.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r3294 r3295  
    3838from mx import DateTime 
    3939 
     40from pykota import utils 
    4041from pykota.errors import PyKotaCommandLineError 
    4142from pykota import config, storage, logger 
    4243from pykota.version import __version__, __author__, __years__, __gplblurb__ 
    43  
    44 def N_(message) : 
    45     """Fake translation marker for translatable strings extraction.""" 
    46     return message 
    47  
    48 def crashed(message="Bug in PyKota") :     
    49     """Minimal crash method.""" 
    50     import traceback 
    51     lines = [] 
    52     for line in traceback.format_exception(*sys.exc_info()) : 
    53         lines.extend([l for l in line.split("\n") if l]) 
    54     msg = "ERROR: ".join(["%s\n" % l for l in (["ERROR: PyKota v%s" % __version__, message] + lines)]) 
    55     sys.stderr.write(msg) 
    56     sys.stderr.flush() 
    57     return msg 
    5844 
    5945class Percent : 
     
    10389class Tool : 
    10490    """Base class for tools with no database access.""" 
    105     def __init__(self, lang="", charset=None, doc="PyKota v%(__version__)s (c) %(__years__)s %(__author__)s") : 
     91    def __init__(self, doc="PyKota v%(__version__)s (c) %(__years__)s %(__author__)s") : 
    10692        """Initializes the command line tool.""" 
    10793        self.debug = True # in case of early failure 
     
    11096        # Saves a copy of the locale settings 
    11197        (self.language, self.charset) = locale.getlocale() 
     98        if not self.charset : 
     99            self.charset = "UTF-8" 
    112100         
    113101        # pykota specific stuff 
     
    247235    def crashed(self, message="Bug in PyKota") :     
    248236        """Outputs a crash message, and optionally sends it to software author.""" 
    249         msg = crashed(message) 
     237        msg = utils.crashed(message) 
    250238        fullmessage = "========== Traceback :\n\n%s\n\n========== sys.argv :\n\n%s\n\n========== Environment :\n\n%s\n" % \ 
    251239                        (msg, \ 
     
    347335class PyKotaTool(Tool) :     
    348336    """Base class for all PyKota command line tools.""" 
    349     def __init__(self, lang="", charset=None, doc="PyKota v%(__version__)s (c) %(__years__)s %(__author__)s") : 
    350         """Initializes the command line tool and opens the database.""" 
    351         Tool.__init__(self, lang, charset, doc) 
    352          
    353337    def deferredInit(self) :     
    354338        """Deferred initialization."""