Re: [Catalyst] Xml data to html
Howdy, I expect you could understand me... As already stated on the list, this is not Catalyst's work. You'll want to use XML::LibXML, XML::LibXSLT or XML::Twig for this matter instead. Here is a little sample of what you can do with XML::LibXSLT (by chance, I'm currently deep into this at the office ;^): - libraries.xml (fixed for it wasn't valid) ?xml version='1.0' encoding='ISO-8859-1'? libraries library name=Wolf book name=The King/ book name=The Queen/ /library library name=Fox book name=The Castle/ book name=The Dragon/ /library /libraries - xml_to_html.xsl ?xml version='1.0' encoding='ISO-8859-1'? xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xsl:output method='html' encoding='ISO-8859-1' indent='yes'/ xsl:template match='libraries' html head titlePedro's Libraries/title meta name=generator content=xml_to_html.xsl/ link rel=stylesheet href=css/html.css type=text/css/ /head body h1Pedro's Libraries/h1 xsl:apply-templates/ /body /html /xsl:template xsl:template match='library' h2xsl:value-of select='@name'/ Library/h2 table xsl:apply-templates/ /table /xsl:template xsl:template match='book' trtdxsl:value-of select='@name'//td/tr /xsl:template /xsl:stylesheet - xml_to_html #!/usr/local/bin/perl use strict; use warnings; use XML::LibXSLT; use XML::LibXML; my $xslted_dom = transform ( document_file = 'libraries.xml', stylesheet_file = 'xml_to_html.xsl' ); print $xslted_dom-toString ( 1 ); # or toFile ( 'libraries.html', 1 ) see perldoc XML::LibXML::Document sub transform { my ( %h ) = @_; my $xml_parser = XML::LibXML-new; my $xslt_parser = XML::LibXSLT-new; $xml_parser-validation ( 0 ); # perldoc XML::LibXML::Parser $xml_parser-load_ext_dtd ( 0 ); my $xml_dom= $xml_parser-parse_file ( $h{document_file} ); my $xsl_dom= $xml_parser-parse_file ( $h{stylesheet_file} ); my $stylesheet = $xslt_parser-parse_stylesheet ( $xsl_dom ); $stylesheet-transform ( $xml_dom, @{$h{parameter_list}} ); } FYI, xml_to_html is Perl equivalent for xsltproc (libxslt) point-tool: % xsltproc xml_to_html.xsl libraries.xml This should help you for this XSLT rather steep learning curve. Cheers, X. ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Xml data to html
On Sep 15, 2008, at 21:53 , Pedro Guevara wrote: Well I thought to make a script but It's going to take me a lot of time. Because is a complex tree of data, so I supossed that some module of Catalyst would do it for me. It's like libraries library name=Wolf book name=The King book name=The Queen /library library name=Fox book name=The Castle book name=The Dragon /library libraries And it retrieves: like html Libraries table tr tdLibrary :/tdtd Wolf/td tdBooks:/tdtd The King,The Queen/td /tr tr tdLibrary :/tdtd Fox/td td Books:/tdtd The Castle,The Dragon/td /tr /table Like everyone else I can only say that this has nothing to do with Catalyst. But what the heck. It's a trivial conversion, so simple that you don't even need XSLT (though you can still use it, I probably would). Old school approach: use XML::LibXML; my $doc = XML::LibXML-new-parse_file('libraries.xml'); print table\n; for my $lib ($doc-getElementsByTagNameNS(undef, 'library')) { print tr\ntdLibrary:/tdtd . $lib-getAttributeNS(undef, 'name') . /td\ntdBooks:/tdtd . join(', ', map { $_-getAttributeNS(undef, 'name') } $lib- getElementsByTagNameNS(undef, 'book')) . /td\n /tr\n; } print /table\n; I haven't tested the above, but if it doesn't work something a lot like it will. -- Robin Berjon - http://berjon.com/ Feel like hiring me? Go to http://robineko.com/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
RE: [Catalyst] Switching to a production server
Thanks, I read your suggestions and opinions and am switching to fastcgi with apache. I'd like to do this in steps: 1. Install FCGI::ProcManager 2. Run myapp_fastcgi.pl from the command line, just like myapp_server.pl 3. Then go through apache with mod_fastcgi. I am on step 2, and I am thinking that I can't do that with that fastcgi script like I can with myapp_server.pl. I need to combine 2 and 3? E -Original Message- From: ivorw [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 10, 2008 1:34 AM To: catalyst@lists.scsys.co.uk Subject: Re: [Catalyst] Switching to a production server Emily Heureux wrote: Hi, I have been developing a Catalyst application and just using the Catalyst myapp_server.pl script to run it. We server a very small market, currently less than 100 visits a day. The major issue we are having is that even small images are loaded very slowly, and therefore the pages are loaded slowly, on the order of more than 5 seconds for a first time visitor. At this time, I don't know anything about fast_cgi or configuring apache or what have you, to work with Catalyst, but before I take that on, my question is, is it likely that the slow loading of very small images has to do with the default myapp_server.pl, and switching to something else will make a big difference with loading images and possibly other files? I don't recommend going live by running myapp_server.pl - this is intended for development and debugging. I do recommend using a standalone fastcgi process farm (which could have just a single instance), talking through a named pipe in the /tmp directory. The fastcgi process runs in your application user account, saving you from having to open up the permissions of your files to the www-data user. This is quite well documented, see http://search.cpan.org/~mramberg/Catalyst- Runtime/lib/Catalyst/Engine/FastCGI.pm Also apart from in special circumstances, there's usually no reason to serve images through your Catalyst application. The special circumstances I imagine could be if the image is being stored in a database blob, or being tweaked on the fly with ImageMagick. One option could be to change the URLs for the images to be absolute ones on the webserver, rather than static/images/powered_by.jpg etc. which will deliver performance results with myapp_server.pl. You'd need to copy the root/static/images directory to somewhere more public, where the www-data user can see and use it. A recommended, documented option is to configure Apache to handle /static rather than pass these requests to the application with the following config snippet: Location /static SetHandler default-handler /Location For more on configuring Apache 2.0, see http://search.cpan.org/~agrundma/Catalyst-Engine- Apache/lib/Catalyst/Engine/Apache2/MP20.pm Please bear it in mind that most of the information in this Pod is about configuring your Catalyst app to run under mod_perl. I much prefer fastcgi as it gives me much more control and awareness of machine resources, keeps my permissions sane, and allows me to run multiple different Catalyst applications and versions on the same box. Ivor. ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail- archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] [patch] Catalyst::Authentication::Store::DBIx::Class's authenticate parameters Documentation
On Tue, 16 Sep 2008, Jason Kuri wrote: I've updated the id_field documentation, hopefully to clear things up. I'll see about pushing a new rev up in the next few days. The new id_field doc snippit is below. =item id_field ... Note that this is used BONLY when restoring a user from the session and has no bearing whatsoever in the initial authentication process. Note also that if use_userdata_from_session is enabled, this config parameter is not used at all. --- snip --- Does that clear things up for you? Thanks, that helps. Setting id_field in the configuration to Catalyst::Authentication::Store::DBIx::Class, I was just cargo-culting from the Catalyst::Manual::Tutorial::Authentication documentation. If I hadn't seen it there, I wouldn't have tried fiddling with it. And I see the reason my application started working was not so much my fiddling with id_field, as my accidental inclusion of the primary key in the arguments to authenticate. Perhaps the id_field option should be removed from the Tutorial. ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/