web2py solution for debbuging with FirePHP/Firebug

111 views
Skip to first unread message

sgtpep

unread,
Jun 2, 2009, 2:02:07 AM6/2/09
to web2py Web Framework
Hi, web2pyers!
Everyone knows Firebug, the perfect webdeveloper tool. There is also
FirePHP addon for using Firebug facilities for server side debugging/
logging. And recently I found firepy (http://code.google.com/p/
firepy/). It makes available to use FirePHP with Django.
I have added a bit of code to firepy source for making possible to use
it with web2py.
Here it is (sorry, I have no time to commit it to firepy or web2py
distribution, mayby later):
http://www.box.net/shared/dtm0dhgze9

For using place firepy folder to modules directory of your application
and add these lines of code at the begining of your models code:
import sys
sys.path += ['applications/%s/modules' % request.application]
from firepy.web2py import start_firepy
start_firepy(globals())

sgtpep

unread,
Jun 2, 2009, 10:04:12 AM6/2/09
to web2py Web Framework
Source files were updated in archive. Some issues were fixed. And also
logs shows in console now if you are authorized in admin application.
I forgot to mention what features of frepy are ready for working with
web2py:
- server-side logging using logging module
- db query logging (!) with timing and multiple databases support
Custom exception handler are not working yet because web2py owerrides
it with own one.

mdipierro

unread,
Jun 2, 2009, 10:34:23 AM6/2/09
to web2py Web Framework
awesome. I will take a look asap.

mdipierro

unread,
Jun 3, 2009, 12:10:58 AM6/3/09
to web2py Web Framework
I am new to this. I can tell this is very usefull but I do not know
how to make it work.

Any chance you can make a short video showing it (perhaps using Jing)?

Do you feel it should be included in web2py? How?

Massimo

On Jun 2, 9:04 am, sgtpep <danil.m...@gmail.com> wrote:

sgtpep

unread,
Jun 3, 2009, 6:19:50 AM6/3/09
to web2py Web Framework
Unfortunately I have no expirience in screencasting, and my English is
buggy.

Debugging/logging tool is very useful thing for web development. I
really like this one in Symfony framework (it is included to Symfony
and made with JavaScript, screenshot -
http://www.symfony-project.org/blog/2008/08/27/new-in-symfony-1-2-customize-the-web-debug-toolbar).
For Django there is third-party module Django Debug Toolbar (http://
rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/).

I think the most valuable things that this type of tools can show for
developer are: accessible report to server-side logs pre request, info
about queries executed during request and maybe some cache stats and
variables list.

Firebug (http://getfirebug.com/) is the most popular Firefox extension
for web developent, very handy and well-built. It implements
JavaScript console, DOM traversing, JS-debugging and lot more. FirePHP
(http://www.firephp.org/) is another extension that uses Firebug
interface and resources and therefore requires Firebug for work. You
can see demo here (Firefox with both extensions required, open and
enable Firebug console to see output) - http://www.firephp.org/Examples/PHPArchitect/.
In two words, FirePHP allows you to output log messages that you
passed from PHP code, displays executed db queries, stack trace of
exceptions, etc. It requires of using PHP class FirePHPCore/
FirePHP.class.php. Firepy (documentation and screenshot -
http://code.google.com/p/firepy/wiki/Documentation) is the
implementation for Python of the server-side FirePHP library, but it
uses the same Firefox extension (FirePHP). And it includes Middleware
for using with Django, but you can easily adopt it for any Python
framework.

How-to for using FirePHP with web2py:
1) Open Firefox, install Firebug, FirePHP addons:
https://addons.mozilla.org/ru/firefox/addon/1843,
https://addons.mozilla.org/en-US/firefox/addon/6149. Restart browser.
2) Download http://www.box.net/shared/dtm0dhgze9 and extract 'firepy'
folder.
3) Open directory with your current web2py application, and copy
'firepy' folder into 'modules' directory of application.
4) Edit first file in 'models' folder in your application (via web- or
desktop-editor). Place these lines in top of the file:

import sys
sys.path += ['applications/%s/modules' % request.application]
from firepy.web2py import start_firepy
start_firepy(globals())

