[Catalyst] html escaping question
Hello @all, as you could help me that fast and excellent yesterday I have an other question to you ;) What is the best/common practice to get text that might containt html escapable characters (e. g. '', '') from a form field to catalyst to db and back to form field? At the moment I'm thinking of not doing any html escaping at all and believe in unicode to handle the encoding correctly, but I would ran into problems with 'funname'. So if I escape a string and send it back to the form the content of the textfield is 'lt;funamegt;'. Why is that? Again every thought is allmost welcome. Greets, Mario Minati ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html escaping question
Mario Minati wrote: Hello @all, as you could help me that fast and excellent yesterday I have an other question to you ;) What is the best/common practice to get text that might containt html escapable characters (e. g. '', '') from a form field to catalyst to db and back to form field? At the moment I'm thinking of not doing any html escaping at all and believe in unicode to handle the encoding correctly, but I would ran into problems with 'funname'. So if I escape a string and send it back to the form the content of the textfield is 'lt;funamegt;'. Why is that? Again every thought is allmost welcome. Greets, Mario Minati I'll asume you are using TT since you didn't say otherwise' [% 'funname' | html %] ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Where and how to access database
Hi, I want to place some database queries in App/lib/App/Modell/App.pm. How can I access the DBI database handle in that module? Is that the right place for complex queries? The database tables are being loaded dynamically by Catalyst::Model::DBIC::Schema/ DBIx::Class::Schema::Loader. I read that I can get the DBH via $schema-storage-dbh -- but where do I get $schema from? Thanks for your help, Stephan ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html escaping question
Am Mittwoch 21 März 2007 10:38 schrieb Ash Berlin: Mario Minati wrote: Hello @all, as you could help me that fast and excellent yesterday I have an other question to you ;) What is the best/common practice to get text that might containt html escapable characters (e. g. '', '') from a form field to catalyst to db and back to form field? At the moment I'm thinking of not doing any html escaping at all and believe in unicode to handle the encoding correctly, but I would ran into problems with 'funname'. So if I escape a string and send it back to the form the content of the textfield is 'lt;funamegt;'. Why is that? Again every thought is allmost welcome. Greets, Mario Minati I'll asume you are using TT since you didn't say otherwise' [% 'funname' | html %] You mean I have to filter every form field that way? Or do you mean normal text content? I hope there's a smoother solution otherwise this would be quite a bit of work. How are others solving the problem with this kind of characters in unicode enabled websites? Greets, Mario ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Where and how to access database
Am Mittwoch 21 März 2007 11:39 schrieb Stephan Austermühle: Hi, I want to place some database queries in App/lib/App/Modell/App.pm. How can I access the DBI database handle in that module? Is that the right place for complex queries? Are you sure that your structure is right? Mine is (based on the Tutorial) App/lib/AppDB/Modell/Table.pm The database tables are being loaded dynamically by Catalyst::Model::DBIC::Schema/ DBIx::Class::Schema::Loader. I read that I can get the DBH via $schema-storage-dbh -- but where do I get $schema from? In the table class I can create custom functions to alter or get the resultsets. How complex can a query be that you want the DBI handle? With DBIC you can do almost everything, e.g. multi table joins, creating aliases with user defined functions and procedures. At least for me that's all I want :) Greets, Mario Minati ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Where and how to access database
On Mar 21, 2007, at 7:43 AM, Mario Minati wrote: Am Mittwoch 21 März 2007 11:39 schrieb Stephan Austermühle: The database tables are being loaded dynamically by Catalyst::Model::DBIC::Schema/ DBIx::Class::Schema::Loader. I read that I can get the DBH via $schema-storage-dbh -- but where do I get $schema from? my $dbh = $c-model( 'MyModel' )-schema-storage-dbh; Just be sure you don't hold onto the handle for too long, or strange things can happen (especially in a persistent environment). In the table class I can create custom functions to alter or get the resultsets. How complex can a query be that you want the DBI handle? With DBIC you can do almost everything, e.g. multi table joins, creating aliases with user defined functions and procedures. At least for me that's all I want :) There is at least one thing that I've used this for that DBIx::Class can't do (or at least I couldn't figure out how at the time I needed to do it)... $c-model( 'MyModel' )-schema-storage-dbh-do( NOTIFY update_listener ); -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ A witty saying proves nothing. -- Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Where and how to access database
Hi, my $dbh = $c-model( 'MyModel' )-schema-storage-dbh; Thanks! Am I right with that this will work in Controllers only? Regards, Stephan ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html escaping question
Am Mittwoch 21 März 2007 12:42 schrieb Carl Franks: On 21/03/07, Mario Minati [EMAIL PROTECTED] wrote: Am Mittwoch 21 März 2007 10:38 schrieb Ash Berlin: Mario Minati wrote: What is the best/common practice to get text that might containt html escapable characters (e. g. '', '') from a form field to catalyst to db and back to form field? At the moment I'm thinking of not doing any html escaping at all and believe in unicode to handle the encoding correctly, but I would ran into problems with 'funname'. So if I escape a string and send it back to the form the content of the textfield is 'lt;funamegt;'. Why is that? I'll asume you are using TT since you didn't say otherwise' [% 'funname' | html %] You mean I have to filter every form field that way? Or do you mean normal text content? Mario, Am I right in thinking you're not using formfu in this particular case? Because if you are, H::FF::Element::field::_render_value() already runs all values through H::FF::Util::xml_escape() which escapes the 5 characters ' In which case you may be double-escaping. I am Carl. But how can I circumvent this. Actually it's not a clever question. Is it usefull to circumvent that. My current problem: As the part of my project I am working on at moment deals with companies I have to deal with GmbH Co. KG which is a quite popular type of company in Germany. If a users types that in a form field everything is fine until it comes to editing. The string is escaped - of course. But the user is confused when he sees GmbH amp; Co. KG. How to go about that? Greets, Mario Minati ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Where and how to access database
Am Mittwoch 21 März 2007 14:01 schrieb Stephan Austermühle: Hi, Are you sure that your structure is right? Mine is (based on the Tutorial) App/lib/AppDB/Modell/Table.pm I have named the AppDB like the application because the database is named that way. The file App.pm just contains __PACKAGE__-config( schema_class = 'App::Schema', connect_info = [ 'dbi:mysql:xxx', 'xxx', 'xxx', ], ); Anyway, all tables are dynamically loaded so I assume that configuration is correct for the moment. In the table class I can create custom functions to alter or get the resultsets. Where do you put queries that join multiple tables? I think such queries do not fit well into a Table.pm but in AppDB.pm. In my app they are, but I think we have a different setup. If you are interested I can post on of my table classes. With DBIC you can do almost everything, e.g. multi table joins, creating aliases with user defined functions and procedures. May be you can do anything with DBIC -- at the cost of having to learn it instead of just and easy placing an SQL statement into the code. Maybe DBIC would be more fun if I would have found better documentation. That is why I need to access a dbh. What about the Manual part of the docs, especially the Cookbook helped me a lot: http://search.cpan.org/~jrobinson/DBIx-Class-0.07005/lib/DBIx/Class/Manual/Cookbook.pod Greets, Maro Minati ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html escaping question
On 21/03/07, Mario Minati [EMAIL PROTECTED] wrote: Am Mittwoch 21 März 2007 12:42 schrieb Carl Franks: In which case you may be double-escaping. But how can I circumvent this. Actually it's not a clever question. Is it usefull to circumvent that. My current problem: As the part of my project I am working on at moment deals with companies I have to deal with GmbH Co. KG which is a quite popular type of company in Germany. If a users types that in a form field everything is fine until it comes to editing. The string is escaped - of course. But the user is confused when he sees GmbH amp; Co. KG. Find out which part of your app is double-escaping, and stop it. If your template has just [% form %] there shouldn't be any problem. By default, a field with: default_value('GmbH Co') will render as: value=Gmbh amp; Co the user will see the value as: GmbH Co and when it's submitted, the server will see: GmbH Co ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html escaping question
Mario Minati wrote: snip I am Carl. But how can I circumvent this. Actually it's not a clever question. Is it usefull to circumvent that. My current problem: As the part of my project I am working on at moment deals with companies I have to deal with GmbH Co. KG which is a quite popular type of company in Germany. If a users types that in a form field everything is fine until it comes to editing. The string is escaped - of course. But the user is confused when he sees GmbH amp; Co. KG. How to go about that? Greets, Mario Minati Check at which point the escaping is being done. Is it in your database un-escaped for example? Regards Ian C. Docherty (icydee) ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html escaping question
Am Mittwoch 21 März 2007 15:01 schrieb Carl Franks: On 21/03/07, Mario Minati [EMAIL PROTECTED] wrote: Am Mittwoch 21 März 2007 12:42 schrieb Carl Franks: In which case you may be double-escaping. But how can I circumvent this. Actually it's not a clever question. Is it usefull to circumvent that. My current problem: As the part of my project I am working on at moment deals with companies I have to deal with GmbH Co. KG which is a quite popular type of company in Germany. If a users types that in a form field everything is fine until it comes to editing. The string is escaped - of course. But the user is confused when he sees GmbH amp; Co. KG. Find out which part of your app is double-escaping, and stop it. If your template has just [% form %] there shouldn't be any problem. By default, a field with: default_value('GmbH Co') will render as: value=Gmbh amp; Co the user will see the value as: GmbH Co and when it's submitted, the server will see: GmbH Co You were right, as always ;-) I used the FormFu HTMLEscape Filter and the $amp; in the database got encode a second time while form processing. Thanks again, Mario ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html escaping question
Mario I might have the wrong end of the stick here but I hope you are saying that you are going to fix this by making sure that the database holds the un-escaped text? Regards Ian C Docherty (icydee) Mario Minati wrote: Am Mittwoch 21 März 2007 15:01 schrieb Carl Franks: snip You were right, as always ;-) I used the FormFu HTMLEscape Filter and the $amp; in the database got encode a second time while form processing. Thanks again, Mario ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] html escaping question
Am Mittwoch 21 März 2007 17:19 schrieb Ian Docherty: Hi Ian, yes I kicked out the HTMLEscape Constraint. And the result is a nice '' in the DB (checked with pgadmin III). Thanks for your concern. Greets, Mario Mario I might have the wrong end of the stick here but I hope you are saying that you are going to fix this by making sure that the database holds the un-escaped text? Regards Ian C Docherty (icydee) Mario Minati wrote: Am Mittwoch 21 März 2007 15:01 schrieb Carl Franks: snip You were right, as always ;-) I used the FormFu HTMLEscape Filter and the $amp; in the database got encode a second time while form processing. Thanks again, Mario ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: Announce: Website In A Box
On 20/03/07, Kieren Diment [EMAIL PROTECTED] wrote: OK, some people pointed out problems with the Makefile.PL and the structure of the tarball, so there's already a 0.011 release at http://websiteinabox.googlecode.com/files/WIAB-0.011.tar.gz I've just starting having a play with it. How do you envisage upgrades working? That is, how do I not munge my page about my cats when I svn up? By coincidence, I've been thinking about CMSes for Catalyst for a while, so I'm interested to see how you're approaching it. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: Announce: Website In A Box
Kieren Diment wrote: On 22/03/07, Neil de Carteret [EMAIL PROTECTED] wrote: On 20/03/07, Kieren Diment [EMAIL PROTECTED] wrote: OK, some people pointed out problems with the Makefile.PL and the structure of the tarball, so there's already a 0.011 release at http://websiteinabox.googlecode.com/files/WIAB-0.011.tar.gz I've just starting having a play with it. How do you envisage upgrades working? That is, how do I not munge my page about my cats when I svn up? Well, if you keep your own branch and make sure that you don't merge wiab.yml, auth.txt or root/content, everything should be right for now. Speaking of which at some point I'll have to put some code to store diffs of each page as well :) Funny. I currently loathe this practice, and I blame myself. On any other system, I can change things without doing source merges when an upgrade comes out. So why do good Cat apps have to be any different. The more I work on Mango, the more I have people just using and changing the app, rather than making it all base software, with creation-isms, like catalyst.pl. the more I hate it. The killer is the templates. Custom app modules can inherit from Base software modules. Templates can't...easily, if all. If we could figure that out, all would be better imho. -=Chris signature.asc Description: OpenPGP digital signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: Announce: Website In A Box
Thomas Klausner wrote: Hi! On Wed, Mar 21, 2007 at 04:47:15PM -0400, Christopher H. Laco wrote: Or more to the point... have app supplied templates, and be able to user user customized templates in combination with the app templates...without have to worry about sources, merging, upgrade, etc... I usually (using TT) do something like: INCLUDE_PATH: [base_framework_stuff app_stuff] All the templates go into base_framework_stuff All modifications needed for an app (or maybe even a sub-area of an app) go into app_stuff. You just need to break your templates into enough smallish components. In the end, it feels a lot like OO templates, where you can override the base implementation. I'm glad to see someone else doing this! I've found it works well for my projects and does feel very OO indeed. As Thomas said, it is mostly about finding the right granularity. Not so small as to make it hard to understand a template's function at a glance, but small enough that an override wouldn't step on something you plan to update in a new revision. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Questions about chained actions, endpoints, etc.
Hey guys, this very well may be due purely to my lack of experience in this matter, but I'm having trouble getting chained actions working the way I WANT them to work and I'm suspicious the way I want them to work is not the way they're intended to work. Here's the situation: I want the application to have public paths like these: /admin List of all existing books you can look at /admin/add Form (FormBuilder) for adding a new book /admin/99 Detailed output of data on book 99 /admin/99/edit Form (FormBuilder) for editing book 99 data /admin/99/deleteForm for confirming deletion of book 99 Looking at the Catalyst::DispatchType::Chained documentation, it's not obvious (to me, anyway) how I should go about this. The way I see it, /admin should be handled by a: package Foo::Controller::Admin; sub index : private {...} and /admin/add should be handled by a: sub add : Local Form {...} So, how exactly would someone suggest I set up the chained handlers for the other paths? I had something like this: sub detail :PathPart('admin') Chained('/') Args(1) {...} And that worked for the /admin/99 path, but nothing I can muster up seems to match the /admin/99/{edit,delete} paths. Any thoughts from those more experienced than me? -- [EMAIL PROTECTED] is Doran L. Barton, president/CTO, Iodynamics LLC Iodynamics: IT and Web services by Linux/Open Source specialists Dealers will hear car talk at noon -- Headline seen in newspaper pgpxD5yJNqzWG.pgp Description: PGP signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Questions about chained actions, endpoints, etc.
This is the same layout I have for my chained actions, and I went through the same huh? phase as well. You seem to be on the right track so far. Here is a quick copy / paste / hack job of my layout adapted to your examples. Won't go in to too much detail since I am busy at work, so let me know if this needs clarified further. In Foo::Controller::Admin (left off Form attrib in examples, just showing the chain layout)... # Not chained, responds to /admin sub index : Private { ... } # Not chained, responds to /admin/add sub sub add : Local { ... } # Captures a book id in the chain for use by further chained actions # You would validate the id, grab it from the model, and put it in # the stash here sub get_book : PathPart('admin') Chained CaptureArgs(1) { my ( $self, $c, $id) = @_; ... } # Chain endpoint for viewing book, responds to /admin/99 sub view : PathPart('') Chained('get_book') Args(0) { ... } # Chain endpoint for editing book, responds to /admin/99/edit sub edit : Chained('get_book') Args(0) { ... } # Chain endpoint for deleting book, responds to /admin/99/delete sub delete : Chained('get_book') Args(0) { ... } Hope that helps! Danny Warren Doran L. Barton wrote: Hey guys, this very well may be due purely to my lack of experience in this matter, but I'm having trouble getting chained actions working the way I WANT them to work and I'm suspicious the way I want them to work is not the way they're intended to work. Here's the situation: I want the application to have public paths like these: /admin List of all existing books you can look at /admin/add Form (FormBuilder) for adding a new book /admin/99 Detailed output of data on book 99 /admin/99/edit Form (FormBuilder) for editing book 99 data /admin/99/deleteForm for confirming deletion of book 99 Looking at the Catalyst::DispatchType::Chained documentation, it's not obvious (to me, anyway) how I should go about this. The way I see it, /admin should be handled by a: package Foo::Controller::Admin; sub index : private {...} and /admin/add should be handled by a: sub add : Local Form {...} So, how exactly would someone suggest I set up the chained handlers for the other paths? I had something like this: sub detail :PathPart('admin') Chained('/') Args(1) {...} And that worked for the /admin/99 path, but nothing I can muster up seems to match the /admin/99/{edit,delete} paths. Any thoughts from those more experienced than me? ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Questions about chained actions, endpoints, etc.
A couple of clarifications: 1) I typo'd 'sub sub' below in the 'add' action, whoops! 2) In my example, I should have used 'detail' as the action instead of 'view', to match your layout ('view' is what I use). 3) I think the general confusion on all of this, and I didn't wrap my head around this when I read the Chained perldoc at first either (even though reading it again, it makes sense) is how the 'Chained' attribute behaves. A general rule of thumb I keep in my head is (and this doesn't apply in all situations and special cases, but stays true for most normal chain layouts I have used)... When dealing with 'CaptureArgs' type methods, the 'Chained' attribute refers to parts of the URI path. When dealing with 'Args' type endpoint actions, the 'Chained' attribute refers to the 'CaptureArgs' method we want to chain off of, and has nothing to do with the URI path. Danny Warren Danny Warren wrote: This is the same layout I have for my chained actions, and I went through the same huh? phase as well. You seem to be on the right track so far. Here is a quick copy / paste / hack job of my layout adapted to your examples. Won't go in to too much detail since I am busy at work, so let me know if this needs clarified further. In Foo::Controller::Admin (left off Form attrib in examples, just showing the chain layout)... # Not chained, responds to /admin sub index : Private { ... } # Not chained, responds to /admin/add sub sub add : Local { ... } # Captures a book id in the chain for use by further chained actions # You would validate the id, grab it from the model, and put it in # the stash here sub get_book : PathPart('admin') Chained CaptureArgs(1) { my ( $self, $c, $id) = @_; ... } # Chain endpoint for viewing book, responds to /admin/99 sub view : PathPart('') Chained('get_book') Args(0) { ... } # Chain endpoint for editing book, responds to /admin/99/edit sub edit : Chained('get_book') Args(0) { ... } # Chain endpoint for deleting book, responds to /admin/99/delete sub delete : Chained('get_book') Args(0) { ... } Hope that helps! Danny Warren Doran L. Barton wrote: Hey guys, this very well may be due purely to my lack of experience in this matter, but I'm having trouble getting chained actions working the way I WANT them to work and I'm suspicious the way I want them to work is not the way they're intended to work. Here's the situation: I want the application to have public paths like these: /admin List of all existing books you can look at /admin/add Form (FormBuilder) for adding a new book /admin/99 Detailed output of data on book 99 /admin/99/edit Form (FormBuilder) for editing book 99 data /admin/99/deleteForm for confirming deletion of book 99 Looking at the Catalyst::DispatchType::Chained documentation, it's not obvious (to me, anyway) how I should go about this. The way I see it, /admin should be handled by a: package Foo::Controller::Admin; sub index : private {...} and /admin/add should be handled by a: sub add : Local Form {...} So, how exactly would someone suggest I set up the chained handlers for the other paths? I had something like this: sub detail :PathPart('admin') Chained('/') Args(1) {...} And that worked for the /admin/99 path, but nothing I can muster up seems to match the /admin/99/{edit,delete} paths. Any thoughts from those more experienced than me? ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Questions about chained actions, endpoints, etc.
Danny, Thanks for your reply. I finally had that epiphany right before your message came through. The part I was not understanding was that the argument to the Chained() action is the private path name: # Handles /admin/* sub book_detail : PathPart('admin') Chained('/') Args(1) {...} # Handler 1 of 2 for /admin/*/{edit,delete} sub book_link : PathPart('admin') Chained('/') CaptureArgs(1) {...} sub edit : PathPart Chained('book_detail') Args(0) {...} I wasn't grasping that minor detail that the edit() function needed to be sub edit : PathPart Chained('admin') Args(0) {...} Thanks! Now on to the next brick wall. :) -=Fozz -- [EMAIL PROTECTED] is Doran L. Barton, president/CTO, Iodynamics LLC Iodynamics: IT and Web services by Linux/Open Source specialists This evening at 7 P.M. there will be a hymn sing in the park across from the Church. Bring a blanket and come prepared to sin. -- Seen in a church bulletin pgppcPlmvzaWH.pgp Description: PGP signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: Announce: Website In A Box
Brian Kirkbride wrote: Thomas Klausner wrote: Hi! On Wed, Mar 21, 2007 at 04:47:15PM -0400, Christopher H. Laco wrote: Or more to the point... have app supplied templates, and be able to user user customized templates in combination with the app templates...without have to worry about sources, merging, upgrade, etc... I usually (using TT) do something like: INCLUDE_PATH: [base_framework_stuff app_stuff] All the templates go into base_framework_stuff All modifications needed for an app (or maybe even a sub-area of an app) go into app_stuff. You just need to break your templates into enough smallish components. In the end, it feels a lot like OO templates, where you can override the base implementation. I'm glad to see someone else doing this! I've found it works well for my projects and does feel very OO indeed. As Thomas said, it is mostly about finding the right granularity. Not so small as to make it hard to understand a template's function at a glance, but small enough that an override wouldn't step on something you plan to update in a new revision. Plus, it's an incentive to keep templates small and sane. It it's hard to use your /template/foo instead of /base/template/foo ... then I guess that's a good pointer to something being wrong. THe only part of that that feels dirty is that it's still an either-or situation, rather than an base_mine situation. That could be solved by TT plugins, but that's nasty at some level. -=Chris =-Chris signature.asc Description: OpenPGP digital signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: Announce: Website In A Box
Christopher H. Laco wrote: THe only part of that that feels dirty is that it's still an either-or situation, rather than an base_mine situation. That could be solved by TT plugins, but that's nasty at some level. True, but if you get the granularity right this is not a problem. Think of method overriding as a metaphor: Class A - method outer (calls inner) - method inner (calls detail) - method detail Class B - method inner (inherits outer and detail) can be compared to: templates/base/ outer.tt2 (PROCESS inner.tt2) inner.tt2 (PROCESS detail.tt2) detail.tt2 templates/local/ inner.tt2 Hopefully that makes sense! ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Questions about chained actions, endpoints, etc.
Now try combining all that with using Chained('.') to spread the chain across controllers! (Which is really damned cool, and I use it to split out my model relations in to chained controllers and actions with and get clean uris). Hint on how to do this (since I see that come up a lot on the list as well). In Catalyst::Controller::Admin... # See previous example for index, add, view, edit and delete actions related to the Admin controller # Add a CaptureArgs method to hook our chain up to the child Admin::Foo # subcontroller # NOTE: I am sure you could do some more interesting things here, but I # prefer to keep all the model interactions and stuff in the real # controller and just use this as a hook sub foo : Chained('admin') CaptureArgs(0) { my ( $self, $c ) = @_; } In Catalyst::Controller::Admin::Foo... # Chain endpoint for adding a related foo to a book # Responds to /admin/[id]/foo/add sub add : Chained('.') Args(0) { ... } # Captures a foo id in the chain that is related to # the book we already have in the chain from earlier sub get_foo : PathPart('') Chained('.') CaptureArgs(1) { my ( $self, $c, $id) = @_; ... # Grab the book from the stash, use it to get the related foo # and put THAT in the stash, etc } # Chain endpoint for viewing a foo related to a book # Responds to /admin/[id]/foo/[id]/ sub display : PathPart('') Chained('get_foo') Args(0) { ... } # Chain endpoint for editing a foo related to a book # Responds to /admin/[id]/foo/[id]/edit sub edit : Chained('get_foo') Args(0) { ... } # Chain endpoint for deleting a foo related to a book # Responds to /admin/[id]/foo/[id]/delete sub delete : Chained('get_foo') Args(0) { ... } Keeps your relations, controllers and uri lyaout nice and clean. I have seen discussion here previously that Chained('.') is a confusing way to express what is going on - but once you wrap your head around the Chained() in a Args method is for referring to CaptureArgs methods not uri paths thing, it starts to make a lot more sense and feels natural. Hope all this was interesting to *somebody* ;) Danny Warren Doran L. Barton wrote: Danny, Thanks for your reply. I finally had that epiphany right before your message came through. The part I was not understanding was that the argument to the Chained() action is the private path name: # Handles /admin/* sub book_detail : PathPart('admin') Chained('/') Args(1) {...} # Handler 1 of 2 for /admin/*/{edit,delete} sub book_link : PathPart('admin') Chained('/') CaptureArgs(1) {...} sub edit : PathPart Chained('book_detail') Args(0) {...} I wasn't grasping that minor detail that the edit() function needed to be sub edit : PathPart Chained('admin') Args(0) {...} Thanks! Now on to the next brick wall. :) -=Fozz ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Re: Announce: Website In A Box
Brian Kirkbride wrote: Christopher H. Laco wrote: THe only part of that that feels dirty is that it's still an either-or situation, rather than an base_mine situation. That could be solved by TT plugins, but that's nasty at some level. True, but if you get the granularity right this is not a problem. Think of method overriding as a metaphor: Class A - method outer (calls inner) - method inner (calls detail) - method detail Class B - method inner (inherits outer and detail) can be compared to: templates/base/ outer.tt2 (PROCESS inner.tt2) inner.tt2 (PROCESS detail.tt2) detail.tt2 templates/local/ inner.tt2 Hopefully that makes sense! Completely. At least all my forms are in FB... nothing easier to make a template for than form.render :-) signature.asc Description: OpenPGP digital signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Problems in make tests of Catalyst::Controller::FormBuilder 0.03
I also tried with the version on svn and the same thing happens. I tried several things before writing to the list but without any luck. Just out of curiosity, how does this my $page = books/basic; $mech-get_ok( http://localhost/$page;, GET /$page ); know if it's goint to use the mason, template or tt2 version of books/basic? and also, if I have another http server running on localhost should this test pass? (I shut down my local apache just in case, again without luck): Oh and BTW, even though the error is in: ok( $form, Form found ) or BAIL_OUT(Can't do anything without a form); there is a warning on the $mech-get_ok() that I could not figire out. Where could I have gotten more info on this 'fieldsubs' option mentiones on the warning? I looked at the doc for many of the modules involved and could not find any info on this. Running make test PERL_DL_NONLAZY=1 /usr/bin/perl -MExtUtils::Command::MM -e test_harness(0, 'inc', 'blib/lib', 'blib/arch') t/00-load.t t/01-basic.t t/02-edit.t t/03-attr_param.t t/00-load..ok 1/1# Testing Catalyst::Controller::FormBuilder 0.03 t/00-load..ok t/01-basic.[Test::WWW::Mechanize::get_ok] Warning: Possible field access via $form-prepare() - see 'fieldsubs' option at t/01-basic.t line 11 t/01-basic.NOK 2 # Failed test 'Form found' # in t/01-basic.t at line 14. FAILED--Further testing stopped: Can't do anything without a form make: *** [test_dynamic] Error 9 /usr/bin/make test -- NOT OK Running make install make test had returned bad status, won't install without force Running catalyst 5.7006 installed from CPAN on Debian Linux. Any help greatly appreciated! Alejandro ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Problems in make tests of Catalyst::Controller::FormBuilder 0.03
On Thursday 22 March 2007 01:34, Alejandro Imass wrote: Running make test PERL_DL_NONLAZY=1 /usr/bin/perl -MExtUtils::Command::MM -e test_harness(0, 'inc', 'blib/lib', 'blib/arch') t/00-load.t t/01-basic.t t/02-edit.t t/03-attr_param.t t/00-load..ok 1/1# Testing Catalyst::Controller::FormBuilder 0.03 t/00-load..ok t/01-basic.[Test::WWW::Mechanize::get_ok] Warning: Possible field access via $form-prepare() - see 'fieldsubs' option at t/01-basic.t line 11 t/01-basic.NOK 2 # Failed test 'Form found' # in t/01-basic.t at line 14. FAILED--Further testing stopped: Can't do anything without a form make: *** [test_dynamic] Error 9 /usr/bin/make test -- NOT OK make sure you have the latest CGI::FormBuilder (3.0501) i had the same problem with 3.03 -- Bogdan Lucaciu http://www.wiz.ro ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/