Re: Well formed XML for RESTful web services ...

2008-12-08 Thread Rob

Thanks Jay and lightlitch, I will give this a shot. I got a similar
suggestion about writing a DBO source to dump the showLog output to a
table on the IRC channel.

Only bit I still can't figure out is why having the debug > 1 would
change my content-type.

Anyway if I get this figured out I'll post my answer.

Thanks again.

On Dec 7, 7:13 pm, "Jay Reeder" <[EMAIL PROTECTED]> wrote:
> We use a "debug" datasource that routes the showLog output to firebug as
> well.  You can enable this datasource while debugging (instead of using the
> mysql driver) and when done, re-enable the mysql driver.
>
> ex:
>
> require_once (LIBS . 'model' . DS . 'datasources' . DS .
> 'dbo_source.php');
> require_once (LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS .
> 'dbo_mysql.php');
>
> class DboMysqlExSource extends DboMysql {
>     var $description = "MySQL DBO Driver - Extended";
>
>     function showLog($sorted = false) {
>
>         if ($sorted) {
>             $log = sortByKey($this->_queriesLog, 'took', 'desc',
> SORT_NUMERIC);
>         } else {
>             $log = $this->_queriesLog;
>                }
>
>         if ($this->_queriesCnt > 1) {
>             $text = 'queries';
>         } else {
>             $text = 'query';
>             }
>         fb("({$this->configKeyName}) {$this->_queriesCnt} {$text} took
> {$this->_queriesTime} ms\n");
>         foreach ($log as $k => $i) {
>             fb (($k +1) . ". {$i['query']} {$i['error']}\n");
>             fb ("\tAffected: {$i['affected']}\tTook:{$i['took']} ms\n");
>             }
>         }
>     }
>
> On Sun, Dec 7, 2008 at 2:13 PM, lightglitch <[EMAIL PROTECTED]> wrote:
>
> > Maybe this will help you:
>
> >http://www.firephp.org/Wiki/Libraries/CakePHP
>
> > On Dec 7, 4:32 am, Rob <[EMAIL PROTECTED]> wrote:
> > > No, I don't expect Cake to format the output at all since we are doing
> > > MVC.
>
> > > I want to use the debug output without it affecting my HTTP stream.
>
> > > The bug/problem is that if debug > 1, the content type gets flipped to
> > > text/html, and the SQL debug gets appended to the XML (after the end
> > > of the HTML because it's being output directly from the dbo_source.php
>
> > > If we're truly doing MVC, there should never be debug information
> > > going directly to the view, and the debug information should be
> > > accessible in the model to the controller so we can decide how to deal
> > > with it.
>
> > > Say for instance I have debug set to 1 to catch errors. Now in my
> > > controller code, I have to turn off debug for XML, so I don't get any
> > > chance to catch those errors, which may or may not need to be dealt
> > > with.
>
> > > I know the workaround is to detect that I'm doing XML and set debug to
> > > 0, but that doesn't help in development in any way.
>
> > > Formatting the debug data and spitting it into the view like it does
> > > is violating the MVC design (while it is nice when you're debugging
> > > HTML).
>
> > > On Dec 6, 6:31 pm, James K <[EMAIL PROTECTED]> wrote:
>
> > > > Not sure I understand the problem. Do you expect Cake to format it's
> > > > debug information based on the content type? It's debug information -
> > > > it's meant for debugging.
>
> > > > You can type Configure::write('debug', 0) at the top of any action in
> > > > order to lower the debug level selectively per action without having
> > > > to shut if off for the entire app.
>
> > > > I have lots of views in a particular application that return XML or
> > > > JSON, and of course having debug info at the bottom of that response
> > > > will break those requests. Once I confirm the response is returning
> > > > correctly formatted XML or JSON, I turn the debugging off for that
> > > > action and only turn it back on in that action in the event I need
> > > > to debug :P
>
> > > > Good luck,
> > > > James
>
> > > > On Dec 6, 6:24 pm, Rob <[EMAIL PROTECTED]> wrote:
>
> > > > > I'll probably get no response or flames telling me to "just set debug
> > > > > to 1", but 
>
> > > > > I've set up my VolunteerCake code to be a RESTful web service by
> > using
> > > > > the Router::parseExtensions() and Router::mapResources() magic. This
> > > > > works fine as long as debug is not greater than 1.
>
> > > > > When debug is greater than 1 however, the XML that gets returned is
> > > > > broken due to problems with the way the SQL debug is spit out.
>
> > > > > I traced this down to a call In the close() function of
> > > > > dbo_source.php, to showLog() which spits out the SQL in an HTML table
>
> > > > > I call the web service and get the XML as expected. The closing XML
> > is
> > > > > followed by the dump of the SQL like:
>
> > > > >        > > > > id="cakeSqlLog_1228604311493b0397a19568_61229664" summary="Cake SQL
> > > > > Log" cellspacing="0" border = "0">
> > > > >       (default) 36 queries took 127 ms
>
> > > > > Other web service tools I've worked with operate by giving you access
> > > > > to the debug data so you can spit 

Re: Well formed XML for RESTful web services ...

2008-12-07 Thread Jay Reeder
We use a "debug" datasource that routes the showLog output to firebug as
well.  You can enable this datasource while debugging (instead of using the
mysql driver) and when done, re-enable the mysql driver.

ex:

require_once (LIBS . 'model' . DS . 'datasources' . DS .
'dbo_source.php');
require_once (LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS .
'dbo_mysql.php');

class DboMysqlExSource extends DboMysql {
var $description = "MySQL DBO Driver - Extended";

function showLog($sorted = false) {

if ($sorted) {
$log = sortByKey($this->_queriesLog, 'took', 'desc',
SORT_NUMERIC);
} else {
$log = $this->_queriesLog;
   }

if ($this->_queriesCnt > 1) {
$text = 'queries';
} else {
$text = 'query';
}
fb("({$this->configKeyName}) {$this->_queriesCnt} {$text} took
{$this->_queriesTime} ms\n");
foreach ($log as $k => $i) {
fb (($k +1) . ". {$i['query']} {$i['error']}\n");
fb ("\tAffected: {$i['affected']}\tTook:{$i['took']} ms\n");
}
}
}

On Sun, Dec 7, 2008 at 2:13 PM, lightglitch <[EMAIL PROTECTED]> wrote:

>
> Maybe this will help you:
>
> http://www.firephp.org/Wiki/Libraries/CakePHP
>
> On Dec 7, 4:32 am, Rob <[EMAIL PROTECTED]> wrote:
> > No, I don't expect Cake to format the output at all since we are doing
> > MVC.
> >
> > I want to use the debug output without it affecting my HTTP stream.
> >
> > The bug/problem is that if debug > 1, the content type gets flipped to
> > text/html, and the SQL debug gets appended to the XML (after the end
> > of the HTML because it's being output directly from the dbo_source.php
> >
> > If we're truly doing MVC, there should never be debug information
> > going directly to the view, and the debug information should be
> > accessible in the model to the controller so we can decide how to deal
> > with it.
> >
> > Say for instance I have debug set to 1 to catch errors. Now in my
> > controller code, I have to turn off debug for XML, so I don't get any
> > chance to catch those errors, which may or may not need to be dealt
> > with.
> >
> > I know the workaround is to detect that I'm doing XML and set debug to
> > 0, but that doesn't help in development in any way.
> >
> > Formatting the debug data and spitting it into the view like it does
> > is violating the MVC design (while it is nice when you're debugging
> > HTML).
> >
> > On Dec 6, 6:31 pm, James K <[EMAIL PROTECTED]> wrote:
> >
> > > Not sure I understand the problem. Do you expect Cake to format it's
> > > debug information based on the content type? It's debug information -
> > > it's meant for debugging.
> >
> > > You can type Configure::write('debug', 0) at the top of any action in
> > > order to lower the debug level selectively per action without having
> > > to shut if off for the entire app.
> >
> > > I have lots of views in a particular application that return XML or
> > > JSON, and of course having debug info at the bottom of that response
> > > will break those requests. Once I confirm the response is returning
> > > correctly formatted XML or JSON, I turn the debugging off for that
> > > action and only turn it back on in that action in the event I need
> > > to debug :P
> >
> > > Good luck,
> > > James
> >
> > > On Dec 6, 6:24 pm, Rob <[EMAIL PROTECTED]> wrote:
> >
> > > > I'll probably get no response or flames telling me to "just set debug
> > > > to 1", but 
> >
> > > > I've set up my VolunteerCake code to be a RESTful web service by
> using
> > > > the Router::parseExtensions() and Router::mapResources() magic. This
> > > > works fine as long as debug is not greater than 1.
> >
> > > > When debug is greater than 1 however, the XML that gets returned is
> > > > broken due to problems with the way the SQL debug is spit out.
> >
> > > > I traced this down to a call In the close() function of
> > > > dbo_source.php, to showLog() which spits out the SQL in an HTML table
> >
> > > > I call the web service and get the XML as expected. The closing XML
> is
> > > > followed by the dump of the SQL like:
> >
> > > >> > > id="cakeSqlLog_1228604311493b0397a19568_61229664" summary="Cake SQL
> > > > Log" cellspacing="0" border = "0">
> > > >   (default) 36 queries took 127 ms
> >
> > > > Other web service tools I've worked with operate by giving you access
> > > > to the debug data so you can spit it out as part of the XML if you
> > > > want to, so you end up with something like:
> >
> > > > non-debug datadebug data
> > > > (usually wrapped in a CDATA)
> >
> > > > Ideally Cake shouldn't be changing the content-type and spitting out
> > > > HTML after the well-formed document has been created anyway.
> >
> >
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.co

Re: Well formed XML for RESTful web services ...

2008-12-07 Thread lightglitch

Maybe this will help you:

http://www.firephp.org/Wiki/Libraries/CakePHP

On Dec 7, 4:32 am, Rob <[EMAIL PROTECTED]> wrote:
> No, I don't expect Cake to format the output at all since we are doing
> MVC.
>
> I want to use the debug output without it affecting my HTTP stream.
>
> The bug/problem is that if debug > 1, the content type gets flipped to
> text/html, and the SQL debug gets appended to the XML (after the end
> of the HTML because it's being output directly from the dbo_source.php
>
> If we're truly doing MVC, there should never be debug information
> going directly to the view, and the debug information should be
> accessible in the model to the controller so we can decide how to deal
> with it.
>
> Say for instance I have debug set to 1 to catch errors. Now in my
> controller code, I have to turn off debug for XML, so I don't get any
> chance to catch those errors, which may or may not need to be dealt
> with.
>
> I know the workaround is to detect that I'm doing XML and set debug to
> 0, but that doesn't help in development in any way.
>
> Formatting the debug data and spitting it into the view like it does
> is violating the MVC design (while it is nice when you're debugging
> HTML).
>
> On Dec 6, 6:31 pm, James K <[EMAIL PROTECTED]> wrote:
>
> > Not sure I understand the problem. Do you expect Cake to format it's
> > debug information based on the content type? It's debug information -
> > it's meant for debugging.
>
> > You can type Configure::write('debug', 0) at the top of any action in
> > order to lower the debug level selectively per action without having
> > to shut if off for the entire app.
>
> > I have lots of views in a particular application that return XML or
> > JSON, and of course having debug info at the bottom of that response
> > will break those requests. Once I confirm the response is returning
> > correctly formatted XML or JSON, I turn the debugging off for that
> > action and only turn it back on in that action in the event I need
> > to debug :P
>
> > Good luck,
> > James
>
> > On Dec 6, 6:24 pm, Rob <[EMAIL PROTECTED]> wrote:
>
> > > I'll probably get no response or flames telling me to "just set debug
> > > to 1", but 
>
> > > I've set up my VolunteerCake code to be a RESTful web service by using
> > > the Router::parseExtensions() and Router::mapResources() magic. This
> > > works fine as long as debug is not greater than 1.
>
> > > When debug is greater than 1 however, the XML that gets returned is
> > > broken due to problems with the way the SQL debug is spit out.
>
> > > I traced this down to a call In the close() function of
> > > dbo_source.php, to showLog() which spits out the SQL in an HTML table
>
> > > I call the web service and get the XML as expected. The closing XML is
> > > followed by the dump of the SQL like:
>
> > >        > > id="cakeSqlLog_1228604311493b0397a19568_61229664" summary="Cake SQL
> > > Log" cellspacing="0" border = "0">
> > >       (default) 36 queries took 127 ms
>
> > > Other web service tools I've worked with operate by giving you access
> > > to the debug data so you can spit it out as part of the XML if you
> > > want to, so you end up with something like:
>
> > > non-debug datadebug data
> > > (usually wrapped in a CDATA)
>
> > > Ideally Cake shouldn't be changing the content-type and spitting out
> > > HTML after the well-formed document has been created anyway.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Well formed XML for RESTful web services ...

2008-12-06 Thread Rob

No, I don't expect Cake to format the output at all since we are doing
MVC.

I want to use the debug output without it affecting my HTTP stream.

The bug/problem is that if debug > 1, the content type gets flipped to
text/html, and the SQL debug gets appended to the XML (after the end
of the HTML because it's being output directly from the dbo_source.php

If we're truly doing MVC, there should never be debug information
going directly to the view, and the debug information should be
accessible in the model to the controller so we can decide how to deal
with it.

Say for instance I have debug set to 1 to catch errors. Now in my
controller code, I have to turn off debug for XML, so I don't get any
chance to catch those errors, which may or may not need to be dealt
with.

I know the workaround is to detect that I'm doing XML and set debug to
0, but that doesn't help in development in any way.

Formatting the debug data and spitting it into the view like it does
is violating the MVC design (while it is nice when you're debugging
HTML).


On Dec 6, 6:31 pm, James K <[EMAIL PROTECTED]> wrote:
> Not sure I understand the problem. Do you expect Cake to format it's
> debug information based on the content type? It's debug information -
> it's meant for debugging.
>
> You can type Configure::write('debug', 0) at the top of any action in
> order to lower the debug level selectively per action without having
> to shut if off for the entire app.
>
> I have lots of views in a particular application that return XML or
> JSON, and of course having debug info at the bottom of that response
> will break those requests. Once I confirm the response is returning
> correctly formatted XML or JSON, I turn the debugging off for that
> action and only turn it back on in that action in the event I need
> to debug :P
>
> Good luck,
> James
>
> On Dec 6, 6:24 pm, Rob <[EMAIL PROTECTED]> wrote:
>
> > I'll probably get no response or flames telling me to "just set debug
> > to 1", but 
>
> > I've set up my VolunteerCake code to be a RESTful web service by using
> > the Router::parseExtensions() and Router::mapResources() magic. This
> > works fine as long as debug is not greater than 1.
>
> > When debug is greater than 1 however, the XML that gets returned is
> > broken due to problems with the way the SQL debug is spit out.
>
> > I traced this down to a call In the close() function of
> > dbo_source.php, to showLog() which spits out the SQL in an HTML table
>
> > I call the web service and get the XML as expected. The closing XML is
> > followed by the dump of the SQL like:
>
> >        > id="cakeSqlLog_1228604311493b0397a19568_61229664" summary="Cake SQL
> > Log" cellspacing="0" border = "0">
> >       (default) 36 queries took 127 ms
>
> > Other web service tools I've worked with operate by giving you access
> > to the debug data so you can spit it out as part of the XML if you
> > want to, so you end up with something like:
>
> > non-debug datadebug data
> > (usually wrapped in a CDATA)
>
> > Ideally Cake shouldn't be changing the content-type and spitting out
> > HTML after the well-formed document has been created anyway.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Well formed XML for RESTful web services ...

2008-12-06 Thread James K

Not sure I understand the problem. Do you expect Cake to format it's
debug information based on the content type? It's debug information -
it's meant for debugging.

You can type Configure::write('debug', 0) at the top of any action in
order to lower the debug level selectively per action without having
to shut if off for the entire app.

I have lots of views in a particular application that return XML or
JSON, and of course having debug info at the bottom of that response
will break those requests. Once I confirm the response is returning
correctly formatted XML or JSON, I turn the debugging off for that
action and only turn it back on in that action in the event I need
to debug :P

Good luck,
James

On Dec 6, 6:24 pm, Rob <[EMAIL PROTECTED]> wrote:
> I'll probably get no response or flames telling me to "just set debug
> to 1", but 
>
> I've set up my VolunteerCake code to be a RESTful web service by using
> the Router::parseExtensions() and Router::mapResources() magic. This
> works fine as long as debug is not greater than 1.
>
> When debug is greater than 1 however, the XML that gets returned is
> broken due to problems with the way the SQL debug is spit out.
>
> I traced this down to a call In the close() function of
> dbo_source.php, to showLog() which spits out the SQL in an HTML table
>
> I call the web service and get the XML as expected. The closing XML is
> followed by the dump of the SQL like:
>
>        id="cakeSqlLog_1228604311493b0397a19568_61229664" summary="Cake SQL
> Log" cellspacing="0" border = "0">
>       (default) 36 queries took 127 ms
>
> Other web service tools I've worked with operate by giving you access
> to the debug data so you can spit it out as part of the XML if you
> want to, so you end up with something like:
>
> non-debug datadebug data
> (usually wrapped in a CDATA)
>
> Ideally Cake shouldn't be changing the content-type and spitting out
> HTML after the well-formed document has been created anyway.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Well formed XML for RESTful web services ...

2008-12-06 Thread Rob

I'll probably get no response or flames telling me to "just set debug
to 1", but 

I've set up my VolunteerCake code to be a RESTful web service by using
the Router::parseExtensions() and Router::mapResources() magic. This
works fine as long as debug is not greater than 1.

When debug is greater than 1 however, the XML that gets returned is
broken due to problems with the way the SQL debug is spit out.


I traced this down to a call In the close() function of
dbo_source.php, to showLog() which spits out the SQL in an HTML table

I call the web service and get the XML as expected. The closing XML is
followed by the dump of the SQL like:

  
  (default) 36 queries took 127 ms

Other web service tools I've worked with operate by giving you access
to the debug data so you can spit it out as part of the XML if you
want to, so you end up with something like:

non-debug datadebug data
(usually wrapped in a CDATA)

Ideally Cake shouldn't be changing the content-type and spitting out
HTML after the well-formed document has been created anyway.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Well formed XML for RESTful web services ...

2008-12-06 Thread Rob

I'll probably get no response or flames telling me to "just set debug
to 1", but 

I've set up my VolunteerCake code to be a RESTful web service by using
the Router::parseExtensions() and Router::mapResources() magic. This
works fine as long as debug is not greater than 1.

When debug is greater than 1 however, the XML that gets returned is
broken due to problems with the way the SQL debug is spit out.


I traced this down to a call In the close() function of
dbo_source.php, to showLog() which spits out the SQL in an HTML table

I call the web service and get the XML as expected. The closing XML is
followed by the dump of the SQL like:

  
  (default) 36 queries took 127 ms

Other web service tools I've worked with operate by giving you access
to the debug data so you can spit it out as part of the XML if you
want to, so you end up with something like:

non-debug datadebug data
(usually wrapped in a CDATA)

Ideally Cake shouldn't be changing the content-type and spitting out
HTML after the well-formed document has been created anyway.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---