5) Edit some controller file and add this line to some controller
function: logging.debug([1, {"asdf":(123, 2, "3")}, "3"])
6) Click on bug icon on bottom status line of Firefox. This will bring
up panel. Check the checkbox "Console" and click "Apply settings".
Ensure that tab "Console" is showing.
7) Navigate from browser to this application/controller/function. And
now you should see your logging output in console ([1, {"asdf":(123,
2, "3")}, "3"]). If controller executes some db queries, then console
will contain some info about them (sample screenshot
http://firepy.googlecode.com/files/firepy.png). This is very
interesting to know raw SQL-queries (especially for eduction, and for
finding redundant or duplicating queries).

Notice: Logs shows only if you are autorized in admin application.
This check prevents from showing debugging logs for non-
administrators.

One disadvantage of this way is that it requires Firefox. But if you
open your site in other browsers no errors will occur (logging info
passes via HTTP headers). One possible way to support other browsers
is to use Firebug Lite (pure JS implementation of extension) for them
(http://getfirebug.com/lite.html) and modify or extend its code for
adding FirePHP functionality.

BTW, web2py is great, I really was charmed with it. It is most pytonic
web framework and more flexible than most of them (I think it beats
Django as well). Such debugging possibility will be a nice addition
for it.

Álvaro Justen [Turicas]

unread,
Jun 3, 2009, 7:33:32 AM6/3/09
to web...@googlegroups.com
Really cool! Congratulations for this work and exaplanation!

2009/6/3 sgtpep <danil...@gmail.com>:


--
Álvaro Justen
Peta5 - Telecomunicações e Software Livre
21 3021-6001 / 9898-0141
http://www.peta5.com.br/

mdipierro

unread,
Jun 3, 2009, 10:00:21 AM6/3/09
to web2py Web Framework
You are now officially our firebug expert!

Massimo

On Jun 3, 5:19 am, sgtpep <danil.m...@gmail.com> wrote:
> Unfortunately I have no expirience in screencasting, and my English is
> buggy.
>
> Debugging/logging tool is very useful thing for web development. I
> really like this one in Symfony framework (it is included to Symfony
> and made with JavaScript, screenshot -http://www.symfony-project.org/blog/2008/08/27/new-in-symfony-1-2-cus...).
> For Django there is third-party module Django Debug Toolbar (http://
> rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/).
>
> I think the most valuable things that this type of tools can show for
> developer are: accessible report to server-side logs pre request, info
> about queries executed during request and maybe some cache stats and
> variables list.
>
> Firebug (http://getfirebug.com/) is the most popular Firefox extension
> for web developent, very handy and well-built. It implements
> JavaScript console, DOM traversing, JS-debugging and lot more. FirePHP
> (http://www.firephp.org/) is another extension that uses Firebug
> interface and resources and therefore requires Firebug for work. You
> can see demo here (Firefox with both extensions required, open and
> enable Firebug console to see output) -http://www.firephp.org/Examples/PHPArchitect/.
> In two words, FirePHP allows you to output log messages that you
> passed from PHP code, displays executed db queries, stack trace of
> exceptions, etc. It requires of using PHP class FirePHPCore/
> FirePHP.class.php. Firepy (documentation and screenshot -http://code.google.com/p/firepy/wiki/Documentation) is the
> implementation for Python of the server-side FirePHP library, but it
> uses the same Firefox extension (FirePHP). And it includes Middleware
> for using with Django, but you can easily adopt it for any Python
> framework.
>
> How-to for using FirePHP with web2py:
> 1) Open Firefox, install Firebug, FirePHP addons:https://addons.mozilla.org/ru/firefox/addon/1843,https://addons.mozilla.org/en-US/firefox/addon/6149. Restart browser.
> 2) Downloadhttp://www.box.net/shared/dtm0dhgze9and extract 'firepy'
> folder.
> 3) Open directory with your current web2py application, and copy
> 'firepy' folder into 'modules' directory of application.
> 4) Edit first file in 'models' folder in your application (via web- or
> desktop-editor). Place these lines in top of the file:
>
> import sys
> sys.path += ['applications/%s/modules' % request.application]
> from firepy.web2py import start_firepy
> start_firepy(globals())
>
> 5) Edit some controller file and add this line to some controller
> function: logging.debug([1, {"asdf":(123, 2, "3")}, "3"])
> 6) Click on bug icon on bottom status line of Firefox. This will bring
> up panel. Check the checkbox "Console" and click "Apply settings".
> Ensure that tab "Console" is showing.
> 7) Navigate from browser to this application/controller/function. And
> now you should see your logging output in console ([1, {"asdf":(123,
> 2, "3")}, "3"]). If controller executes some db queries, then console
> will contain some info about them (sample screenshothttp://firepy.googlecode.com/files/firepy.png). This is very

sgtpep

unread,
Jun 10, 2009, 3:12:14 PM6/10/09
to web2py Web Framework
Newer version uploaded and accessible by the link above.

You can see screenshot of what you'll get:
http://www.picamatic.com/view/3948659_109510221650-My-Desktop/

What's added:
- skipping web2py debug messages (starts with "WEB2PY CRON")
- situations: you have a page with self-submitting form or one view
redirects to other, and all them executes some db queries; now you can
see the request path and method (post/get) of latest executed http
requests. If db queries are executed within one http request than this
column is hidden.
- you can see a very simple stack trace of code execution that
initializes each db query. See screenshot. This feature is still
alpha.

TODO:
- show some caching system statistics in form of db query stats (as
FirePHP table): which keys are got, set and so on.
- checking for duplicating db queries and highlighting them.
> > 1) Open Firefox, install Firebug, FirePHP addons:https://addons.mozilla.org/ru/firefox/addon/1843,https://addons.mozil.... Restart browser.
> > 2) Downloadhttp://www.box.net/shared/dtm0dhgze9andextract 'firepy'

