Re: How to enable a CSV webservice?
It actually seems to work just fine either way in IE and FireFox. I only have them after the foreach because for some reason it wasn't playing nice with Safari when I had the header() calls first (and Safari is the browser of choice for a lot of people in my company, so it HAS to work there first and foremost). Damned if I know why, though. -Kionae On May 29, 3:58 pm, "Gonzalo Servat" <[EMAIL PROTECTED]> wrote: > On 5/29/07, Howard Glynn <[EMAIL PROTECTED]> wrote: > klonae: just wondering, shouldn't the header() calls be made just before the > foreach begins? > > - Gonzalo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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: How to enable a CSV webservice?
What about a view like this. I have not tested but extracted from a view in one project that is a little more complex but it is just as an example. hth Da: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] Per conto di Gonzalo Servat Inviato: martedì 29 maggio 2007 22.59 A: cake-php@googlegroups.com Oggetto: Re: How to enable a CSV webservice? On 5/29/07, Howard Glynn <[EMAIL PROTECTED]> wrote: Slightly bad karma to reply to one's own post so soon, but after continuing to investigate, I'd like to provide a solution for the mail archives. I just didn't fully understand the route handling up until this point, but the light is starting to go on for me. I have subsequently found 2 ways it can be done: 1) Less agreeable way: change the cake distro libs/router.php around line 147, adding: $this->connect('/csv/:controller/:action/*', array('webservices' => 'Csv')); 2) More agreeable, add to the application app/config/routes.php $Route->connect('/csv/:controller/:action/*', array('webservices' => 'Csv')); I am well aware that CSV is not a webservice as such but I want the CSV output availability to be consistent with the XML approach. Is your requirement strictly CSV or can it be an actual Excel file? I found this article recently at bakery.cakephp.org (which I plan on using) to create an XLS file from database records: http://bakery.cakephp.org/articles/view/generate-excel-spreadsheets-from-you r-database <http://bakery.cakephp.org/articles/view/generate-excel-spreadsheets-from-yo ur-database> If it's strictly CSV what you need, then it won't help, but I think what klonae said is probably the simplest way. klonae: just wondering, shouldn't the header() calls be made just before the foreach begins? - Gonzalo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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: How to enable a CSV webservice?
On 5/29/07, Howard Glynn <[EMAIL PROTECTED]> wrote: > > Slightly bad karma to reply to one's own post so soon, but after > continuing to investigate, > I'd like to provide a solution for the mail archives. I just didn't fully > understand the route handling up until this point, but the light is starting > to go on for me. I have subsequently found 2 ways it can be done: > > 1) Less agreeable way: change the cake distro libs/router.php around line > 147, adding: > > $this->connect('/csv/:controller/:action/*', > array('webservices' => 'Csv')); > > 2) More agreeable, add to the application app/config/routes.php > > $Route->connect('/csv/:controller/:action/*', array('webservices' > => 'Csv')); > > I am well aware that CSV is not a webservice as such but I want the CSV > output availability to be consistent with the XML approach. Is your requirement strictly CSV or can it be an actual Excel file? I found this article recently at bakery.cakephp.org (which I plan on using) to create an XLS file from database records: http://bakery.cakephp.org/articles/view/generate-excel-spreadsheets-from-your-database If it's strictly CSV what you need, then it won't help, but I think what klonae said is probably the simplest way. klonae: just wondering, shouldn't the header() calls be made just before the foreach begins? - Gonzalo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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: How to enable a CSV webservice?
/me bangs himself over the head several times and decides he should stop answering emails on his blackberry or really read emails through first before deciding to answer I actually do have some code lying about that outputs to CSV from a database - although I've not used it in cake yet, its just an old class I wrote which could be plugged in as a vendor. But at the moment I'm hurtling down the M8 on a bus so I won't have access to it until later. Tane On 5/29/07, Tane Piper <[EMAIL PROTECTED]> wrote: > Do'h ignore that last message - I read CSV as CVS :) > > Yea, I agree with chris - this doesn't sound like a service, you could > probably create a component/helper that can do the work for you. I'd > say read the file one line at a time, explode each comma seperated > value into an array and save it to the db. > > I was actually looking at this today as part of something else I > wanted to do (use XSL-FO to covert xsl and csv files to PDF on > upload). > > There might even be a class on PHPclasses.com that you could put in > your vendor dir, could save on a lot of code. > > Tane > > > On 5/29/07, Tane Piper <[EMAIL PROTECTED]> wrote: > > Hello fellow Embra Cake developer :) > > > > I'm not 100% sure, but if your not tied to CVS, check out Trac for > > running a backend SVN server. There is an XML-RPC plugin for it that > > allows you to make calls to it. > > > > I'm not sure on the source side, but it definetly let's you make calls > > to the ticket tracker - adding/viewing/editing tickets. That's how > > Mylar for Eclipse works, and it ties in nicely. > > > > Tane > > http://webrocket.wordpress.com > > > > > > On 5/29/07, Howard Glynn <[EMAIL PROTECTED]> wrote: > > > I have successfully used the XML webservice to export my records in > > > that form as well as a regular html view just by varying the url > > > > > > The manual describes webservices as "rss, xml, rest, soap, xmlrpc" > > > (Section 4 Advanced routing > > http://manual.cakephp.org/chapter/configuration) > > > > > > I know CSV is not strictly a webservice, but I would dearly love to add > it > > > to this list as the consumers on my app expect to be able to paste into > > > a spreadsheet, and this would be very convenient in terms of consistency > > > > > > Can anyone point me in the right direction of how I do this? > > > > > > I tried following the pattern for xml (items/xml/view.thtml, > > > layouts/xml/default.thtml etc) > > > but each time I try to go to a URL like http:///csv/items/view/1234 > > > ... I get an error about a missing CSV controller. I suspect I just need > > to > > > update some file > > > or configuration or route to sort this out > > > > > > Am I missing something obvious? > > > Howard > > > > > > -- > > > -- > > > Howard Glynn [ [EMAIL PROTECTED] ] > > > Edinburgh, UK > > > > > > > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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: How to enable a CSV webservice?
On 5/29/07, Howard Glynn <[EMAIL PROTECTED]> wrote: > I am well aware that CSV is not a webservice as such but I want the CSV > output availability to be consistent with the XML approach. > > Cheers, Howard You are overcomplicating what appears to me (at least) a simple solution. Why can't you just create a csv controller with actions that read in the data, format it into CSV and then spit it out via a view. Am I missing something? You're doing all this nonsense with routes, etc, to gain what exactly? -- Chris Hartjes My motto for 2007: "Just build it, damnit!" @TheBallpark - http://www.littlehart.net/attheballpark @TheKeyboard - http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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: How to enable a CSV webservice?
Slightly bad karma to reply to one's own post so soon, but after continuing to investigate, I'd like to provide a solution for the mail archives. I just didn't fully understand the route handling up until this point, but the light is starting to go on for me. I have subsequently found 2 ways it can be done: 1) Less agreeable way: change the cake distro libs/router.php around line 147, adding: $this->connect('/csv/:controller/:action/*', array('webservices' => 'Csv')); 2) More agreeable, add to the application app/config/routes.php $Route->connect('/csv/:controller/:action/*', array('webservices' => 'Csv')); I am well aware that CSV is not a webservice as such but I want the CSV output availability to be consistent with the XML approach. Cheers, Howard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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: How to enable a CSV webservice?
Do'h ignore that last message - I read CSV as CVS :) Yea, I agree with chris - this doesn't sound like a service, you could probably create a component/helper that can do the work for you. I'd say read the file one line at a time, explode each comma seperated value into an array and save it to the db. I was actually looking at this today as part of something else I wanted to do (use XSL-FO to covert xsl and csv files to PDF on upload). There might even be a class on PHPclasses.com that you could put in your vendor dir, could save on a lot of code. Tane On 5/29/07, Tane Piper <[EMAIL PROTECTED]> wrote: > Hello fellow Embra Cake developer :) > > I'm not 100% sure, but if your not tied to CVS, check out Trac for > running a backend SVN server. There is an XML-RPC plugin for it that > allows you to make calls to it. > > I'm not sure on the source side, but it definetly let's you make calls > to the ticket tracker - adding/viewing/editing tickets. That's how > Mylar for Eclipse works, and it ties in nicely. > > Tane > http://webrocket.wordpress.com > > > On 5/29/07, Howard Glynn <[EMAIL PROTECTED]> wrote: > > I have successfully used the XML webservice to export my records in > > that form as well as a regular html view just by varying the url > > > > The manual describes webservices as "rss, xml, rest, soap, xmlrpc" > > (Section 4 Advanced routing > http://manual.cakephp.org/chapter/configuration) > > > > I know CSV is not strictly a webservice, but I would dearly love to add it > > to this list as the consumers on my app expect to be able to paste into > > a spreadsheet, and this would be very convenient in terms of consistency > > > > Can anyone point me in the right direction of how I do this? > > > > I tried following the pattern for xml (items/xml/view.thtml, > > layouts/xml/default.thtml etc) > > but each time I try to go to a URL like http:///csv/items/view/1234 > > ... I get an error about a missing CSV controller. I suspect I just need > to > > update some file > > or configuration or route to sort this out > > > > Am I missing something obvious? > > Howard > > > > -- > > -- > > Howard Glynn [ [EMAIL PROTECTED] ] > > Edinburgh, UK > > > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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: How to enable a CSV webservice?
This may or may not help. it's not exactly what you want to do, but I don't have much use for CSV. I needed to be able to allow site managers to generate and download an excel spreasheet of user records from the database. In the controller: function excel() { $this->layout = 'excelfile'; $data = $this->Alum->findAll('', array('first_name', 'last_name', 'email'), 'last_name ASC'); $this->set('data', $data); } The excel.thtml view: The excel layout file: This allows them to download a .xsl file by clicking a link that calls the excel function. On May 29, 11:15 am, "Howard Glynn" <[EMAIL PROTECTED]> wrote: > I have successfully used the XML webservice to export my records in > that form as well as a regular html view just by varying the url > > The manual describes webservices as "rss, xml, rest, soap, xmlrpc" > (Section 4 Advanced routinghttp://manual.cakephp.org/chapter/configuration) > > I know CSV is not strictly a webservice, but I would dearly love to add it > to this list as the consumers on my app expect to be able to paste into > a spreadsheet, and this would be very convenient in terms of consistency > > Can anyone point me in the right direction of how I do this? > > I tried following the pattern for xml (items/xml/view.thtml, > layouts/xml/default.thtml etc) > but each time I try to go to a URL likehttp:///csv/items/view/1234 > ... I get an error about a missing CSV controller. I suspect I just need to > update some file > or configuration or route to sort this out > > Am I missing something obvious? > Howard > > -- > -- > Howard Glynn [ [EMAIL PROTECTED] ] > Edinburgh, UK --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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: How to enable a CSV webservice?
Hello fellow Embra Cake developer :) I'm not 100% sure, but if your not tied to CVS, check out Trac for running a backend SVN server. There is an XML-RPC plugin for it that allows you to make calls to it. I'm not sure on the source side, but it definetly let's you make calls to the ticket tracker - adding/viewing/editing tickets. That's how Mylar for Eclipse works, and it ties in nicely. Tane http://webrocket.wordpress.com On 5/29/07, Howard Glynn <[EMAIL PROTECTED]> wrote: > I have successfully used the XML webservice to export my records in > that form as well as a regular html view just by varying the url > > The manual describes webservices as "rss, xml, rest, soap, xmlrpc" > (Section 4 Advanced routing http://manual.cakephp.org/chapter/configuration) > > I know CSV is not strictly a webservice, but I would dearly love to add it > to this list as the consumers on my app expect to be able to paste into > a spreadsheet, and this would be very convenient in terms of consistency > > Can anyone point me in the right direction of how I do this? > > I tried following the pattern for xml (items/xml/view.thtml, > layouts/xml/default.thtml etc) > but each time I try to go to a URL like http:///csv/items/view/1234 > ... I get an error about a missing CSV controller. I suspect I just need to > update some file > or configuration or route to sort this out > > Am I missing something obvious? > Howard > > -- > -- > Howard Glynn [ [EMAIL PROTECTED] ] > Edinburgh, UK > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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: How to enable a CSV webservice?
On 5/29/07, Howard Glynn <[EMAIL PROTECTED]> wrote: > Am I missing something obvious? Well, given that CSV isn't a standard web service, you are missing the obvious. :) You'll have to create a csv controller that passes the data to your csv template. Should be very simple. Of course, I can say that because I don't have to write it. :) -- Chris Hartjes My motto for 2007: "Just build it, damnit!" @TheBallpark - http://www.littlehart.net/attheballpark @TheKeyboard - http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---
How to enable a CSV webservice?
I have successfully used the XML webservice to export my records in that form as well as a regular html view just by varying the url The manual describes webservices as "rss, xml, rest, soap, xmlrpc" (Section 4 Advanced routing http://manual.cakephp.org/chapter/configuration) I know CSV is not strictly a webservice, but I would dearly love to add it to this list as the consumers on my app expect to be able to paste into a spreadsheet, and this would be very convenient in terms of consistency Can anyone point me in the right direction of how I do this? I tried following the pattern for xml (items/xml/view.thtml, layouts/xml/default.thtml etc) but each time I try to go to a URL like http:///csv/items/view/1234 ... I get an error about a missing CSV controller. I suspect I just need to update some file or configuration or route to sort this out Am I missing something obvious? Howard -- -- Howard Glynn [ [EMAIL PROTECTED] ] Edinburgh, UK --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~--~~~~--~~--~--~---