Re: [Catalyst] Catalyst $c-request-params
On 06/01/2013 02:32 PM, 疾驰者 wrote: Dear friends: I read and follow http://www.catalystframework.org/calendar/2012/8 article, These code --- $c-request-params --- in controller Manage.pm, and write_file $database_file, { append = 1 }, $id|$params-{first_name}|$params-{last_name}|$params-{email}\n; -- in model DB.pm, 'first_name' and 'last_name' can't get from database_file.txt and two pm file. What's the principle? $c is so import and complex, how can I get it from formal pod document or some special article such as http://www.catalystframework.org/calendar/2012/8? Thanks a lot. Thai Heng Hi, The Article you are referring to uses File::Slurp to create a File based Model. If you are looking for read_file, edit_file_lines or write_file, you have to take a look at File::Slurp. This is not really Catalyst related. I think File::Slurp is explained in the fist part of the 9 Step Tutorial. Did you read that? The Author mentioned somewhere that his articles are not a replacement for the Catalyst Docs: $c is documented in Catalyst.pm. I guess you are looking for the METHODS section: https://metacpan.org/module/Catalyst#METHODS Catalyst.pm also contains links to almost all related components, like Catalyst::Request and Catalyst::Model. Another good starting point for learning Catalyst is Catalyst::Manual::Tutorial. https://metacpan.org/module/Catalyst::Manual::Tutorial I think it is not completely up to date, but it will help you to understand how Catalyst works and how to use it. cheers, Lukas ___ 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] Chained and exceptions
On 05/09/2013 03:25 PM, Bill Moseley wrote: I have a feeling I asked this before, but cannot find the post. [info] Exception powered by Catalyst 5.90030 What's the reasoning that chained actions continue to run after an earlier exception? sub start : Chained( '/' ) : CaptureArgs(0) { warn in start\n; } sub middle : Chained( 'start' ) : CaptureArgs(0) { warn in middle\n; die died in middle\n; # or e.g. throw access violation } sub lastpart : Chained( 'middle' ) : Args(0) { my ( $self, $c ) = @_; $c-res-body( finished\n ); warn in lastpart\n; } $ script/exception_test.pl http://exception_test.pl /start/middle/lastpart in start in middle *in lastpart* [error] Caught exception in Exception::Controller::Root-middle died in middle Hi Bill, This is because you don't want Catalyst to die. Imagine you are running a fastcgi server and you accidentally created an action which dies on certain user input. If Catalyst would die, the fastcgi server would die and your whole application would not be available anymore. Instead, you want to report the incident and keep the fastcgi server (Catalyst) running. Because of this, every action is wrapped in an eval{...}. Potential errors are logged, but the server keeps running. See execute in Catalyst.pm for implementation details. To solve your problem, you can wrap your unsafe code in an eval or use Try::Tiny (or whatever you prefer) and detach if the unsafe code dies. Your Example would look like this: use Try::Tiny; sub start : Chained( '/' ) : CaptureArgs(0) { warn in start\n; } sub middle : Chained( 'start' ) : CaptureArgs(0) { my ($self, $c) = @_; warn in middle\n; try{ die died in middle\n; # or e.g. throw access violation } catch{ $c-detach }; } sub lastpart : Chained( 'middle' ) : Args(0) { my ( $self, $c ) = @_; $c-res-body( finished\n ); warn in lastpart\n; } If you do it like this, actions chained to the unsafe action will not get executed if the unsafe action dies. In your case, lastpart will never be executed, because middle always dies. Lukas ___ 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] Out of Memory - File delivery issue
Hey Craig, don't print in your Controller! As Neil stated: Passing the response Object to the model and using it as a Filehandle is the way to go. Not using the Catalyst response object and printing directly is not what he suggested. There is no need to print your HTTP Header. You can set $c-res-header(...), and still use $res to stream the output to the client. The same goes for your RenderView problem. RenderView forwards to a view if the value of $c-res-body is undefined. (It's all in the docs). Just set $c-res-body(), and you are fine. No need to override the end method. If this does not work for you for any reason, use 'around end = sub{...}' and avoid calling $self-$orig if the action matches your export action. But as I said, I think setting the body do an empty string should work for you. Lukas ___ 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] Out of Memory - File delivery issue
Hi again, FIRST: Your Controller Code looks good. I would use build-in functionality whenever possible. In this case, using $c-res-content_type instead of setting the content type by hand. But your code should work just fine. Your are right. You have to set the headers before using $c-res-print (or write). But this does not mean that you have to do this in the model. You can set the headers in your Controller before running the model code. SECOND: IMO you are right about your concerns regarding the MVC architecture. The Model should provide the data and not deal with HTTP responses. On the other hand, the data has to be provided in some format. XML is a well known standard format for textual data presentation. Providing the data as XML is as good or as bad as providing the data as DBIC objects. (Well, not really. But close enough for this explanation). The cleanest (most MVC conform) way to do this would be to fetch the raw data from your model and create your XML in a special view. There are several ways to do this. You can create XML using a TT view. ( I have done this before, it works fine). Or you can use existing XML views like Catalyst::View::XML::Generator or Catalyst::View::XML::Hash::LX. (I have not used any of them, but the names are promising). I guess there are even more ways to do it... In your Case, you already have a Model which provides the XML Data (which is fine, as I said before). IMO, one of the great things about Catalyst is that it allows you to get the job done quickly. It makes reusing existing code easy. There is no reason to abandon your existing XML-creation code just because it doesn't fit the MVC layout. Doing so would be contra-productive. So, what can be done to re-use your XML Model and still fit into the MVC architecture? I see two ways: The first one would be to update your model that it writes its data to any IO::Handle compatible object. You can pass $c-res to your Model, which is IO::Handle compatible. Your model uses a Catalyst independent API to write out the data. Catalyst streams the data to the client. Your Model Code is still Catalyst independent and does not know that it is writing to a Catalyst::Response object. No tight coupling. You can reuse your model in non-catalyst applications and easily test its functionality using Test::More or any other test suite. ( I think this is more or less the way proposed by Neil) The second way (which I would prefer, since it is even more MVC conform) is the following: Update your Model to return an IO::Handle-style object instead of a string. You can fetch this object from the model in your controller, and pass it to $c-res-body. Catalyst will take care of streaming the data to the client in small chunks. You don't have to pass any Catalyst related objects to the model anymore. Your model returns the data as a well known standard object which happens to be suitable for streaming large amounts data with catalyst. No tight coupling at all. Problem solved. Have a Tea and celebrate. This is my opinion on this topic. I hope it helps you to find a way which fits your needs, and reduces your confusion about Models, Views and controllers in this specific case. Lukas ___ 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] Out of Memory - File delivery issue
On 05/02/2013 06:19 PM, Craig Chant wrote: I can't work this out? I have in my model... -- my $xls = col1,col2,col3\n; # open io handle $io_handle = IO::Handle-new(); open my ($str_fh), '', \$xls; if ($io_handle-fdopen($str_fh,w)) { $io_handle-print('row1,row2,row3' . \n); } return $io_handle; in my controller... -- # output header $c-response-header( Content_Type = 'application/vnd.ms-excel', Content_Disposition = 'attachment;filename=NBCS_Export.csv' ); # output XLS data $c-response-body($io_handle); -- All I get is a blank XLS file? I can't work out how I create the IO::Handle object with the XLS data inside it? Thanks, Craig. Hi Craig, I don't have much experience with IO::Handle. Additionally, I don't know how your XML Model works. I assume that $xls will contain the generated data. In that case, you should open $xls for *reading* and not for *writing*. You have already written the data to $xls, so IO::Handle has to read it. You might want to take a look at IO::File or IO::String instead of using IO::Handle directly. The following works for me: use IO::File; sub test :Local{ my ($self, $c) = @_; $c-res-content_type(text/plain); $c-res-header(Content_Disposition = 'attachment;filename=test.txt'); my $data = foo\nbar\n; my $ioh = IO::File-new; $ioh-open(\$data, r); $c-res-body($ioh); } There might be a better way. As I said, I am not an expert in using IO::*. And don't forget: This is the Catalyst Users list, and not the IO::Handle list. :) cheers, Lukas ___ 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] Adding CaptureArgs for the whole controller?
On 04/02/2013 10:07 PM, Alex Povolotsky wrote: Hello! I'm implementing some sort of simple CRM, and I'd like to handle a chain like /domain/*/service/*/edit with controller App::Controller::Domain::Service, not with App::Controller::Domain How can I set CaptureArgs for the whole App::Controller::Domain::Service? I'd like to handle captured arg somewhere in begin or auto Alex ___ 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/ Hi, short answer: you can't! Args and CaptureArgs are always specific to an action. It is not possible (and doesn't make sense) to define CaptureArgs for the whole Controller. But: You can create a empty action, and chain all actions in your controller to that actions, like this: sub mybase :Chained(/) :PathPart() :CaptureArgs(2) {}; sub foo :Chained('mybase') Args(0){ #do foo } sub bar :Chained('mybase') Args(0){ # do bar } You can even create a BUILDARGS method which ensures that all your actions are chained to that base action (if you don't want to do this by yourself). But I would not recomment this. If you realy want to process your args and capture args in begin or auto (for whatever reason) you can just do so. Args can be found in $c-req-arguments and captures in $c-req-captures. cheers, Lukas ___ 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] Catalyst with HTTP authentication
On 03/12/2013 01:07 PM, Alexander Hartmaier wrote: Having the webserver do the authentication means you are depending on it to support the type of authentication you want to use. I'd prefer having the authentication in the app with the exact same code for production and testing over ::Remote. Everything has its pros and cons. If you do all your authentication in your app, you depend on existing modules for the desired authentication method, or you have to write your own authentication code. I prefer using stable and tested mechanisms over writing my own code (if possible). And if a tool lacks some features which I need, I just use something else (again, if possible). I guess 90% of all webservers support most common authentication methods. Until now, I used DBIC based authentication within my app, and ::Remote for everything else. But until now everything else is just one project which requires digest, certificates and kerberos authentication. I guess there is no better in this case. Its a matter of personal preferences and use case. Concerning the differing code for testing and production: I agree. This truly is a disadvantage when using ::Remote cheers, Lukas ___ 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] Catalyst with HTTP authentication
Hi, I just had some time to try it: C::Authentication::Credential::HTTP and C::Authentication::Store::Htpasswd work together just fine. Here is my setup: in TestApp.pm: use Catalyst qw/ ConfigLoader Authentication /; __PACKAGE__-config( Plugin::Authentication = { realms = { default = { credential = { class = 'HTTP', type = basic, password_field = 'check_password', password_type = 'self_check', }, store = { class = 'Htpasswd', file = /tmp/htpasswd, }, }, }, }, ); and in Controller/Root.pm (or wherever you need it): sub index :Path :Args(0) { my ( $self, $c ) = @_; $c-authenticate; if($c-user_exists){ $c-res-body(logged in); } } The tricky part is that you have to set password_field and password_type correctly, which is not documented. (You have to know how Catalyst Authentication works and read the docs for Authen::Htpasswd to find out) I still recommend to use C::A::Credential::Remote. Let the server do the job, and keep your application small and simple. Plus: You can add digest authentication, certificate authentication, kerberos authentication and whatever your server supports without modifying your application. Lukas On 03/11/2013 03:10 PM, Robert Rothenberg wrote: I have a project that requires using HTTP authentication. There is a Catalyst::Authentication::Credential::HTTP module, but from the documentation, it does not seem to support using htpasswd files, which I need, because a separate web site will be using that file. There is Catalyst::Authentication::Store::Htpasswd, but it does not work with Catalyst::Authentication::Credential::HTTP. I'm not clear on how to do this, without having to write my own handlers for HTTP authentication. ___ 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] Catalyst with HTTP authentication
I realized that you don't even have to set password_field correctly. Something was going terribly wrong in my head, sorry for that. Only password_type has to be set to self_check, but this is documented. This means that there is no tricky part at all. Just configure both modules as described in their documentation. Lukas On 03/11/2013 07:54 PM, Lukas Thiemeier wrote: Hi, I just had some time to try it: C::Authentication::Credential::HTTP and C::Authentication::Store::Htpasswd work together just fine. Here is my setup: in TestApp.pm: use Catalyst qw/ ConfigLoader Authentication /; __PACKAGE__-config( Plugin::Authentication = { realms = { default = { credential = { class = 'HTTP', type = basic, password_field = 'check_password', password_type = 'self_check', }, store = { class = 'Htpasswd', file = /tmp/htpasswd, }, }, }, }, ); and in Controller/Root.pm (or wherever you need it): sub index :Path :Args(0) { my ( $self, $c ) = @_; $c-authenticate; if($c-user_exists){ $c-res-body(logged in); } } The tricky part is that you have to set password_field and password_type correctly, which is not documented. (You have to know how Catalyst Authentication works and read the docs for Authen::Htpasswd to find out) I still recommend to use C::A::Credential::Remote. Let the server do the job, and keep your application small and simple. Plus: You can add digest authentication, certificate authentication, kerberos authentication and whatever your server supports without modifying your application. Lukas On 03/11/2013 03:10 PM, Robert Rothenberg wrote: I have a project that requires using HTTP authentication. There is a Catalyst::Authentication::Credential::HTTP module, but from the documentation, it does not seem to support using htpasswd files, which I need, because a separate web site will be using that file. There is Catalyst::Authentication::Store::Htpasswd, but it does not work with Catalyst::Authentication::Credential::HTTP. I'm not clear on how to do this, without having to write my own handlers for HTTP authentication. ___ 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/ ___ 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] HTML::FormHandler and the Catalyst stash
On 01/16/2013 11:39 AM, Jacinta wrote: G'day folk, I've been working through the Catalyst tutorial (again) and I decided to give HTML::FormHandler a go. It's tutorial at https://metacpan.org/module/GSHANK/HTML-FormHandler-0.40017/lib/HTML/FormHandler/Manual/Tutorial.pod has been great. However I am stuck on something I am certain should be easy, but is not proving so... As per the tutorial my edit method looks much like this: sub edit : Local { my ( $self, $c, $book_id ) = @_; $c-stash( template = 'books/edit.tt2', form = $self-form ); # Validate and insert/update database return unless $self-form-process( item_id = $book_id, params = $c-req-parameters, schema = $c-model('DB')-schema ); # Form validated, return to the books list $c-flash-{status_msg} = 'Book saved'; $c-res-redirect($c-uri_for('list')); } and that works beautifully. However, I've enhanced my examples as I've gone along and instead of going to the list of books, I want to go to my review page and print out all of the details (including extra stuff) of this specific book I've just added. So I would like to change the last line to be: $c-res-redirect($c-uri_for($self-action_for('review'), [$book_id])); This works perfectly if I'm editing a book, but if I'm creating a book for the first time, $book_id is undefined so I pass in an undefined id to review. Review seems to deal with that okay: sub review :Chained('object') :PathPart('review') :Args(0) { my ($self, $c) = @_; my $book = $c-stash-{object}; ... until I want to use $book for something. I have looked through most of the documentation for HTML::FormHandler and I can't find anything that actually documents process() (it returns 1 on success) and I don't know the Catalyst stash well enough. Is this information hiding therein or do I need to create a method to get the last insert id? All help gratefully appreciated. Jacinta ___ 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/ Hi Jacinta, Assumed that you are using HTML::FormHandler::Model::DBIC, HTML::FormHandler will store the new (or updated) item in the forms item attribute. You can try this: my $new_id = $c-stash-{form}-item-id; $c-res-redirect($c-uri_for($self-action_for('review'), [$new_id])); This code should work, no matter if the item was updated or created. It will even work if the items id changes during the update process (which should rarely happen, but it will work if it happens) I hope I could help. Lukas ___ 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] sub-modules for model
Hi, when Catalyst::Model::DBIC::Schema is in use, you get this for free. I assume that your sub-modules match your database tables. In that case, you will have Thingy::Schema::Result::User, Thingy::Schema::Result::Team and Thingy::Schema::Result::Incident. You can access them like this: my $users = $c-model(DB::User); Now you can edit lib/Thingy/schema/Result/User.pm and add your user-related code. If you need code which operates on a resultset, instead of a single row, you can create and/or edit Thingy::Schema::Resultset::User. If you want to create your own Model for some reason, I suggest you to take a look at Catalyst::Model::Adaptor. There are tons of examples in Catalyst::Manual::Tutorial, DBIx::Class::Manual and DBIx::Class::Tutorial (I haven't read the last one) I am sure that the Catalyst manual contains a section about passing configuration to the model, and that the DBIC manual will teach you how to manually add modules to the schema. To deploy shared code to several result classes, you can use Moose, MooseX::NonMoose and Moose::Role, which have their own manuals. cheers, Lukas On 12/19/2012 06:53 PM, will trillich wrote: Spent a bit of time googlilng this and apparnelty I'm not searching very effectively today... Short version: What's best-practices to get model library sub-modules hooked in to the main model? Long version: *catalyst.pl http://catalyst.pl Thingy* *cd Thingy* *script/thingy_create.pl http://thingy_create.pl model DB DBIC::Schema \* * Thingy::Schema::DB create=static dbi:mysql:thingy \ * * dbuser dbpasswd* So now we have lib/Thingy/Model/DB like so: *package Thingy::Model::DB;* * * *use strict;* *use base 'Catalyst::Model::DBIC::Schema';* * * *__PACKAGE__-config(* *schema_class = 'Thingy::Schema::DB',* * * *connect_info = {* *dsn = 'dbi:mysql:thingy',* *user = 'dbuser',* *password = 'dbpasswd',* *}* *);* This is a top-level module. Instead of a monolithic mess with all possible library routines in one package, we want to modularize sub-functions into, say *Thingy::Model::DB::Team* *Thingy::Model::DB::User* *Thingy::Model::DB::Incident* etc Do we have those sub-modules use the top-level Thingy::Model::DB? Do we have Thingy::Model::DB use the sub-modules? Do we have the sub-modules use base 'Catalyst::Model::DBIC::Schema'? Or can they just extends 'Catalyst::Model' and if so how do they hook in with $c? Is there an elegant way to have all the sub-module models use the same DB config as the top model? ...or... What's the best practice for getting separate modules to work as models in the MVC universe? -- Will Trillich :: 812.454.6431 “Grading takes away all the fun from failing. And a huge part of education is about failure.” -- Shimon Schocken ___ 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] Generating a large XML document (KML file) from a database
I once had a similar problem, and solved it by using an ordinary TT View which rendered the XML, and stashing the required resultset. It worked fine for me, but my xml structure was very simple. It just contained lots of data. I don't know if this is an option for you. If your xml is very complex or dynamic, creating the templates can be a pain! Lukas On 11/26/2012 05:58 PM, Robert Rothenberg wrote: I need to output a large XML file (actually, a KML file of points) from a database. I can't find any documentation for Catalyst::View::XML::Generator, or even decent documentation for XML::Generator, on how to do this. It would appear to expect me to put the entire structure in the stash, which I don't want to do, as it could contain thousands of points. Ideally I would pass an iterator function and it would do the rest. ___ 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] Model objects from multiple DBIx::Class rows
Hi Stephen, As far as I know, creating result class without underlying table is not supported. Having a class without table, but with relationships doesn't realy make sense to me. A relationship always has two sides. I am not sure if I really understand your problem. You have a user table and a related picture table? My approach would be to select the user from the user-table, and use prefetch to populate the pictures-relation with the same call. You will get a $user object with the pictures relationship already populated. https://metacpan.org/module/DBIx::Class::ResultSet#prefetch If you want to update several related tables with a single method call, take a look at RecursiveUpdate. It is not the fastest solution, and there might be situations where it is not suitable, but it works fine in most cases. And it allows you to pass nested hash- and arrayrefs to recursive_update, and therefore updating or creating several related rows with very little code. For example, HTML::FormHandler uses R-U to update the database. https://metacpan.org/module/DBIx::Class::ResultSet::RecursiveUpdate It is also possible to create several result classes for the same table, if you need different behavior in different situations. You cound, for example, create a Montage class, which works on the user table, and add custom code which is only needed by montages. The old user class will still be available. cheers, Lukas On 11/22/2012 04:59 PM, Stephen Shorrock wrote: Hi, I was wondering whether there is any advice out there about how to use and manage objects within a Catalyst application where the objects contain DBIx::Class schema model objects that are also within the application. I've considered creating simple moose objects that get passed the schema objects and use rows returned from the schema objects to populate 'local' values but this doesn't seem right. The trouble I have is that data for these objects is stored in the database but their i sno single table for the object them selves for example I might have a Montage object that has a $User and several @Pictures the User record is stored in the database and the Picture records are also stored as individual rows in a pictures table. I want to manipulate the users along with their pictures as an object them selves, for example given a User DBIx::class objects create a method (eg get_montage) that returns a Montage. Is there a simple solution perhaps creating a DBIx::class object that doesn't actually have an underlying table but can still utilize relationships and have User::get_montage return an instance of one of these? Or am I overlooking something else that is obvious? Thanks in advance Stephen ___ 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] Why is $c undefined?
Hi Craig, On 10/30/2012 12:09 PM, Craig Chant wrote: Thanks Ian, The hierarchy is something that I am finding mind-blowing at the moment, $self-jqgrid-render($self, , you are calling methods jqgrid-render on $self, passing in $self, I'm sure it makes sense to you :-) No, he is calling render on whatever is returned by $self-jqgrid. Thats why $self has to be passed to render. The code above is equivalent to: my $jqgrid = $self-jqgrid; $jqgrid-render($self, ...); One thing I would like clarification with if possible. Where do I put code that requires the use of more than one model? Do I create a separate model that acts as an interface between the other models? Thats one possibility. Another possibility would be to create a helper method in Model1, which expects Model2 as a parameter. Model1.pm: sub calculate_sth_with_model2{ my ($self, $model2) = @_; do_crazy_calculations(); } And in your Controller: sub calculate :Local :Args(0) { my ($self, $c) = @_; my $m1 = $c-model(Model1); my $m2 = $c-model(Model2); $m1-calculate_sth_with_model2($m2); } You see I have two SQL servers in opposite ends of the country and so I have a model built on Model::DBI that can access one server and another Model that can access the other, but I have functionality that needs data from both , do some calculations and output accordingly. I assume this does not go in the controller, but I create an interface model with the required methods and functionality that the controller uses? Regards, Craig. -Original Message- From: Ian Docherty [mailto:catal...@iandocherty.com] Sent: 30 October 2012 07:22 To: The elegant MVC web framework Subject: Re: [Catalyst] Why is $c undefined? On 29 October 2012 21:01, Craig Chant cr...@homeloanpartnership.com wrote: ... I have read and seen frameworks such as Mojolicious encourage a shrinkage of the Model and move alot of functionality to the Controller, so there is a paradigm which seems to imply it is ok to do more stuff in the Controller, but I am leaning towards having the main code in the Model and then bolting it together via the Controller. I can understand why you get this impression, I think a lot of people end up putting code in the Controller when they first start using MVC (I did so myself in the past). The Model should be external to your Catalyst app (or whatever framework you use) so that you can use it in things like cron jobs. It also makes testing easier if your Model is separate from your Catalyst app. Look at using something like Catalyst::Model::Adaptor as a thin shell to add your external Model into Catalyst. I am moving more and more into making my Controllers as thin as possible. Logic that I might have previously put into the Controller, I either put into the Model or I create helper functions. Here is an example of a Controller (from Mojolicious as it happens but that is not important) sub user_list { my ($self) = @_; $self-jqgrid-render($self, { rs = $self-schema-resultset('User')-search_rs, filters = {}, rows= [qw(id name)], }); } It's not important to know what is going on here, but this Controller gets a list of all users, formats the data for use in the jQuery jqGrid allows for sorting and filtering and outputs the data in JSON format. The point being, the controller code is kept simple and 'thin' and yet it does a lot of work behind the scenes. ___ 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/ This Email and any attachments contain confidential information and is intended solely for the individual to whom it is addressed. If this Email has been misdirected, please notify the author as soon as possible. If you are not the intended recipient you must not disclose, distribute, copy, print or rely on any of the information contained, and all copies must be deleted immediately. Whilst we take reasonable steps to try to identify any software viruses, any attachments to this e-mail may nevertheless contain viruses, which our anti-virus software has failed to identify. You should therefore carry out your own anti-virus checks before opening any documents. HomeLoan Partnership will not accept any liability for damage caused by computer viruses emanating from any attachment or other document supplied with this e-mail. HomeLoan Partnership reserves the right to monitor and archive all e-mail communications through its network. No representative or employee of HomeLoan Partn ership ha s the authority to enter into any contract on behalf of HomeLoan Partnership by email. HomeLoan Partnership is a
Re: [Catalyst] Why is $c undefined?
Hi Craig, You don't understand why $c-model('Model1') retrieves and data, because it doesn't retrieve any data. Database-code in the controller should be avoided, and instead be implemented in the model. My code just passes a reference to Model2 to Model1, so Model1 can access data from Model2. Within Model1, you can use prepare, execute, fetch et cetera on Model1 and Model2, to fetch the data for your calculations. Nevertheless, i think that your idea to create a extra model, which has access to both underlying databases, is a better choice. Lukas On 10/30/2012 01:16 PM, Craig Chant wrote: Thanks Lukas, Chained method calls is not my strong point in Perl, they seem easier to read in other languages with bracketed encapsulation and the dot notation. Your helper method is interesting, though I don't understand how $c-model(Model1); retrieves any SQL data, like I said wrapping my head around this is a bit of an uphill struggle currently. Regards, Craig. -Original Message- From: Lukas Thiemeier [mailto:spamcatc...@thiemeier.net] Sent: 30 October 2012 11:28 To: The elegant MVC web framework Subject: Re: [Catalyst] Why is $c undefined? Hi Craig, On 10/30/2012 12:09 PM, Craig Chant wrote: Thanks Ian, The hierarchy is something that I am finding mind-blowing at the moment, $self-jqgrid-render($self, , you are calling methods jqgrid-render on $self, passing in $self, I'm sure it makes sense to you :-) No, he is calling render on whatever is returned by $self-jqgrid. Thats why $self has to be passed to render. The code above is equivalent to: my $jqgrid = $self-jqgrid; $jqgrid-render($self, ...); One thing I would like clarification with if possible. Where do I put code that requires the use of more than one model? Do I create a separate model that acts as an interface between the other models? Thats one possibility. Another possibility would be to create a helper method in Model1, which expects Model2 as a parameter. Model1.pm: sub calculate_sth_with_model2{ my ($self, $model2) = @_; do_crazy_calculations(); } And in your Controller: sub calculate :Local :Args(0) { my ($self, $c) = @_; my $m1 = $c-model(Model1); my $m2 = $c-model(Model2); $m1-calculate_sth_with_model2($m2); } You see I have two SQL servers in opposite ends of the country and so I have a model built on Model::DBI that can access one server and another Model that can access the other, but I have functionality that needs data from both , do some calculations and output accordingly. I assume this does not go in the controller, but I create an interface model with the required methods and functionality that the controller uses? Regards, Craig. -Original Message- From: Ian Docherty [mailto:catal...@iandocherty.com] Sent: 30 October 2012 07:22 To: The elegant MVC web framework Subject: Re: [Catalyst] Why is $c undefined? On 29 October 2012 21:01, Craig Chant cr...@homeloanpartnership.com wrote: ... I have read and seen frameworks such as Mojolicious encourage a shrinkage of the Model and move alot of functionality to the Controller, so there is a paradigm which seems to imply it is ok to do more stuff in the Controller, but I am leaning towards having the main code in the Model and then bolting it together via the Controller. I can understand why you get this impression, I think a lot of people end up putting code in the Controller when they first start using MVC (I did so myself in the past). The Model should be external to your Catalyst app (or whatever framework you use) so that you can use it in things like cron jobs. It also makes testing easier if your Model is separate from your Catalyst app. Look at using something like Catalyst::Model::Adaptor as a thin shell to add your external Model into Catalyst. I am moving more and more into making my Controllers as thin as possible. Logic that I might have previously put into the Controller, I either put into the Model or I create helper functions. Here is an example of a Controller (from Mojolicious as it happens but that is not important) sub user_list { my ($self) = @_; $self-jqgrid-render($self, { rs = $self-schema-resultset('User')-search_rs, filters = {}, rows= [qw(id name)], }); } It's not important to know what is going on here, but this Controller gets a list of all users, formats the data for use in the jQuery jqGrid allows for sorting and filtering and outputs the data in JSON format. The point being, the controller code is kept simple and 'thin' and yet it does a lot of work behind the scenes. ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com
Re: [Catalyst] Global 'helper' methods
You can also define your constants in YourApp/Constants.pl, and use YourApp::Constants wherever you need them. YourApp/Constants.pm: use constant { FOO = 1 }; 1; Controller.pm: use YourApp::Constants; # and in some method ... my $global_foo = FOO; There might be a better way, but this works... For handling dates, I recommend DateTime, available on cpan: Another reason to use DBIC: DBIx::Class::Inflatecolumn::DateTime automatically transforms dates stored in a database into a DateTime object, which can be used like this: my $uk_string = $datetime-dmy('/'); my $us_string = $datetime-ymd('-'); But DateTime is not related to DBIC, DBIC just makes using it easy. Use it if you have to work with dates a lot. It has lots of methods for outputting dates, times or both in different formats, and it allows datetime-math... On 10/30/2012 03:39 PM, Craig Chant wrote: Well I opted for putting my globals (methods and constants) in MyApp.pm It's working grand with $c-myMethod or $c-MY_CONSTANT I use to have them working as a bareword within my application , but $c-MY_CONSTANT is just as easy! Many thanks for all the input and help, it really is appreciated. -Original Message- From: Lukas Thiemeier [mailto:spamcatc...@thiemeier.net] Sent: 30 October 2012 13:56 To: catalyst@lists.scsys.co.uk Subject: Re: [Catalyst] Global 'helper' methods Hi Craig, Writing helpers in your main App.pm and using roles is not either-or. Roles are one possibility to modify your classes in a reusable way. If your helpers are really global, which means that they are used by all, or almost all your controllers, I would put them into your main application class. If you have more than one application which make use of the same helpers: Put them into a role: YourHelperRole.pm: package YourHelperRole; use Moose::Role; has some_attribute = ( ... ); # if you need attributes sub helpermethod1{ my ($self, $other, $args) = @_; do_something(); } sub helpermethod2{ my ($self, $other, $args) = @_; do_something_different(); } no Moose::Role; # or use namespace::autoclean or MooseX::MarkAsMethod 1; App.pm: use Catalyst qw( ... ); extends Catalyst; with qw/YourHelperRole/; ... In my opinion, extending your main App.pm with roles is only useful if you need the same helpers in different locations, too. If you only need them for that single application, avoid the overhead related to using roles. If you have helpers which are only needed by some controllers, create a role for your controllers. You can not only implement helpers in you roles, you can also create method-modifiers, which change the way your methods behave. Here is an example, which writes sth to the log, after the delete method was called: YourLogRole.pm: package YourLogRole; use Moose::Role; requires qw/delete/; #die if the consuming class has no delete after delete = sub{ my ($self, $c) = @_; $c-log-debug(DELETE called); }; no Moose::Role; 1; Controller1.pm: (has the helpers, but no logging) package Controller1; use Moose; extends Catalyst::Controller; with qw/ YourHelperRole /; sub someaction :Local { my ($self, $c) =@_; $self-helpermethod1(); } ... Controller2.pm: (has helpers AND logging) package Controller2; use Moose; extends Catalyst::Controller; with qw/ YourLogRole YourHelperRole /; sub delete :Local :Args(1) { ... } Controller3.pm (has logging, but no helpers) package Controller3; use Moose; extends Catalyst::Controller; with qw/ YourLogRole /; sub delete :Local :Args(1) { ... } Roles are very powerful tools. I use them a lot. Read the Moose docs for more information. If you don't want to learn Moose, roles and so on now, just remember: 1. write sth in a role 2. consume the role in a moose class, using with 3. your roles methods and attributes will be available in the consuming class Lukas On 10/30/2012 02:03 PM, Craig Chant wrote: Hi, Please could you advise the best way of having a global 'helper' class that has all commonly used methods in it accessible for any part of the catalyst app. I found this thread http://stackoverflow.com/questions/11941836/catalyst-global-subroutine s With one indicating it's ok to put them in the main MyApp.pm and another saying to use Moose Roles. What is considered the correct way and could you provide an example of how I create this helper class and bolt it to the Catalyst application. Many thanks, */Craig Chant/* I.T. Manager Description: cid:image001.png@01CD5F4A.17E848D0 Main Line01903 602664 Direct Line 01903 227753 Visit our website http://www.homeloanpartnership.com *HomeLoan Partnership have been named
Re: [Catalyst] Global 'helper' methods
Hm... how to measure the overhead of a module? There is a XS version of the module which is used if you have a C compiler. I don't know the exact overhead, but I know that it is fast. I have no experience with the pure perl version of that module. If all you have to do with the dates is the simple string transformation you are right. As I said before: I recommend to use DT if you are working with dates a lot. Doing math on dates and times is annoying, because of leap years, epochs, timezones and so on. If you need this: Using DateTime is recommended. If not: Its not :) If you are ONLY using pure perl modules: You can include all required modules in your distribution. It should run on any perl installation, even in a shared host environment. App::FatPacker helps you doing this... But this doesn't work as soon as you use XS modules. On 10/30/2012 04:03 PM, Craig Chant wrote: Thanks Lukas, I appreciate there is DateTime , though I have so much legacy code that uses my helper class re-writing everything will be a mammoth task. I hand rolled a lot when I first started out with Perl, didn't know much about CPAN or PPM, and couldn't load any modules that weren't part of the core install on the original 'shared' hosting I was using. Plus I always felt loading an entire module to re-arrange a tiny string seems a bit OTT? Dunno, what's the overhead of DateTime? Craig. -Original Message- From: Lukas Thiemeier [mailto:spamcatc...@thiemeier.net] Sent: 30 October 2012 14:52 To: catalyst@lists.scsys.co.uk Subject: Re: [Catalyst] Global 'helper' methods You can also define your constants in YourApp/Constants.pl, and use YourApp::Constants wherever you need them. YourApp/Constants.pm: use constant { FOO = 1 }; 1; Controller.pm: use YourApp::Constants; # and in some method ... my $global_foo = FOO; There might be a better way, but this works... For handling dates, I recommend DateTime, available on cpan: Another reason to use DBIC: DBIx::Class::Inflatecolumn::DateTime automatically transforms dates stored in a database into a DateTime object, which can be used like this: my $uk_string = $datetime-dmy('/'); my $us_string = $datetime-ymd('-'); But DateTime is not related to DBIC, DBIC just makes using it easy. Use it if you have to work with dates a lot. It has lots of methods for outputting dates, times or both in different formats, and it allows datetime-math... On 10/30/2012 03:39 PM, Craig Chant wrote: Well I opted for putting my globals (methods and constants) in MyApp.pm It's working grand with $c-myMethod or $c-MY_CONSTANT I use to have them working as a bareword within my application , but $c-MY_CONSTANT is just as easy! Many thanks for all the input and help, it really is appreciated. -Original Message- From: Lukas Thiemeier [mailto:spamcatc...@thiemeier.net] Sent: 30 October 2012 13:56 To: catalyst@lists.scsys.co.uk Subject: Re: [Catalyst] Global 'helper' methods Hi Craig, Writing helpers in your main App.pm and using roles is not either-or. Roles are one possibility to modify your classes in a reusable way. If your helpers are really global, which means that they are used by all, or almost all your controllers, I would put them into your main application class. If you have more than one application which make use of the same helpers: Put them into a role: YourHelperRole.pm: package YourHelperRole; use Moose::Role; has some_attribute = ( ... ); # if you need attributes sub helpermethod1{ my ($self, $other, $args) = @_; do_something(); } sub helpermethod2{ my ($self, $other, $args) = @_; do_something_different(); } no Moose::Role; # or use namespace::autoclean or MooseX::MarkAsMethod 1; App.pm: use Catalyst qw( ... ); extends Catalyst; with qw/YourHelperRole/; ... In my opinion, extending your main App.pm with roles is only useful if you need the same helpers in different locations, too. If you only need them for that single application, avoid the overhead related to using roles. If you have helpers which are only needed by some controllers, create a role for your controllers. You can not only implement helpers in you roles, you can also create method-modifiers, which change the way your methods behave. Here is an example, which writes sth to the log, after the delete method was called: YourLogRole.pm: package YourLogRole; use Moose::Role; requires qw/delete/; #die if the consuming class has no delete after delete = sub{ my ($self, $c) = @_; $c-log-debug(DELETE called); }; no Moose::Role; 1; Controller1.pm: (has the helpers, but no logging) package Controller1; use Moose; extends Catalyst::Controller; with qw/ YourHelperRole /; sub someaction :Local { my ($self, $c) =@_; $self
Re: [Catalyst] Unable to output anything in Root.pm - 'auto'
Hi Craig, Take a look at the default index method in Controller/Root.pm. If you look at the debug output, you will see that index is called after auto. Index sets, and therefore overwrites $c-res-body. If you use a template system, the default end action (ActionClass:RenderView) will only render the template if $c-res-body is not set. But setting the body directly, as in index, will overwrite any previously added content. Uncomment the line '$c-response-body( $c-welcome_message );' in 'sub index ...', and you will see whatever you write to $c-res-body in auto. Cheers, Lukas On 10/29/2012 04:04 PM, Craig Chant wrote: Oh I also tried changing it to ‘begin’ instead of ‘auto’, still doesn’t work? I also thought that all calls to ANY method / sub will always be passed $self $c , only it doesn’t seem to be passing in $c and I’ve had to manually do it? I’ve tried… # always runs first! sub begin :Private { my ( $self, $c ) = @_; # Authenticate $self-AuthenticateUser($c); return 1; } sub AuthenticateUser { my ( $self, $c ) = @_; die 'Session ID = ' . $c-sessionid; } But there is no session ID. I am still getting the “Use of uninitialized value in concatenation (.) or string” error. I’ve read http://search.cpan.org/~mramberg/Catalyst-Plugin-Session-0.14/lib/Catalyst/Plugin/Session/Tutorial.pod Where it states : These plugins will automatically set |$c-sessionid|at the begining of the request, and automatically cause |$c-sessionid|to be saved by the client at the end of the request. So why is $c-sessionid uninitialized? Any ideas where my session info is? Thanks, Craig *From:*Craig Chant [mailto:cr...@homeloanpartnership.com] *Sent:* 29 October 2012 14:54 *To:* The elegant MVC web framework *Subject:* RE: [Catalyst] Unable to output anything in Root.pm - 'auto' Nope, no change; same warning in the devel output and all that happens is the welcome screen loads? *From:*Ben Vinnerd [mailto:ben+catal...@vinnerd.com] mailto:[mailto:ben+catal...@vinnerd.com] *Sent:* 29 October 2012 14:48 *To:* The elegant MVC web framework *Subject:* Re: [Catalyst] Unable to output anything in Root.pm - 'auto' Private methods have to return a true value to continue processing. Try adding return 1 at the end of the method. Ben On 29 October 2012 14:23, Craig Chant cr...@homeloanpartnership.com mailto:cr...@homeloanpartnership.com wrote: Hi, I seem to be going round in circles unable to get Catalyst to output anything via ‘auto’? I made a change to the Root.pm to try to add authentication via the ‘auto’ method, but it does nothing? # always runs first! sub auto :Private { my ( $self, $c ) = @_; # Authenticate $c-response-body('Matched Members::Controller::Auto in Root.' . $c-sessionid); } This doesn’t output anything and I simply get the welcome screen, plus there is a warning in the devel server output of “Use of uninitialized value in concatenation (.) or string” I have .. use Catalyst qw/ -Debug ConfigLoader Static::Simple StackTrace Session Session::Store::FastMmap Session::State::Cookie /; In my main MyApp.pm Why is $c-response-body not working and why is the sessionid empty? Thanks */Craig Chant/* I.T. Manager Description: cid:image001.png@01CD5F4A.17E848D0 Main Line01903 602664 tel:01903%20602664 Direct Line 01903 227753 tel:01903%20227753 Visit our website http://www.homeloanpartnership.com *HomeLoan Partnership have been named the Best Mortgage Network, 2012, at the myintroducer.com http://myintroducer.com Industry Awards* This Email and any attachments contain confidential information and is intended solely for the individual to whom it is addressed. If this Email has been misdirected, please notify the author as soon as possible. If you are not the intended recipient you must not disclose, distribute, copy, print or rely on any of the information contained, and all copies must be deleted immediately. Whilst we take reasonable steps to try to identify any software viruses, any attachments to this e-mail may nevertheless contain viruses, which our anti-virus software has failed to identify. You should therefore carry out your own anti-virus checks before opening any documents. HomeLoan Partnership will not accept any liability for damage caused by computer viruses emanating from any attachment or other document supplied with this e-mail. HomeLoan Partnership reserves the right to monitor and archive all e-mail communications through its network. No representative or employee of HomeLoan Partnership has the authority to enter into any
Re: [Catalyst] Unable to output anything in Root.pm - 'auto'
Hi again, about the missing sessionid: I don't know much about the internals of Catalyst::Plugin::Session, but I guess that the session is a lazy attribute, and only created if used. This means: unless you put something in the session, you will not have one, and therefore have no session-id. This is very handy, because the overhead related to creating and restoring a session is only executed if the session is really needed. If your app has a session-less interface without authentication, and extra functionality for authenticated users, the session will only be created for authenticated users. If you touch your session object before fetching the session-id, it will work: $c-session; $c-res-body(SESSIONID . $c-sessionid); As soon as you implemented authentication, the session will be used and the session-id will be set. By the way, what do you need the session-id for? Catalyst handles sessions in a transparent way. In most cases, you don't need to access the session-id in your code. And if it is only for debugging: The session plugin writes the session-id to $c-log when a session is created or restored. This means: the code showed above will result in the session-id being printed twice :) Lukas On 10/29/2012 04:04 PM, Craig Chant wrote: Oh I also tried changing it to ‘begin’ instead of ‘auto’, still doesn’t work? I also thought that all calls to ANY method / sub will always be passed $self $c , only it doesn’t seem to be passing in $c and I’ve had to manually do it? I’ve tried… # always runs first! sub begin :Private { my ( $self, $c ) = @_; # Authenticate $self-AuthenticateUser($c); return 1; } sub AuthenticateUser { my ( $self, $c ) = @_; die 'Session ID = ' . $c-sessionid; } But there is no session ID. I am still getting the “Use of uninitialized value in concatenation (.) or string” error. I’ve read http://search.cpan.org/~mramberg/Catalyst-Plugin-Session-0.14/lib/Catalyst/Plugin/Session/Tutorial.pod Where it states : These plugins will automatically set |$c-sessionid|at the begining of the request, and automatically cause |$c-sessionid|to be saved by the client at the end of the request. So why is $c-sessionid uninitialized? Any ideas where my session info is? Thanks, Craig *From:*Craig Chant [mailto:cr...@homeloanpartnership.com] *Sent:* 29 October 2012 14:54 *To:* The elegant MVC web framework *Subject:* RE: [Catalyst] Unable to output anything in Root.pm - 'auto' Nope, no change; same warning in the devel output and all that happens is the welcome screen loads? *From:*Ben Vinnerd [mailto:ben+catal...@vinnerd.com] mailto:[mailto:ben+catal...@vinnerd.com] *Sent:* 29 October 2012 14:48 *To:* The elegant MVC web framework *Subject:* Re: [Catalyst] Unable to output anything in Root.pm - 'auto' Private methods have to return a true value to continue processing. Try adding return 1 at the end of the method. Ben On 29 October 2012 14:23, Craig Chant cr...@homeloanpartnership.com mailto:cr...@homeloanpartnership.com wrote: Hi, I seem to be going round in circles unable to get Catalyst to output anything via ‘auto’? I made a change to the Root.pm to try to add authentication via the ‘auto’ method, but it does nothing? # always runs first! sub auto :Private { my ( $self, $c ) = @_; # Authenticate $c-response-body('Matched Members::Controller::Auto in Root.' . $c-sessionid); } This doesn’t output anything and I simply get the welcome screen, plus there is a warning in the devel server output of “Use of uninitialized value in concatenation (.) or string” I have .. use Catalyst qw/ -Debug ConfigLoader Static::Simple StackTrace Session Session::Store::FastMmap Session::State::Cookie /; In my main MyApp.pm Why is $c-response-body not working and why is the sessionid empty? Thanks */Craig Chant/* I.T. Manager Description: cid:image001.png@01CD5F4A.17E848D0 Main Line01903 602664 tel:01903%20602664 Direct Line 01903 227753 tel:01903%20227753 Visit our website http://www.homeloanpartnership.com *HomeLoan Partnership have been named the Best Mortgage Network, 2012, at the myintroducer.com http://myintroducer.com Industry Awards* This Email and any attachments contain confidential information and is intended solely for the individual to whom it is addressed. If this Email has been misdirected, please notify the author as soon as possible. If you are not the intended recipient you must not disclose, distribute, copy, print or rely on any of the information contained, and all copies must be deleted immediately. Whilst we take reasonable
Re: [Catalyst] Unable to output anything in Root.pm - 'auto'
On 10/29/2012 04:43 PM, Craig Chant wrote: By the way, what do you need the session-id for? Catalyst handles sessions in a transparent way To authenticate users, I don't want to store authentication in the hash and it seems the only other way to do this is via ORM, which I don't want to use either. I find catalyst whenever I look at how it implements anything to do with DB access, it forces ORM upon you, so I need to write my own authentication code don't I ? There are lots of authentication modules on cpan. I guess there is something for you: Examples: Catalyst::Authentication::Credential::Remote - let the webserver do authenticaion Catalyst::Authentication::Credential::HTTP - basic and digest authentication Catalyst::Authentication::Store::Htpasswd - use catalyst authentication with htpasswd-files Or you use Catalyst::Authentication::Store::Minimal, and populate the config hash within finalize_config (If you want to store accounts and passwords in a file, which has no standard-format. Is this what you meant with i don't want to store the autentication in the hash? In that case: Take a look at Config::Any. It might help you parsing your file.) https://metacpan.org is your friend :) ___ 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] Unable to output anything in Root.pm - 'auto'
Hey Craig, I got it. You want to store your credentials in a database, but you don't want to use DBIx::Class? What about Catalyst::Authentication::Storage::DBI? If this doesn't help, you might me right. Maybe you have to write your own authentication module. In that case, consider making it a Catalyst::Authentication::Store module, and publish it on cpan. It might be useful for others, too... By the way: Catalyst::Model::DBI is a ORM-less, raw DBI model for catalyst. So ... whenever I look at how it implements anything to do with DB access, it forces ORM upon you ... is not correct. There are very few things which are really forced by catalyst. Using DBIx::Class is just considered good practice. A lot of people use it, thats why it is used in most tutorials and examples. Lukas On 10/29/2012 05:09 PM, Craig Chant wrote: Yes, but I need to keep a backed DB up-to-date with current logins, where in the system they are etc... So local server disk won't help in this situation. -Original Message- From: Denny [mailto:2...@denny.me] Sent: 29 October 2012 15:50 To: The elegant MVC web framework Subject: RE: [Catalyst] Unable to output anything in Root.pm - 'auto' On Mon, 2012-10-29 at 15:43 +, Craig Chant wrote: By the way, what do you need the session-id for? Catalyst handles sessions in a transparent way To authenticate users, I don't want to store authentication in the hash and it seems the only other way to do this is via ORM, which I don't want to use either. I find catalyst whenever I look at how it implements anything to do with DB access, it forces ORM upon you, so I need to write my own authentication code don't I ? I'm pretty sure the default storage for session stuff is disk-based. ___ 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/ This Email and any attachments contain confidential information and is intended solely for the individual to whom it is addressed. If this Email has been misdirected, please notify the author as soon as possible. If you are not the intended recipient you must not disclose, distribute, copy, print or rely on any of the information contained, and all copies must be deleted immediately. Whilst we take reasonable steps to try to identify any software viruses, any attachments to this e-mail may nevertheless contain viruses, which our anti-virus software has failed to identify. You should therefore carry out your own anti-virus checks before opening any documents. HomeLoan Partnership will not accept any liability for damage caused by computer viruses emanating from any attachment or other document supplied with this e-mail. HomeLoan Partnership reserves the right to monitor and archive all e-mail communications through its network. No representative or employee of HomeLoan Partn ership ha s the authority to enter into any contract on behalf of HomeLoan Partnership by email. HomeLoan Partnership is a trading name of H L Partnership Limited, registered in England and Wales with Registration Number 5011722. Registered office: 26-34 Old Street, London, EC1V 9QQ. H L Partnership Limited is authorised and regulated by the Financial Services Authority. ___ 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] Unable to output anything in Root.pm - 'auto'
', 'user_role_table'= 'competence', 'user_role_user_key' = 'login', 'user_role_role_key' = 'authority', }, }, }, };[/quote] Have I read the above incorrectly? I have a non-normalised DB , with an application that functions in a particular way, I deal with user roles and other such stuff in my own way and I cannot refactor to use catalyst without ensuring all sections of the system function the same along with the back end admin system, I can't rewrite both parts at the same time, this is a live app in production that works currently, I'm simply trying to learn Catalyst MVC cuteness, not start from scratch. From what I can see using any of those authentication modules expects certain data I don't have or use nor want. Please correct me if I'm reading the CPAN documentation incorrectly. I want to refactor my app to be MVC using Catalyst without being forced to do any other than MVC cuteness and work the way I want to with the a database that already exists, I got the feeling Catalyst allows this unlike ROR or other MVC frameworks. Again, have I got this wrong? If to use Catalyst I have to have a normalised DB, use specific modules with data in a particular format, then I will just refactor our systems myself using my own modules and such, best to find this out now before I spend any more time on something that isn't suitable. Thanks, Craig. -Original Message- From: Lukas Thiemeier [mailto:spamcatc...@thiemeier.net] Sent: 29 October 2012 16:42 To: catalyst@lists.scsys.co.uk Subject: Re: [Catalyst] Unable to output anything in Root.pm - 'auto' Hey Craig, I got it. You want to store your credentials in a database, but you don't want to use DBIx::Class? What about Catalyst::Authentication::Storage::DBI? If this doesn't help, you might me right. Maybe you have to write your own authentication module. In that case, consider making it a Catalyst::Authentication::Store module, and publish it on cpan. It might be useful for others, too... By the way: Catalyst::Model::DBI is a ORM-less, raw DBI model for catalyst. So ... whenever I look at how it implements anything to do with DB access, it forces ORM upon you ... is not correct. There are very few things which are really forced by catalyst. Using DBIx::Class is just considered good practice. A lot of people use it, thats why it is used in most tutorials and examples. Lukas On 10/29/2012 05:09 PM, Craig Chant wrote: Yes, but I need to keep a backed DB up-to-date with current logins, where in the system they are etc... So local server disk won't help in this situation. -Original Message- From: Denny [mailto:2...@denny.me] Sent: 29 October 2012 15:50 To: The elegant MVC web framework Subject: RE: [Catalyst] Unable to output anything in Root.pm - 'auto' On Mon, 2012-10-29 at 15:43 +, Craig Chant wrote: By the way, what do you need the session-id for? Catalyst handles sessions in a transparent way To authenticate users, I don't want to store authentication in the hash and it seems the only other way to do this is via ORM, which I don't want to use either. I find catalyst whenever I look at how it implements anything to do with DB access, it forces ORM upon you, so I need to write my own authentication code don't I ? I'm pretty sure the default storage for session stuff is disk-based. ___ 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/ This Email and any attachments contain confidential information and is intended solely for the individual to whom it is addressed. If this Email has been misdirected, please notify the author as soon as possible. If you are not the intended recipient you must not disclose, distribute, copy, print or rely on any of the information contained, and all copies must be deleted immediately. Whilst we take reasonable steps to try to identify any software viruses, any attachments to this e-mail may nevertheless contain viruses, which our anti-virus software has failed to identify. You should therefore carry out your own anti-virus checks before opening any documents. HomeLoan Partnership will not accept any liability for damage caused by computer viruses emanating from any attachment or other document supplied with this e-mail. HomeLoan Partnership reserves the right to monitor and archive all e-mail communications through its network. No representative or employee of HomeLoan Partn ership ha s the authority to enter into any contract on behalf of HomeLoan Partnership by email. HomeLoan Partnership is a trading name of H L Partnership Limited, registered in England and Wales with Registration Number
Re: [Catalyst] Why is $c undefined?
Hi again, $c is automatically passed to Catalyst-actions (not methods), but only if you use Catalyst to do so. If you call $self-someaction; or $c-controller('SomeController')-someaction(); it is not passed. How can catalyst know if you are calling a catalyst action, or any method on any object? And even if the object is a catalyst controller, how can catalyst know if it is a action, which requires the context, or just a helper, which doesn't use the context? If you want catalyst to pass $c, use $c-forward, $c-detach, $c-visit and $c-go instead: $c-forward(/someaction); or $c-forward($c-controller('MyController')-action_for(someaction)); or $c-forward(/somecontroller/someaction); Read the main catalyst docs for details. (perldoc Catalyst) Lukas On 10/29/2012 08:07 PM, Craig Chant wrote: Hi, I seem to be unable to work out why $c is never automatically passed to any of my models or methods? I have in root.pm # always runs first! sub begin :Private { my ( $self, $c ) = @_; # Authenticate $self-AuthenticateUser(); return 1; } I then have... sub AuthenticateUser { my ( $self, $c ) = @_; $c-session; if(!$c-model('Members')-LogCheck($c)){ $c-uri_for_action('/login/login'); } } However, $c is undefined and errors, it only works if I pass it $c from 'begin'.. $self-AuthenticateUser($c); I was under the impression that $c was the context (Catalyst) default variable and was always passed to every method / subroutine. is this not the case? Thanks, Craig . This Email and any attachments contain confidential information and is intended solely for the individual to whom it is addressed. If this Email has been misdirected, please notify the author as soon as possible. If you are not the intended recipient you must not disclose, distribute, copy, print or rely on any of the information contained, and all copies must be deleted immediately. Whilst we take reasonable steps to try to identify any software viruses, any attachments to this e-mail may nevertheless contain viruses, which our anti-virus software has failed to identify. You should therefore carry out your own anti-virus checks before opening any documents. HomeLoan Partnership will not accept any liability for damage caused by computer viruses emanating from any attachment or other document supplied with this e-mail. HomeLoan Partnership reserves the right to monitor and archive all e-mail communications through its network. No representative or employee of HomeLoan Partnership has the authority to enter into any contract on behalf of HomeLoan Partnership by email. HomeLoan Partnership is a trading name of H L Partnership Limited, registered in England and Wales with Registration Number 5011722. Registered office: 26-34 Old Street, London, EC1V 9QQ. H L Partnership Limited is authorised and regulated by the Financial Services Authority. ___ 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] Unable to output anything in Root.pm - 'auto'
Hi Craig, Using C::M::DBI is straight forward. Install it from cpan, and run script/yourapp.pl create model DBI DBI dsn user password where dsn is sth like dbi:mysql:dbname, depending on your backend. If it doesn't work you most likely have some typo in your dsn, username or password. When this doesn't work, what error is printed? What was your input (except passwd, of course)? Something like $c-dbh doesn't exist. The database handler belongs to the model, and you can create Cat applications with several models, or without any model at all. (Or with a model which is not a database-model, or, or ...) $c-model('DBI')-dbh does the trick. The name DBI is required by C::A::Store::DBI, but besides this, any model name is fine. Alternatively, add a shortcut to your main App.pm: sub dbh{ shift-model(DBI)-dbh } Now, $c-dbh is available. Session timeouts et cetera are configurable in the session plugin. The session keeps track of when it was created, and when it was updated. Setting extra fields (in the session or in the database), which are not automatically set by the authentication plugin, can easily be done by you, even if you use a authentication plugin. You can do this in the auto action, for example. I can only suggest you to search for existing modules, and use them whenever possible. Thanks to Moose, extending a catalyst module is easy in most cases. And it is much less work than writing everything from scratch. In my opinion, the biggest benefit of catalyst is (besides its great backwards compatibility), that it is very modular, dozens of modules exist, and most modules are extendable and reusable. If you try to write all your code by yourself, you will not get happy. Another suggestion: Maybe you should first forget about your real applicationfor now, and just work through the catalyst tutorial. You can finish it in some hours (depending on your perl- and web knowledge). It will give you a great overview about how Catalyst works, what is possible (almost everything) and what isn't possible (almost nothing) :) Or maybe you don't need a monster like catalyst? Dancer might be an option. Dancer is a perl MVC Framework, too. It is much smaller and simpler than Catalyst, has less dependencies and less modules and (at least I was told so) is easier to learn. It does not do as much for you as catalyst does (in most cases, you have to write more code). But if you have to reinvent the wheel again and again anyway, it might be a better choice. Don't get me wrong. I don't suggest you to let catalyst go. Catalyst rocks! But if most of the benefits are really not an option for you, you should think about alternatives. And finally: Don't make unpaid overtime: Go and get a beer! NOW! Catalyst will be more fun tomorrow! Ooops, I am writing this while making unpaid overtime. I will go and get a beer :) bye, Lukas On 10/29/2012 08:25 PM, Craig Chant wrote: Hi Lukas, I tried to use C::Model::DBI , but I cannot get it to work? I've ended up refactoring my own SQL module from the exisitng app as OOP and then as an extension of Catayst::Model I then create my own Model which extends my SQL module and I've got it working. No matter what I tried , I couldn't find $c-dbh , I really seem to be struggling at the moment getting my head round Catalyst, but I am persevering! I was hoping to use the built in DBI functionality, as it is meant to keep database handles / connections open etc..but $c-dbh didn't exits in my Model when I created it via myapp_create.pl MODEL DBI I also appreciate there is a lot of stuff already written such as the authentication mechanism, but will that update my backend DB with the current location of the user? Does it have a mechanism to enable 'heartbeat' to keep idle sessions open? Will it keep up-to-date the date / time field so we can see at a glance the length of time a user has been logged on via our admin system? Or does it simply keep a state of whether the user is loged in or not? I also know that I should look at ORM and DBIC, but one thing at a time, Rome wasn't built in a day, and playing with Catalyst is simply something I want to do, not a requirement of my Job. I start a 10 month SQL course in January, where I'm sure I will learn about DB's in far more detail and can then consider ORM / DBIC. There is only so many hours in the day, then there are only so many I am paid to work and then there is only so much information I can absorb in one go! I'm already sitting here doing unpaid overtime, but I'm commited to getting Catalyst working, so don't mind putting in the extra hours, sounds sad I know, but I am enjoying it, even if I seem frustrated at times. Thank for all the input. Craig. From: Lukas Thiemeier [spamcatc...@thiemeier.net] Sent: 29 October 2012 19:03 To: catalyst@lists.scsys.co.uk Subject: Re: [Catalyst] Unable to output
Re: [Catalyst] Unable to output anything in Root.pm - 'auto'
On 10/29/2012 11:30 PM, Rob Brown wrote: basically... $sth-finish if you've finished with the results of that statement, ie, you've looped through the rows and are now done. $dbh-disconnect if you've finished with the database connection, tho now you start to think about working in a persistent environment, where you may never disconnect from the database, and/or have some connection caching setup. This is where DBIx::Class just takes of all this for you - it does sound like you're re-inventing a lot here. What was the reason for not using DBIC again? Right. If you need more help about DBI, dbi-us...@perl.org is a better place to ask. Not that we catalyst users are not willing to help you, but most people here know much about Catalyst, and not-as-much about DBI. Feel free to ask your DBI questions here, but if it comes to DBI details, the people reading dbi-us...@perl.org are, well, more qualified. The chance to get helpful answers (or any answers at all, for more special/difficult questions) is much higher if you post to the right list... Lukas On 10/29/2012 10:10 PM, Craig Chant wrote: I finally got to grips with extending my own class with the inbuilt $c-dbh. But am unsure whether I am mean to issue either... $sth-finish(); or $dbh-disconnect(); Once I have prepared / executed the SQL and fetched the records I want. so a little further guidance is appreciated. Craig From: Lukas Thiemeier [spamcatc...@thiemeier.net] Sent: 29 October 2012 20:16 To: catalyst@lists.scsys.co.uk Subject: Re: [Catalyst] Unable to output anything in Root.pm - 'auto' Hi Craig, Using C::M::DBI is straight forward. Install it from cpan, and run script/yourapp.pl create model DBI DBI dsn user password where dsn is sth like dbi:mysql:dbname, depending on your backend. If it doesn't work you most likely have some typo in your dsn, username or password. When this doesn't work, what error is printed? What was your input (except passwd, of course)? Something like $c-dbh doesn't exist. The database handler belongs to the model, and you can create Cat applications with several models, or without any model at all. (Or with a model which is not a database-model, or, or ...) $c-model('DBI')-dbh does the trick. The name DBI is required by C::A::Store::DBI, but besides this, any model name is fine. Alternatively, add a shortcut to your main App.pm: sub dbh{ shift-model(DBI)-dbh } Now, $c-dbh is available. Session timeouts et cetera are configurable in the session plugin. The session keeps track of when it was created, and when it was updated. Setting extra fields (in the session or in the database), which are not automatically set by the authentication plugin, can easily be done by you, even if you use a authentication plugin. You can do this in the auto action, for example. I can only suggest you to search for existing modules, and use them whenever possible. Thanks to Moose, extending a catalyst module is easy in most cases. And it is much less work than writing everything from scratch. In my opinion, the biggest benefit of catalyst is (besides its great backwards compatibility), that it is very modular, dozens of modules exist, and most modules are extendable and reusable. If you try to write all your code by yourself, you will not get happy. Another suggestion: Maybe you should first forget about your real applicationfor now, and just work through the catalyst tutorial. You can finish it in some hours (depending on your perl- and web knowledge). It will give you a great overview about how Catalyst works, what is possible (almost everything) and what isn't possible (almost nothing) :) Or maybe you don't need a monster like catalyst? Dancer might be an option. Dancer is a perl MVC Framework, too. It is much smaller and simpler than Catalyst, has less dependencies and less modules and (at least I was told so) is easier to learn. It does not do as much for you as catalyst does (in most cases, you have to write more code). But if you have to reinvent the wheel again and again anyway, it might be a better choice. Don't get me wrong. I don't suggest you to let catalyst go. Catalyst rocks! But if most of the benefits are really not an option for you, you should think about alternatives. And finally: Don't make unpaid overtime: Go and get a beer! NOW! Catalyst will be more fun tomorrow! Ooops, I am writing this while making unpaid overtime. I will go and get a beer :) bye, Lukas On 10/29/2012 08:25 PM, Craig Chant wrote: Hi Lukas, I tried to use C::Model::DBI , but I cannot get it to work? I've ended up refactoring my own SQL module from the exisitng app as OOP and then as an extension of Catayst::Model I then create my own Model which extends my SQL module and I've got it working. No matter what I tried , I couldn't find $c-dbh , I really seem to be struggling at the moment getting my head round Catalyst, but I am persevering! I
Re: [Catalyst] Catalyst - Creating DB dump - Getting “No tables found, did you forget to specify db_schema?” on MS SQL Server connection
On 09/11/2012 07:56 PM, Derek W wrote: I'm trying to create a Catalyst project connecting to an existing MS SQL Server database. I got the correct connection string and it's authenticating, but it's not finding any tables. Anyone have an idea of what I might be missing? I substituted the real ip address, database name, username, and password but you get the idea. This is the command I run: script\qa_utility_create.pl model DB DBIC::Schema QA_Utility::Schema create=static db_schema=DatabaseName dbi:ODBC:Driver={sql server};Server=1.1.1.1,1433;Database=DatabaseName username password When I run this, I get the below error: exists C:\strawberry\perl\site\bin\QA_Utility\lib\QA_Utility\Model exists C:\strawberry\perl\site\bin\QA_Utility\t Dumping manual schema for QA_Utility::Schema to directory C:\strawberry\perl\site\bin\QA_Utility\lib ... Schema dump completed. WARNING: No tables found, did you forget to specify db_schema? exists C:\strawberry\perl\site\bin\QA_Utility\lib\QA_Utility\Model\DB.pm I wanted to quickly get a simple CRUD web app for our existing database using perl but I'm starting to think this is not going to happen with SQL server? Hi, I think this is more a DBIx::Class issue than a Catalyst issue. I am not really sure about what I am going write next, but give it a try. Maybe it helps: 1. If I understand the docs right, specifying a db_schema is only required if you want to load more than one schema. See https://metacpan.org/module/DBIx::Class::Schema::Loader#KNOWN-ISSUES and https://metacpan.org/module/DBIx::Class::Schema::Loader::Base#db_schema Since you specified a database in your dsn, did you try to omit the db_schema option? 2. I never worked with ODBC, and I am not working on windows. But: If I try to do the same as you on Unix, using dbi:mysql, I get the same error as you. If I omit the quotes around db_schema=... everything works fine. I get my schema files created correctly, even if I do not specify the databasename within the dsn. So, try to use db_schema=DatabaseName instead of db_schema=DatabaseName As I stated before, this answer is more guessing than knowledge. If it doesn't help, you will have to wait for a more professional answer. If nobody can help you here, you might try asking the DBIC list, or via irc in #dbix-class. I hope I could help. And if my answer is rubbish, just ignore me :) Cheers, lukast ___ 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] Applying roles that contain actions.
My Last years Advent articles might help. It is a introduction to creating Chained Catalyst actions in Moose::Role(s): http://www.catalystframework.org/calendar/2011/10 http://www.catalystframework.org/calendar/2011/17 cheers, lukast On 09/05/2012 10:48 PM, Bill Moseley wrote: I've been injecting models into Catalyst apps (either using CatalystX::InjectComponent or just stuffing an instance into $app-components hash). I'd also like to be able to apply roles to existing controllers. If I try to -apply the role it fails if using MooseX::MethodAttributes::Role. Which I assume is because the actions would not be registered with Catalyst. Is there a way to inject actions in this way? Currently I just manually apply the role directly in the existing controller, so not a huge issue, but would be handy if I could just add a role to the base class and pull in all the components -- or dynamically add the actions. In general, what I'm after is a way to specify with App::Feature::Widget; in my app base class and bring in an entire feature. I'm also looking at a gatekeeper type of feature control that Facebook is known for: https://www.facebook.com/video/video.php?v=10100259101684977oid=9445547199comments https://www.facebook.com/video/video.php?v=10100259101684977oid=9445547199comments -- Bill Moseley mose...@hank.org mailto:mose...@hank.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/ ___ 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] DBIx::HA
Hi Theo, Take a look at Getting Help and Support on http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class.pm cheers, Lukas On 08/26/2012 10:49 AM, Theo Bot wrote: Tom You are right. It's an DBIC issue. Do you happen to know where I csn address this issue? Regards Theo On Sat, Aug 25, 2012 at 2:07 PM, Tomas Doranbobtf...@bobtfish.net wrote: On 25 Aug 2012, at 10:41, Theo Bot wrote: I already create a model with the ..._create.pl script. But I want to use a dual-master mysql setup. And I want the application server to be able to failover over to a back-up server. Yes, and this functionality is nothing to do with Catalyst, so I don't see how Catalyst is relevant here ;) Cheers t0m ___ 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/ ___ 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] using perldoc on VM
On 06/11/2012 03:38 PM, John Deighan wrote: I'm using the Catalyst VM that accompanies the catalyst tutorial. I'm currently unable to use perldoc: catalyst@catalyst:~/MyApp$ perldoc Session::Store You need to install the perl-doc package to use this program. Can someone please tell me how to install perl-doc on the VM so I can view Perl documentation there? ___ 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/ Hi, This highly depends on your distribution, and is totaly unrelated to catalyst. On debian based systems, perldoc is included in the package perl-doc, so you can install it by runnig apt-get install perl-doc as root. Since the output on your console says You need to install the perl-doc package..., a reasonable first step would be to follow these instructions and install the perl-doc package! On redhat based systems, perldoc should be included in in the main perl package, but it has been a while since I was working on redhat, so i am not sure if this is right. If you build your own perl, e.g with perlbrew (which I recommend) perldoc should be included. Cheers, Lukas ___ 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/