Re: [Catalyst] Forms generation
On 6/14/07, Leo Cacciari <[EMAIL PROTECTED]> wrote: What do the list members thinks about this? How do you generate your forms? Is there something like this already out, and I'm to stupid to find it? Reaction does exactly what you mentioned: http://code2.0beta.co.uk/reaction/svn http://code2.0beta.co.uk/reaction/svnweb/index.cgi/reaction -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática ___ 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] running a function once on all requests
On 6/4/07, Steve Francia <[EMAIL PROTECTED]> wrote: Instead of the first, it gives me last controller in the chain, which leads me to believe that this method is either called once for each controller or called only once, but from the last controller in the chain. It runs for all controllers in the hierarchy, top-most first. Even if it ran the other way around, you'd still get the wrong result because you're calling $c->namespace, which gives you the namespace of the current running action, you want $self->namespace instead. Perhaps there is a different approach with autochaining I should try. you could do something like: sub auto : Private { my($self, $c) = @_; push @{$c->stash->{controllers}}, $self->namespace; return 1; } # in Root sub end : Private { my($self, $c) = @_; $c->stash{controller} = $c->stash->{controllers}[0]; } Although I'm not sure if this is the best way to do it, I'd much prefer this over subclassing since things can get messy if you need to inherit from another controller like FormBuilder or REST. -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática ___ 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] running a function once on all requests
On 6/4/07, Steve Francia <[EMAIL PROTECTED]> wrote: Anyone know of any good reason to do it differently, or has anyone used other strategies in the past? That looks like auto-chaining, you might want to take a look at "auto" actions. http://search.cpan.org/~jrockway/Catalyst-Manual-5.700701/lib/Catalyst/Manual/Intro.pod#Built-in_actions_in_controllers/autochaining http://dev.catalystframework.org/wiki/FlowChart -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática ___ 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] Catalyst and transactions
On 5/25/07, Jason Konrad <[EMAIL PROTECTED]> wrote: I got some help from the DBIx list today which helped me get the txn_do() method working for my schema which is created with the loader Schema package kRadDB; use strict; use base qw/DBIx::Class::Schema::Loader/; __PACKAGE__->loader_options( relationships => 1, ); The solution was to create a schema instance like so, my $schema = kRadDB->connect(...); Then do the transaction $schema->txn_do($coderef); This does accomplish what I was trying to do but aren't there some connections around that I could use rather than manually connecting each time I need to do this transaction? You don't have to connect every time. Catalyst::Model::DBIC::Schema connects when your catalyst application launches and does its best to preserve the connection for you. You can get to the schema instance via $c->model() The docs for Catalyst-Model-DBIC-Schema say # to access schema methods directly: $c->model('FilmDB')->schema->source(...); When I try a similar thing, $c->model('kRadDB')->schema I get this error " Can't call method "schema" without a package or object reference" You need to ask for the model name that inherits from Catalyst::Model::DBIC::Schema, the one that has __PACKAGE__->config( schema_class => 'kRadDB', config_info => '...' ) in it, not the schema class. -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática ___ 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] Catalyst and transactions
On 5/25/07, Eden Cardim <[EMAIL PROTECTED]> wrote: You need to ask for the model name that inherits from Catalyst::Model::DBIC::Schema, the one that has __PACKAGE__->config( schema_class => 'kRadDB', config_info => '...' ) in it, not the schema class. oops, s/config/connect/ -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática ___ 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] ActiveRecord for Perl
On 5/22/07, Adam Bartosik <[EMAIL PROTECTED]> wrote: Good point. To be honest - I need to dig deeply into dbix structure to propose something in the dbix way. The main feature I would like to get from dbix as a wrapper for SQL statement is pagination. DBIC::RS has paging, just use the 'rows' and 'page' attrs. -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática ___ 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] ActiveRecord for Perl
On 5/22/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: one thing i really like about AR is the association proxies, where relationships themselves are objects you can call methods (ie, find) on class User < ActiveRecord::Base has_many :items end class Item < ActiveRecord::Base belongs_to :user end items = user.items item = user.items.find(params[:id]) new_item = user.items.create!(params[:item]) you can get close to that with RDBO's $user->find_items() (and maybe DBIC has something similarish) but the ruby way here feels so much better! "ruby way"? That's exactly how DBIC works. -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática ___ 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] Howto use ConfigLoader?
On 5/12/07, Johannes Rumpf <[EMAIL PROTECTED]> wrote: Howto find out if my Config is loaded? Because $c->config->{my_test} result in empty value? Any advice? Make sure to put a trailing "\n" in the file. -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática ___ 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] Debug/Warning messages for duplicate files under M/V/C directorios
Greetings everyone, I stumbled onto an annoying problem this week, a co-worker of mine somehow managed to duplicate the lib tree into lib/MyApp/Controller which, of course caused the app to crash before I got the initial debug messages, since the log only flushes after the entire app loads, so it took me quite a while to figure it out. While I was whining about the problem in #catalyst, mst suggested there should be helpful debug messages to deal with this kind of issue. Simply flushing the log as each component loads doesn't help a lot since the duplicate file can be loaded before the real one, in that case, the 'redefine' warnings aren't very helpful. Ideally, the debug messages should report which two components tried to load the same thing. I've done something like this by walking the symtable every time a component loads, but that sounds like overkill. Any thoughts on how to get this done? -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática ___ 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] putting an object in the stash
On 3/13/07, Octavian Rasnita <[EMAIL PROTECTED]> wrote: Please tell me what it means column inflation. Check the docs for DBIx::Class::InflateColumn -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl ___ 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] assigning vars to $c->stash
On 3/12/07, Robert 'phaylon' Sedlacek <[EMAIL PROTECTED]> wrote: $c->stash( %$hash ); $c->stash( $hash ); is a little bit faster... -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl ___ 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] reserved words
On 3/7/07, Octavian Rasnita <[EMAIL PROTECTED]> wrote: If I just delete the file Show.pm and restart the server, the program works fine, but if I put it back and restart, it gives that error. I have seen the same thing under Linux and Windows. You'd get along a lot better if you actually read the docs and error messages. You can't forward to a Catalyst View that doesn't implement a process() method or it'll throw an exception, which was just what happened in your case. You probably need to run: script/myapp_create.pl view MyView TT To create a TT view that has a process() method implemented. Or just change TT to whatever type of view you want. Either that or implement a process() method yourself. -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl ___ 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] create=static
On 1/2/07, Octavian Rasnita <[EMAIL PROTECTED]> wrote: I have also tried using the parameter create=dynamic but I have seen that it is creating only the model and not the table classes also. What is this option exactly doing, and how should it be used, or why it doesn't create the table classes? It creates table classes alright, it just doesn't dump them into files. The class loader will analyse the schema in your database, create the classes and load them into memory, every time you load your app. -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl ___ 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] default template
On 12/29/06, Octavian Rasnita <[EMAIL PROTECTED]> wrote: Hi, I often need to make external redirections like in the following case: sub logout : Local { my ($self, $c) = @_; $c->logout; $c->res->redirect($c->uri_for("/")); } When I access /user/logout for executing this subroutine, it prints the following error: Coldn't render template "file error - user/logout: not found" So I need to add a template in the stash in this subroutine, even though I don't want to use and print any template, but just do the redirect. If I add before redirection: $c->stash->{template} = "index.tt"; all works fine, but I guess something is not right in this code. Isn't there a way to just stop everything and make the redirection, without executing the end action? No, there isn't. Catalyst only emits the response after all the actions are dispatched. One way you can keep the end action from running is by not having one. In your case, set up a Controller without an end action just for authentication. In there, you can set up Path actions so you don't have to rewrite all the URLs you've already got in your code: sub logout : Path('/user/logout'){ my ($self, $c) = @_; $c->logout; $c->res->redirect($c->uri_for('/')); } -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl ___ 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] Accessing $c from Model
On 12/27/06, Mark Zealey <[EMAIL PROTECTED]> wrote: Hi there, I'm basically wanting to write a simple log function which logs hits on my website as entries in a database (automatically adding $c->user->{id} and $c->req->referrer etc), but to do so I want to use a model (I think). Any ideas how I can just say $c->model('Log')->info("foo") and automatically get $c passed in? What's wrong with $c->forward('Model::Log', 'info', ['foo']) ? -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl ___ 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] question from tutorial - does creating HTML in a controller using HTML::Widget violate MVC?
On 12/6/06, Michael Reece <[EMAIL PROTECTED]> wrote: what about implicit data retrieval via method calls on objects passed to templates? <% $thing->owner->name %> Well, if the view shouldn't have access to the implicit data via some object, the controller shouldn't have passed that object to the view in the first place. An object is still an object, whether it's stored in a database or not. -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl ___ 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] question from tutorial - does creating HTML in a controller using HTML::Widget violate MVC?
On 12/5/06, Nilson Santos Figueiredo Junior <[EMAIL PROTECTED]> wrote: IMO, the real thing that's missing is Perl code layer between the controller and the template, i.e., the view should be composed by code + templates. If you don't do it this way you need to either a) put code which belongs to the view inside your controller, b) write large amounts of code in your templates using and reap *all* the great benefits that come along with large chunks of code written in TT language or c) write a TT plugin. "a" is fundamentally wrong, "b" will give you nightmares, "c" is arguably clumsy and not practical at all. Actually, someone could come up with a view class which would first call some Perl code and then process the TT template. Why not override MyApp::View::MyView->process() and put your Perl code layer in there? What I do is have ->process() build up pieces of HTML, like tables, forms, etc, with whatever external module I see fit, based on the stash data. Then I stuff them back into the stash and use the template only for layouting those pre-built pieces. -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl ___ 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] Last Chance / Last Day: Web development platform contest and Perl / Catalyst
On 11/30/06, Thomas L. Shinnick <[EMAIL PROTECTED]> wrote: I expect that there will simply always be a large number of people who will read "Catalyst Framework in Perl" as "grandmother's new shoes" :-( Ha! That's SOooo true, whenever I deliver a Catalyst/Perl based project, people ask me: "So, what'd you use? PHP? Ruby? Python? Java". I answer: "err... Perl". The other guy: "C'mon, don't fool around with me...". I really don't care, and I don't think anyone should, actually, I like it. ;) -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl ___ 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: How to redirect before some code excute
On 10/26/06, Fayland Lam <[EMAIL PROTECTED]> wrote: Matt S Trout wrote: > Fayland Lam wrote: >> Lee Standen wrote: >>> It's a subroutine, right? >>> >>> Tried a return?such as: >>> >>> $c->res->redirect('http://www.yahoo.com'); >>> return undef; >> >> Indeed I want to run the 'while' loop in backend. 'return' would not >> run the loop I think. > > $c->res->redirect(...); > $c->finalize_headers; > > > > might do the trick > no, it doesn't work. maybe there is something concerned with 'butter', it's not sent immediately. and I use mod_perl2, so I'd like to have a try of system. Thanks any way. It works if you manage to run your stuff after Catalyst calls $c->finalize() in handle_request(). Funny, I just wrote a hack, err, plugin yesterday which gives me the option to set up a hook that's called right after $c->finalize(). I'm not sure if this is the correct way to do it or if there are any side-effects, if any of the more experient Catalyst users/developers think its a good idea for a plugin, let me know and I'll can carve it up and release it. I use mod_perl and haven't had any trouble so far, this approach lets me delegate all the pre-fork management to apache. I have a Catalyst front-end which adds jobs to a queue like mentioned before in the thread and a another Catalyst server running XMLRPC that gets notified about incoming jobs and runs them after responding to the XMLRPC notification. In MyApp.pm: use Catalyst qw/AfterFinalize/; In a controller action somewhere: sub myaction : Local { $c->res->body('running job'); $c->after_finalize(sub { run_job() } ); } -- Eden Cardim Instituto Baiano de Biotecnologia Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas Laboratório de Bioinformática -- "you seem to think that 'close enough' is close enough... please learn to be 'literal' around programming." merlyn - on irc.freenode.net#perl AfterFinalize.pm Description: Perl program ___ 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] beginner question: MVC / HTML, recommended practice
On 8/3/06, Sarah Berry <[EMAIL PROTECTED]> wrote: > I've already had the opportunity to learn how to pull data from a > database on another Catalyst page. What I'm stuck on is how best to > generate the HTML table once I've got the data. The structure of the > table itself, and not just its contents, will depend heavily on the > data. What I'd do is create separate templates to lay out each different table structure in separate templates as needed and have the View choose one based on its analysis of the data fetched from the model. The View could do some pre-processing if needed to ease data access in the chosen template. ___ 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] Program the logic
On 6/28/06, Eduardo Oliveros <[EMAIL PROTECTED]> wrote: > I know is difficult in practice to separate both worlds (logic from > the presentation) but that is the false promise of the MVC pattern :). Not really, no, the MVC pattern is actually just a specialized Adapter pattern so you can program your Views and Models independently without having to conform the Application and its Presentation to a specific interface. In Web Development that basically means web designers can work without having to know any gory details of the application logic and technology, and vice-versa. This reduces the development effort enormously IMHO. > What I see is that what Catalyst calls Model is just the Objects that > map with the tables in the DDBB. And the logic of the application are > developed in the Actions (in fact linked to the web application). Catalyst is very flexible, you can put your mapped DB classes wherever you want, you could even have a View that's mapped to a database that stores your templates or even your application data if you want. You could program your application logic directly inside Controller Actions if you wish. You'll have trouble maintaining your code later, but that's not Catalyst's fault. > Anyway, the question is just what is the best practice to program the > logic and test it before link the logic with the web application?. > (using the classes generated by the Class::DBI or whatever plugin). I'd stick to the fundamental OO Pattern theory: program to interfaces not implementations. Personally, I have my Controller actions call operations from a Model class interface and my aplication logic stays in the Model, behind the interfaces I defined. That way, I can test the aplication logic independently with unit tests and later on, run integration tests by mocking context objects. ___ 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/