mdipierro

unread,
Jun 10, 2009, 3:15:36 PM6/10/09
to web2py Web Framework
How do you propose we include this in web2py? Should I just dump it in
contrib?
I have a feeling this should integrated with the logging function
recently proposed (for that what is logged is also sent to firebug).
What do you think?

Massimo

sgtpep

unread,
Jul 3, 2009, 11:15:04 AM7/3/09
to web2py Web Framework
Sorry for long reply delay. I subscribed to messages in this thread,
but didn't recieved any notifications for some reason.
Yes, I found this debugging solution very handy. It could be
transparent for newbie, but useful for experienced user.
Group user ceej discovered another logging Firefox extension,
FirePython: http://groups.google.com/group/web2py/browse_thread/thread/4629c3984a66cb07
I will check this out and will try to produce some code for merging
with web2py trunk and a bit of documentation.

On 10 июн, 23:15, mdipierro <mdipie...@cs.depaul.edu> wrote:
> How do you propose we include this in web2py? Should I just dump it in
> contrib?
> I have a feeling this should integrated with the logging function
> recently proposed (for that what is logged is also sent to firebug).
> What do you think?
>
> Massimo
>
> On Jun 10, 2:12 pm, sgtpep <danil.m...@gmail.com> wrote:
>
> > Newer version uploaded and accessible by the link above.
>
> > You can see screenshot of what you'll get:http://www.picamatic.com/view/3948659_109510221650-My-Desktop/
>
> > What's added:
> > - skipping web2py debug messages (starts with "WEB2PY CRON")
> > - situations: you have a page with self-submitting form or one view
> > redirects to other, and all them executes some db queries; now you can
> > see the request path and method (post/get) of latest executed http
> > requests. If db queries are executed within one http request than this
> > column is hidden.
> > - you can see a very simple stack trace of code execution that
> > initializes each db query. See screenshot. This feature is still
> > alpha.
>
> > TODO:
> > - show some caching system statistics in form of db query stats (as
> >FirePHPtable): which keys are got, set and so on.
> > - checking for duplicating db queries and highlighting them.
>
> > On 3 июн, 18:00, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > You are now officially our firebug expert!
>
> > > Massimo
>
> > > On Jun 3, 5:19 am, sgtpep <danil.m...@gmail.com> wrote:
>
> > > > Unfortunately I have no expirience in screencasting, and my English is
> > > > buggy.
>
> > > > Debugging/logging tool is very useful thing for web development. I
> > > > really like this one in Symfony framework (it is included to Symfony
> > > > and made with JavaScript, screenshot -http://www.symfony-project.org/blog/2008/08/27/new-in-symfony-1-2-cus...).
> > > > For Django there is third-party module Django Debug Toolbar (http://
> > > > rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/).
>
> > > > I think the most valuable things that this type of tools can show for
> > > > developer are: accessible report to server-side logs pre request, info
> > > > about queries executed during request and maybe some cache stats and
> > > > variables list.
>
> > > > Firebug (http://getfirebug.com/) is the most popular Firefox extension
> > > > for web developent, very handy and well-built. It implements
> > > > JavaScript console, DOM traversing, JS-debugging and lot more.FirePHP
> > > > (http://www.firephp.org/) is another extension that uses Firebug
> > > > interface and resources and therefore requires Firebug for work. You
> > > > can see demo here (Firefox with both extensions required, open and
> > > > enable Firebug console to see output) -http://www.firephp.org/Examples/PHPArchitect/.
> > > > In two words,FirePHPallows you to output log messages that you
> > > > passed from PHP code, displays executed db queries, stack trace of
> > > > exceptions, etc. It requires of using PHP class FirePHPCore/
> > > >FirePHP.class.php. Firepy (documentation and screenshot -http://code.google.com/p/firepy/wiki/Documentation) is the
> > > > implementation for Python of the server-sideFirePHPlibrary, but it
> > > > uses the same Firefox extension (FirePHP). And it includes Middleware
> > > > for using with Django, but you can easily adopt it for any Python
> > > > framework.
>
> > > > How-to for usingFirePHPwith web2py:
> > > > 1) Open Firefox, install Firebug,FirePHPaddons:https://addons.mozilla.org/ru/firefox/addon/1843,https://addons.mozil.... Restart browser.
> > > > > > >FirePHPaddon for using Firebug facilities for server side debugging/
> > > > > > > logging. And recently I found firepy (http://code.google.com/p/
> > > > > > > firepy/). It makes available to useFirePHPwith Django.

faultyzebra

unread,
Nov 24, 2011, 4:13:30 PM11/24/11
to web...@googlegroups.com
Hello,

The file is not available at this link http://www.box.net/shared/dtm0dhgze9 anymore. 
Can you re-upload it or make it available in any other form? 

Your gesture will be highly appreciated.
Regards,
FZ
Reply all
Reply to author
Forward
0 new messages