You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/appdev.rst
+24-2Lines changed: 24 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -310,7 +310,16 @@ When creating the Application instance, it takes a ``development`` flag as argum
310
310
print
311
311
~~~~~
312
312
313
-
The most common technique is the infamous ``print`` statement which has been replaced with a ``print()`` function in Python 3. The results of ``print()`` calls go to the console where the WSGI server was started (not to the HTML page as would happen with CGI). In production mode, you can specify an ``AppLogFilename`` in ``Application.config``, which will cause the standard output and error to be redirected to this file.
313
+
The most common technique is the infamous ``print`` statement which has been replaced with a ``print()`` function in Python 3. The results of ``print()`` calls go to the console where the WSGI server was started (not to the HTML page as would happen with CGI). If you specify ``AppLogFilename`` in ``Application.config``, this will cause the standard output and error to be redirected to this file.
314
+
315
+
For convenient debugging, we recommend you use a clause like this in your ``Application.config`` file::
316
+
317
+
if Development:
318
+
AppLogFilename = None
319
+
else:
320
+
AppLogFilename = 'Logs/Application.log'
321
+
322
+
This will prevent standard output and error from being redirected to the log file in development mode, which makes it easier to find debugging output, and also makes it possible to use ```pdb``` (see below).
314
323
315
324
Prefixing the debugging output with a special tag (such as ``>>``) is useful because it stands out on the console and you can search for the tag in source code to remove the print statements after they are no longer useful. For example::
316
325
@@ -331,7 +340,7 @@ While this is totally useful during development, giving away too much internal i
331
340
Reloading the Development Server
332
341
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
333
342
334
-
When a servlet's source code changes, it is reloaded. However, ancestor classes of servlets, library modules and configuration files are not. You may wish to enable the auto-reloading feature when running the development server, by adding the ``-r`` or ``--reload`` option to the ``webware seve command`` in order to mitigate this problem.
343
+
When a servlet's source code changes, it is reloaded. However, ancestor classes of servlets, library modules and configuration files are not. You may wish to enable the auto-reloading feature when running the development server, by adding the ``-r`` or ``--reload`` option to the ``webware serve command`` in order to mitigate this problem.
335
344
336
345
In any case, when having problems, consider restarting the development server (or the WSGI server you are running in production).
337
346
@@ -345,6 +354,19 @@ Assertions are used to ensure that the internal conditions of the application ar
345
354
assert shoppingCart.total() >= 0, \
346
355
f'shopping cart total is {shoppingCart.total()}'
347
356
357
+
Debugging using PDB
358
+
~~~~~~~~~~~~~~~~~~~
359
+
To use python's built-in debugger ```pdb```, see the tip above about setting ```AppLogFilename``` for convenient debugging.
360
+
361
+
To have Webware automatically put you into pdb when an exception occurs, set this in your ``Application.config`` file::
362
+
363
+
EnterDebuggerOnException = Development
364
+
365
+
A quick and easy way to debug a particular section of code is to add these lines at that point in the code::
0 commit comments