How to debug Zope by thebest11

VIEWS: 23 PAGES: 8

									How to debug Zope
          Miruna Bădescu
          Finsiel Romania




           Copenhagen, 25 May 2004
Overview
   Several levels of debug:
        Objectsin ZODB (DTML Methods, Page Templates,
         Python Scripts, ZSQL Methods)
        Python products

   Various types:
        Programming/syntax   errors – cause an error to be
         displayed to the end user
        Long loading time of pages – enabling the Zope’s
         Python profiling capabilities helps trace the weak
         points
        Ignorable errors – caused by a “wrong” action done by
         end-users
Techniques
   Consult the Site Error Log objects:
           Keeps detailed information for the recent errors
   Setting the debug mode “on” displays more detailed error
    tracebacks
         Zope remains attached to the terminal that started it
         External Methods, DTMLFile and ZPTFiles objects are reloaded
          every time they are modified
         Tracebacks are shown on the browser

              • everybody can spot the source of errors
              • end-users might get confused
           Reduces the server performance a bit
   Product refresh setting
         Reloads all the products’ modules (manual and automatically)
         Place a refresh.txt in your products’ directory
Profiling
   Control Panel provides a Debug Information tab
        Useful   mostly in the performance area
   Setting the Python-based profile mode “on”:
        Information   about which methods in your system take
         the most time to execute
        It builds a profile which lists the busiest methods
         sorted by increasing resource usage
        Should be enabled only for short periods, since the
         Zope performance will suffer a lot
   Use the CallProfiler product which traces certain
    types and builds a dependency list with their loading
    times
What to show end users

   The standard error page can be customized for
    regular users in order to:
        Avoid giving too much information about the back-end
         of your application (reduce the possibility of exposing
         the weak points)
        Do not scare non-technical users with complicated
         messages
        Provide instructions on what to do and who to turn to

        Apologize ;-)
Debugging Python code (1)

   Use print statements in critical points to narrow
    down the error source – debug mode only
   Zope is integrated with a Python debugger pdb:
        run Zope in debug mode and enter the debugger
         through Zope’s terminal session
   Use programs like Wing IDE and integrate them in
    Python’s Zope to gain:
        Graphicaldebugger
        Code browser

        Source editors, etc.
Debugging Python code (2)
   Use unit tests: create small applications for each
    individual part to verify if the intended component
    behavior is the desired one
        Can  be grouped in unit testing frameworks
        Are not necessarily written in Python

        Are not manually operated

        Are not interactive – no questions asked, use a
         predefined input data
        Should not be complicated

        Possible situations where needs:
          • New modules added
          • Change/enhance existing modules
          • Fix bugs
Logging errors

   Since Zope 2.7, the logging mechanism contains
    more refined ways of recording/keeping the logs:
        access  – the access to the Zope server
        event – Zope event information

        trace – detailed server request information (debug
         purposes)
   Email notifyers introduced in case of certain type or
    errors
   Keeping warnings (e.g. DeprecationWarning) helps
    developers improve the code

								
To top