Changeset 1700

Show
Ignore:
Timestamp:
07/21/08 08:00:32 (20 months ago)
Author:
JensDiemer
Message:

add a simple error feedback method to BasePlugin?.

Location:
trunk/pylucid
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/doc/plugin_api.py

    r1634 r1700  
    181181            self.page_msg("Debug is on.") 
    182182 
     183    #__________________________________________________________________________ 
     184    # UTILS 
     185    # 
     186    # Some needfull methods 
     187    # 
     188    def simple_error_feedback(self): 
     189        """ 
     190        with self._error() you can easy create a "abort" error messages. 
     191        The goal is: The method gets two messages types: 
     192            public_msg, debug_msg 
     193        The public messages would be always displayed. The debug messages would 
     194        be append if self.request.debug is on. 
     195        So you can easy gives feedback for anonymous users and developers, too. 
     196        """ 
     197        try: 
     198            ...do something... 
     199        except Exception, err: 
     200            return self.error(_("Wrong URL."), err) 
  • trunk/pylucid/PyLucid/system/BasePlugin.py

    r1679 r1700  
    208208        return html 
    209209 
    210  
    211  
     210    def error(self, public_msg, debug_msg): 
     211        """ 
     212        Display a error with page_msg.red(). 
     213        Append debug_msg if self.request.debug is on 
     214        e.g.: 
     215            try: 
     216                ...do something... 
     217            except Exception, err: 
     218                return self.error(_("Wrong URL."), err) 
     219        """ 
     220        msg = public_msg 
     221        if self.request.debug: 
     222            msg += " %s" % debug_msg 
     223 
     224        self.page_msg.red(msg) 
     225 
     226