Re: [Catalyst] how to reuse Catalyst Schema for non-web purposes?

2009-04-27 Thread Matt S Trout
On Fri, Apr 24, 2009 at 02:08:14PM +1000, kakim...@tpg.com.au wrote:
> I took off the 'Authentication::Store::DBIC' from my "use Catalyst qw(" in 
> myApp.pm.
> 
> This is such that " Catalyst/Plugin/Authentication/Store/DBIx/Class.pm" will 
> not be required.
> After all, no such thing exists(checked cpan).

Right, that's because only -old- authentication stores were under
Catalyst::Plugin::Authentication::Store:: - the new style stores aren't
plugins because they don't need to be so they're under
Catalyst::Authentication::Store::

> Strangely, when I run scripts/myApp_server.pl, 
> I got this message: 
> 
> -- error message - start 
> [error] Caught exception in myApp::Controller::Root->auto "Can't call method 
> "user_is_restorable" 
> on an undefined value at 
> /usr/local/lib/perl5/site_perl/5.8.9/Catalyst/Plugin/Authentication.pm line 
> 168."
> -- error message - end 

Without seeing your current config I can't tell you waht's gone wrong there.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical Directorhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/http://www.shadowcat.co.uk/servers/

___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-23 Thread kakimoto
I took off the 'Authentication::Store::DBIC' from my "use Catalyst qw(" in 
myApp.pm.

This is such that " Catalyst/Plugin/Authentication/Store/DBIx/Class.pm" will 
not be required.
After all, no such thing exists(checked cpan).


Strangely, when I run scripts/myApp_server.pl, 
I got this message: 

-- error message - start 
[error] Caught exception in myApp::Controller::Root->auto "Can't call method 
"user_is_restorable" 
on an undefined value at 
/usr/local/lib/perl5/site_perl/5.8.9/Catalyst/Plugin/Authentication.pm line 
168."
-- error message - end 

 I found a thread which I think is fairly similar. It's http://www.mail-
archive.com/catalyst@lists.scsys.co.uk/msg04758.html. 
Going to give it a go and will share with you guys on my findings:)

K. akimoto



Quoting kakim...@tpg.com.au:

> Gah Thanks, moritz.. 2am here and my coffee's runnin' low.
>  haha 
> that's the case i figure. I will give it a go tomorrow.
>  Cheers!
> 
> 
> Quoting Moritz Onken :
> 
> > >
> > >
> > > So it's the model I put the business logic in?  That sounds ok,
> for
> >  
> > > now.  But what about this:
> > > * Input from the web has to be validated.  May be I use  
> > > Data::FormValidator, may be FormFu.  However, I may have to
> > validate  
> > > the params I get from the script (eg. data import from ERP
> > systems),  
> > > too.  Do I have to implement the validation again?  And maybe  
> > > normalization/converting, too?  Or where would you place these  
> > > functionality?  Extra modules?
> > 
> > You are not limited by the number of models. You can write a model 
> 
> > which does the form/data validation and which calls the dbic model
> to
> >  
> > insert the data. Just place an extra layer between your controller
> > and  
> > your dbic model.
> > 
> > > * What about business logic that is in not only bound to a
> specific
> >  
> > > schema but has an overall logic that fetches data from different 
> 
> > > tables, adds some somewhere and produces results?  How would you 
> 
> > > implement such a logic?  Any examples?
> > 
> > I would write an extra model for this or you create a resultset
> class
> >  
> > which can handle that. This very much depends on the data which is 
> 
> > needed.
> > 
> > > * An example for using data and logic outside of the web app
> would 
> > 
> > > be generating invoices by night.  That process would bring out
> some
> >  
> > > PDFs which will be printed or sent by mail through another
> script. 
> >  
> > > Shouldn't a view be involved in this process that builds the PDFs
> 
> > 
> > > from templates?  Is it possible to build this example upon a  
> > > Catalyst web app?  Examples?
> > 
> > I use Template::Plugin::Latex to create a TeX document which is
> then 
> > 
> > converted to a pdf. But this is totally independent from catalyst.
> It
> >  
> > is a script which is run once a day and generates the invoices. No 
> 
> > need to follow the MVC scheme here.
> > 
> > If you plan to run those jobs with catalyst I'll suggest you have a
> 
> > 
> > look a job queue which can help you with that (e.g. TheSchwartz).
> > 
> > 
> > moritz
> > 
> > ___
> > 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] how to reuse Catalyst Schema for non-web purposes?

2009-04-23 Thread Matt S Trout
On Thu, Apr 23, 2009 at 08:12:23AM +1000, kakim...@tpg.com.au wrote:
>  Execution of test - start 
> kakim...@dev-machine:~/projects/myApp/t$ prove -v userSubscriptions.t 
> userSubscriptions.t .. 
> ok 1 - use myApp::Schema::UserSubscriptions;
> ok 2 - The object isa myApp::Schema::UserSubscriptions
> ok 3 - myApp::Schema::UserSubscriptions->can('subscriptions_id')
> ok 4 - myApp::Schema::UserSubscriptions->can('name')
> ok 5 - myApp::Schema::UserSubscriptions->can('user_id')
> ok 6 - myApp::Schema::UserSubscriptions->can('comments')
> ok 7 - myApp::Schema::UserSubscriptions->can('rea_agent_code')
> 1..7
> Can't call method "resolve" on an undefined value at
> /usr/local/lib/perl5/site_perl/5.8.9/DBIx/Class/Row.pm line 720.
> # Looks like your test exited with 255 just after 7.
> Dubious, test returned 255 (wstat 65280, 0xff00)
> All 7 subtests passed 
>
> foreach my $new_subscription ( @user_subscriptions )
> {
> my $new_user_sub = $package_name->new();
> isa_ok ( $new_user_sub, $package_name );
> 
> foreach my $attr ( keys %{$new_subscription} )
> {
> can_ok ($new_user_sub, $attr);
> $new_user_sub->$attr($new_subscription);
> }
> $new_user_sub->insert();
> }

Right, so, you've created a row object directly with new(), never
associated it with a live, connected $schema, and then you're trying
to ->insert. The error message could be better, but of -course- that
doesn't work. You wanted to create a $schema and do -

$schema->resultset('User')->new({});

I suspect. Please don't just guess how to use DBIx::Class outside of
Catalyst, read the DBIx::Class manual - and please ask further DBIx::Class
specific questions on the relevant list; this isn't really anything to
do with Catalyst ...

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical Directorhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/http://www.shadowcat.co.uk/servers/

___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-23 Thread kakimoto
Gah Thanks, moritz.. 2am here and my coffee's runnin' low.
 haha 
that's the case i figure. I will give it a go tomorrow.
 Cheers!


Quoting Moritz Onken :

> >
> >
> > So it's the model I put the business logic in?  That sounds ok, for
>  
> > now.  But what about this:
> > * Input from the web has to be validated.  May be I use  
> > Data::FormValidator, may be FormFu.  However, I may have to
> validate  
> > the params I get from the script (eg. data import from ERP
> systems),  
> > too.  Do I have to implement the validation again?  And maybe  
> > normalization/converting, too?  Or where would you place these  
> > functionality?  Extra modules?
> 
> You are not limited by the number of models. You can write a model  
> which does the form/data validation and which calls the dbic model to
>  
> insert the data. Just place an extra layer between your controller
> and  
> your dbic model.
> 
> > * What about business logic that is in not only bound to a specific
>  
> > schema but has an overall logic that fetches data from different  
> > tables, adds some somewhere and produces results?  How would you  
> > implement such a logic?  Any examples?
> 
> I would write an extra model for this or you create a resultset class
>  
> which can handle that. This very much depends on the data which is  
> needed.
> 
> > * An example for using data and logic outside of the web app would 
> 
> > be generating invoices by night.  That process would bring out some
>  
> > PDFs which will be printed or sent by mail through another script. 
>  
> > Shouldn't a view be involved in this process that builds the PDFs 
> 
> > from templates?  Is it possible to build this example upon a  
> > Catalyst web app?  Examples?
> 
> I use Template::Plugin::Latex to create a TeX document which is then 
> 
> converted to a pdf. But this is totally independent from catalyst. It
>  
> is a script which is run once a day and generates the invoices. No  
> need to follow the MVC scheme here.
> 
> If you plan to run those jobs with catalyst I'll suggest you have a 
> 
> look a job queue which can help you with that (e.g. TheSchwartz).
> 
> 
> moritz
> 
> ___
> 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] how to reuse Catalyst Schema for non-web purposes?

2009-04-23 Thread Moritz Onken



So it's the model I put the business logic in?  That sounds ok, for  
now.  But what about this:
* Input from the web has to be validated.  May be I use  
Data::FormValidator, may be FormFu.  However, I may have to validate  
the params I get from the script (eg. data import from ERP systems),  
too.  Do I have to implement the validation again?  And maybe  
normalization/converting, too?  Or where would you place these  
functionality?  Extra modules?


You are not limited by the number of models. You can write a model  
which does the form/data validation and which calls the dbic model to  
insert the data. Just place an extra layer between your controller and  
your dbic model.


* What about business logic that is in not only bound to a specific  
schema but has an overall logic that fetches data from different  
tables, adds some somewhere and produces results?  How would you  
implement such a logic?  Any examples?


I would write an extra model for this or you create a resultset class  
which can handle that. This very much depends on the data which is  
needed.


* An example for using data and logic outside of the web app would  
be generating invoices by night.  That process would bring out some  
PDFs which will be printed or sent by mail through another script.   
Shouldn't a view be involved in this process that builds the PDFs  
from templates?  Is it possible to build this example upon a  
Catalyst web app?  Examples?


I use Template::Plugin::Latex to create a TeX document which is then  
converted to a pdf. But this is totally independent from catalyst. It  
is a script which is run once a day and generates the invoices. No  
need to follow the MVC scheme here.


If you plan to run those jobs with catalyst I'll suggest you have a  
look a job queue which can help you with that (e.g. TheSchwartz).



moritz

___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-23 Thread Matthias Dietrich

Hi,

this is an interesting topic.  I'm also one of that guys that put  
business logic into the controllers, but I never released any project  
yet, so it's my "test Catalyst" period and I'm still learning :) (and  
I never used MVC before).


I had that problem to use data of the db outside of the web app from a  
perl script.  What I have done so far is to use  
Catalyst::Plugin::CommandLine and accessed the model (that contains no  
business logic, the scripts actions differ from those of the web  
app).  That was fine for me in that situation.


Now, if I want to use business logic - which is implemented in  
Catalyst - in my script, I would get stuck.  Where should I place the  
business logic that I want to use on both ends?  In the controller  
actions?  No way, I don't want to call the action that is called  
though the web browser - because I might have some more logic that  
should be executed only when coming over the web.  (I asked a similar  
question to me very often yet: where to put business logic that is  
used by controller action A *and* B?)


There may be the possibility to add a new function to the namespace of  
one of the Controllers, but that sounds ugly to me.


So it's the model I put the business logic in?  That sounds ok, for  
now.  But what about this:
 * Input from the web has to be validated.  May be I use  
Data::FormValidator, may be FormFu.  However, I may have to validate  
the params I get from the script (eg. data import from ERP systems),  
too.  Do I have to implement the validation again?  And maybe  
normalization/converting, too?  Or where would you place these  
functionality?  Extra modules?
 * What about business logic that is in not only bound to a specific  
schema but has an overall logic that fetches data from different  
tables, adds some somewhere and produces results?  How would you  
implement such a logic?  Any examples?
 * An example for using data and logic outside of the web app would  
be generating invoices by night.  That process would bring out some  
PDFs which will be printed or sent by mail through another script.   
Shouldn't a view be involved in this process that builds the PDFs from  
templates?  Is it possible to build this example upon a Catalyst web  
app?  Examples?


Thanks for listening, looking forward to the answers...

Matt

--
rainboxx Matthias Dietrich
Freier Software Engineer

rainboxx  |  Tel.: +49 (0) 151 / 50 60 78 64
Tölzer Str. 19|  Mail: m...@rainboxx.de
70372 Stuttgart   |  WWW : http://www.rainboxx.de

XING: https://www.xing.com/profile/Matthias_Dietrich18
GULP: http://www.gulp.de/profil/rainboxx.html



PGP.sig
Description: Signierter Teil der Nachricht
___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-23 Thread Simon Wilcox

On 23/4/09 03:59, kakim...@tpg.com.au wrote:

From the Catalyst tutes, I seem to get the impression that pretty much a

lot of the business logic is done in the controller.


Yes, because it's a Catalyst tutorial not a tutorial for whatever model 
provider you choose to use.


You *can* put your logic in the controller and if all you will ever 
build is a single web app that doesn't need to talk to anything else 
then that's fine.


The general experience is that, in the long term, making the web app a 
simple layer over a standalone model is more flexible, easier to extend 
and easier to test.


But it's up to you, I suggest reading more widely around the concepts 
behind MVC and do whatever works best for you. As Kieren says, you'll 
learn by experience :-)


Best of luck.

Simon.

___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread Kieren Diment


On 23/04/2009, at 1:48 PM, kakim...@tpg.com.au wrote:


Hello Kieren,

   thank you for the link,
http://blog.hide-k.net/archives/2008/10/dbixclassresult_1.php.


Please correct me if I am wrong.
Say if I have a Schema file, Schema/Subscriptions.pm

After the section, "DO NOT MODIFY ANYTHING ABOVE THIS! ",
I start declaring functions (not methods).


sub is_trial_period
{
  # evaluate if trial period is over or not
  # as this has to be determined through a set
  # of business rules.
  ...
}

sub is_promo_period
{
  # evaluate if promo period is still on or not
  # as this has to be determined through a set
  # of business rules.
  ...
}




Here's some code I have lying around:

use strict;
use warnings;

package Zotero::Schema::Collections;


use base 'DBIx::Class';

__PACKAGE__->load_components("Tree::AdjacencyList","Core");
__PACKAGE__->table("collections");
__PACKAGE__->resultset_class('Zotero::ResultSet::Collections');
__PACKAGE__->add_columns(
  "collectionid",
  { data_type => "INTEGER", is_nullable => 0, size => undef },
  "collectionname",
  { data_type => "TEXT", is_nullable => 0, size => undef },
  "parentcollectionid",
  { data_type => "INT", is_nullable => 0, size => undef },
);
__PACKAGE__->set_primary_key("collectionid");
__PACKAGE__->has_many(
  "collections",
  "Zotero::Schema::Collections",
  { "foreign.parentcollectionid" => "self.collectionid" },
);
__PACKAGE__->has_many(
  "collectionitems",
  "Zotero::Schema::Collectionitems",
  { "foreign.collectionid" => "self.collectionid" },
);


# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-08-04 20:07:34
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wOyyez2QNjtYXdJsmFHQFQ


__PACKAGE__->parent_column("parentcollectionID");


1;

package Zotero::ResultSet::Collections;
use warnings;
use strict;

use base qw/DBIx::Class::ResultSet/;

sub get_collections_tree {
my $self = shift;
my @res;
my $rs = $self->search( {parentcollectionid => undef},
{order_by => [ 'collectionname' ] },
);
while (my $node =  $rs->next) {
push @res, $self->get_children($node);
}
return \...@res;
}

sub get_children {
my ($self, $node ) = @_;
my $res = {};
$res->{title} = $node->collectionname ;
$res->{key} = $node->collectionid;
my @kids = $node->children;
$res->{expand} = 1;
$DB::single=1;
if (@kids) {
my @children;
foreach (@kids) {
 push @children, [$self->get_children($_)];
}
$res->{children} = \...@children;
}
return $res;
}

1;






___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread kakimoto
Hello Kieren,

thank you for the link,
http://blog.hide-k.net/archives/2008/10/dbixclassresult_1.php.


Please correct me if I am wrong.
Say if I have a Schema file, Schema/Subscriptions.pm

After the section, "DO NOT MODIFY ANYTHING ABOVE THIS! ",
 I start declaring functions (not methods).


sub is_trial_period
{
   # evaluate if trial period is over or not
   # as this has to be determined through a set
   # of business rules.
   ...
}

sub is_promo_period
{
   # evaluate if promo period is still on or not
   # as this has to be determined through a set
   # of business rules.
   ...
}


Have I got the right idea?


Thank you.

K. akimoto




Quoting Kieren Diment :

> 
> On 23/04/2009, at 12:59 PM, kakim...@tpg.com.au wrote:
> 
> >> From the Catalyst tutes, I seem to get the impression that pretty 
> 
> >> much a
> > lot of the business logic is done in the controller.
> >
> > I might be wrong but in
> >
>
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7020/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod#___top
> > ("Add a Method to Process Form Values and Update Database"),
> > it seems that the task of creating a new entry for books in the  
> > database
> > and establishing the right relationships to the book_authors  db
> table
> > is done in the sub form_create_do in the Controller.
> >
> > i suppose if a batch script were to be used to add in amany books,
> the
> > logic there would be trapped in the controller.
> >
> > How do we put that logic into the Model? very interesting and I
> would
> > like to hear more since I cant find any examples for putting
> business
> > logic in the Model for catalyst on google.
> >
> 
> This:  http://blog.hide-k.net/archives/2008/10/dbixclassresult_1.php 
> 
> is the blog post that I worked it out in, despite the text being in a
>  
> language I don't speak :)
> 
> ___
> 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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread Kieren Diment


On 23/04/2009, at 12:59 PM, kakim...@tpg.com.au wrote:

From the Catalyst tutes, I seem to get the impression that pretty  
much a

lot of the business logic is done in the controller.

I might be wrong but in
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7020/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod#___top
("Add a Method to Process Form Values and Update Database"),
it seems that the task of creating a new entry for books in the  
database

and establishing the right relationships to the book_authors  db table
is done in the sub form_create_do in the Controller.

i suppose if a batch script were to be used to add in amany books, the
logic there would be trapped in the controller.

How do we put that logic into the Model? very interesting and I would
like to hear more since I cant find any examples for putting business
logic in the Model for catalyst on google.



This:  http://blog.hide-k.net/archives/2008/10/dbixclassresult_1.php  
is the blog post that I worked it out in, despite the text being in a  
language I don't speak :)


___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread John Napiorkowski



--- On Wed, 4/22/09, kakim...@tpg.com.au  wrote:

> From: kakim...@tpg.com.au 
> Subject: Re: [Catalyst] how to reuse Catalyst Schema for non-web purposes?
> To: "Simon Wilcox" 
> Cc: "The elegant MVC web framework" 
> Date: Wednesday, April 22, 2009, 10:47 PM
> Hello, Simon,
> 
>   Your points have good weight for thoughts. In fact,
> coming from many
> backgrounds pre-Catalyst and pre-MVC (ie many a times, the
> templating
> system ie Mason would do the job of both controller and
> view
> incorporating the business logic), I have been able to
> write regression
> tests to test methods within an ORM.
> 
>  When I first started using Catalyst, I looked at the tutes
> and so forth
> and it seemed to me that the only form of testing is just
> web based (ie
> using web robots like Test::WWW::Mechanize::Catalyst).
> Whilst that allowed a good test of the interface and
> functionality as a
> whole(akin a blackbox), I missed the days when I had to
> develop
> something without the web front end and have it work for
> both web and
> back end(ie via scripts).
> 
> 
>  Your arguments here have raised a direction for me to put
> my business
> logic into the model component of my app.
> Nevertheless, can I ask for some references to examples of
> business
> logic being written in the model? I can't seem to observe
> any from the
> Catalyst tutes.
> 
> thank you
> 
> K. akimoto
> 

I'd recommend taking a close look at some of the catalyst applications already 
on CPAN. You should be able to glean some info that way.  Current tutorials are 
geared to get people rolling.

check out

MojoMojo
Mango
AngerWhale

There's probably more, I just mentioned the ones whose source code I have 
examined as part of my learning process.

You can just search for those on http://search.cpan.org/  I'd give you the 
links as well but am on my blackberry and it's a hassle

John

> 
> Quoting Simon Wilcox :
> 
> > On 22/4/09 23:03, kakim...@tpg.com.au
> wrote:
> > > IMO the best place for your business logic is the
> controller.
> > 
> > Then you're wrong, at least in the eyes of many
> people.
> > 
> > http://en.wikipedia.org/wiki/Model-view-controller
> > 
> > The Controller is just a layer that converts the input
> to something
> > that 
> > can be passed to the Model and then sends the output
> back to the user
> > 
> > via a View.
> > 
> > You *can* put all your logic in the controller but
> typically you will
> > 
> > end up with two problems:
> > 
> > 1. Your app is tightly bound to a web framework and
> adding some other
> > 
> > sort of user interaction, or extending the application
> code elsewhere
> > 
> > becomes difficult, which is what started this thread
> isn't it ?
> > 
> > 2. It becomes hard to test as you need to have the web
> framework
> > running 
> > to run the tests. You should be able to test all of
> the use cases & 
> > business interactions outside of the web framework. If
> you can't,
> > then 
> > that's a code smell and an indicator that you have too
> much going on
> > in 
> > your Controller classes.
> > 
> > The Catalyst Model classes should really be a very
> thin shim over the
> > 
> > top of your DBIx::Class Schema objects which is where
> all the 'heavy
> > 
> > lifting' of the business process takes place.
> > 
> > Hope that makes sense,
> > 
> > Simon.
> > 
> > 
> > 
> 
> 
> 
> 
> ___
> 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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread kakimoto
>From the Catalyst tutes, I seem to get the impression that pretty much a
lot of the business logic is done in the controller.

I might be wrong but in
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7020/lib/Catalyst/Manual/Tutorial/BasicCRUD.pod#___top
("Add a Method to Process Form Values and Update Database"),
it seems that the task of creating a new entry for books in the database
and establishing the right relationships to the book_authors  db table
is done in the sub form_create_do in the Controller.

i suppose if a batch script were to be used to add in amany books, the
logic there would be trapped in the controller.
 
How do we put that logic into the Model? very interesting and I would
like to hear more since I cant find any examples for putting business
logic in the Model for catalyst on google.

thank you.

k. akimoto



Quoting kakim...@tpg.com.au:

> Hello, Simon,
> 
>   Your points have good weight for thoughts. In fact, coming from
> many
> backgrounds pre-Catalyst and pre-MVC (ie many a times, the
> templating
> system ie Mason would do the job of both controller and view
> incorporating the business logic), I have been able to write
> regression
> tests to test methods within an ORM.
> 
>  When I first started using Catalyst, I looked at the tutes and so
> forth
> and it seemed to me that the only form of testing is just web based
> (ie
> using web robots like Test::WWW::Mechanize::Catalyst).
> Whilst that allowed a good test of the interface and functionality as
> a
> whole(akin a blackbox), I missed the days when I had to develop
> something without the web front end and have it work for both web
> and
> back end(ie via scripts).
> 
> 
>  Your arguments here have raised a direction for me to put my
> business
> logic into the model component of my app.
> Nevertheless, can I ask for some references to examples of business
> logic being written in the model? I can't seem to observe any from
> the
> Catalyst tutes.
> 
> thank you
> 
> K. akimoto
> 
> 
> Quoting Simon Wilcox :
> 
> > On 22/4/09 23:03, kakim...@tpg.com.au wrote:
> > > IMO the best place for your business logic is the controller.
> > 
> > Then you're wrong, at least in the eyes of many people.
> > 
> > http://en.wikipedia.org/wiki/Model-view-controller
> > 
> > The Controller is just a layer that converts the input to
> something
> > that 
> > can be passed to the Model and then sends the output back to the
> user
> > 
> > via a View.
> > 
> > You *can* put all your logic in the controller but typically you
> will
> > 
> > end up with two problems:
> > 
> > 1. Your app is tightly bound to a web framework and adding some
> other
> > 
> > sort of user interaction, or extending the application code
> elsewhere
> > 
> > becomes difficult, which is what started this thread isn't it ?
> > 
> > 2. It becomes hard to test as you need to have the web framework
> > running 
> > to run the tests. You should be able to test all of the use cases &
> 
> > business interactions outside of the web framework. If you can't,
> > then 
> > that's a code smell and an indicator that you have too much going
> on
> > in 
> > your Controller classes.
> > 
> > The Catalyst Model classes should really be a very thin shim over
> the
> > 
> > top of your DBIx::Class Schema objects which is where all the
> 'heavy
> > 
> > lifting' of the business process takes place.
> > 
> > Hope that makes sense,
> > 
> > Simon.
> > 
> > 
> > 
> 
> 
> 
> 
> ___
> 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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread kakimoto
Hello, Simon,

  Your points have good weight for thoughts. In fact, coming from many
backgrounds pre-Catalyst and pre-MVC (ie many a times, the templating
system ie Mason would do the job of both controller and view
incorporating the business logic), I have been able to write regression
tests to test methods within an ORM.

 When I first started using Catalyst, I looked at the tutes and so forth
and it seemed to me that the only form of testing is just web based (ie
using web robots like Test::WWW::Mechanize::Catalyst).
Whilst that allowed a good test of the interface and functionality as a
whole(akin a blackbox), I missed the days when I had to develop
something without the web front end and have it work for both web and
back end(ie via scripts).


 Your arguments here have raised a direction for me to put my business
logic into the model component of my app.
Nevertheless, can I ask for some references to examples of business
logic being written in the model? I can't seem to observe any from the
Catalyst tutes.

thank you

K. akimoto


Quoting Simon Wilcox :

> On 22/4/09 23:03, kakim...@tpg.com.au wrote:
> > IMO the best place for your business logic is the controller.
> 
> Then you're wrong, at least in the eyes of many people.
> 
> http://en.wikipedia.org/wiki/Model-view-controller
> 
> The Controller is just a layer that converts the input to something
> that 
> can be passed to the Model and then sends the output back to the user
> 
> via a View.
> 
> You *can* put all your logic in the controller but typically you will
> 
> end up with two problems:
> 
> 1. Your app is tightly bound to a web framework and adding some other
> 
> sort of user interaction, or extending the application code elsewhere
> 
> becomes difficult, which is what started this thread isn't it ?
> 
> 2. It becomes hard to test as you need to have the web framework
> running 
> to run the tests. You should be able to test all of the use cases & 
> business interactions outside of the web framework. If you can't,
> then 
> that's a code smell and an indicator that you have too much going on
> in 
> your Controller classes.
> 
> The Catalyst Model classes should really be a very thin shim over the
> 
> top of your DBIx::Class Schema objects which is where all the 'heavy
> 
> lifting' of the business process takes place.
> 
> Hope that makes sense,
> 
> Simon.
> 
> 
> 




___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread Kieren Diment


On 23/04/2009, at 12:42 PM, kakim...@tpg.com.au wrote:


Hello, Peter,

I had a look at your ExtJs app via the url given in this email.

Basically, the script just makes direct calls to the Model. Business
logic is found in the script itself and not the Model .

Unfortunately, I still can't see the importance of business logic  
being

placed in the Model than the Controller.



That's fine, sometimes (like me) you've got to learn by experience.   
But keeping things separate - business logic in the model - like that  
really has a major impact on the speed with which you can add features  
to an existing application.  Like many things, the setup time is a  
little longer, but the dividends that you reap from the fat model  
design pay dividends quickly.





___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread kakimoto
Hello, Peter,

 I had a look at your ExtJs app via the url given in this email.

 Basically, the script just makes direct calls to the Model. Business
logic is found in the script itself and not the Model .

 Unfortunately, I still can't see the importance of business logic being
placed in the Model than the Controller.

 Nevertheless, simon Wilcox's opinion in one of the emails in this
thread does bring some good weight for thought.

thank you.

k. akimoto



Quoting Peter Edwards :

> 2009/4/22 
> 
> >   Good morning. I am interested in hearing more about this.
> > IMO the best place for your business logic is the controller.
> > A view is made out of the html (usually templated with a
> templating
> > system such as template toolkit).
> 
> For example, in an application that sells insurance (doing away with
> any
> > javascript which does any business logic):
> >
> 
> Okay, imagine the situation where you wish to send out insurance
> renewal
> reminders.
> You want to run it from a batch program so you can merge it to PDF
> and email
> / print and snailmail all the customers. Obviously, there is no web
> screen
> involved!
> You wish to use the Catalyst DBIC business object Model to get at the
> data.
> How are you going to do that if you need to use the web controller?
> Agreed,
> you *could* run the web transactions and collect the data as, say,
> XML, but
> that would be very inefficient.
> That is why the recommendation is to make the Controller a very thin
> layer
> and to put as much business logic as possible in the Model.
> I wrote a (somewhat outdated) article for the Catalyst advent
> calendar a
> couple of years ago on how to do this:
> http://www.catalystframework.org/calendar/2007/14
> 
> Best wishes,
> Peter
> http://perl.dragonstaff.co.uk
> 




___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread Peter Edwards
 Looking back at the article and the multiple config loader issue I
mentioned I see Robert Krimen wrote a CPAN module to fix
it:
http://search.cpan.org/perldoc?Config::JFDI . Sweet!

Regards, Peter
http://perl.dragonstaff.co.uk
___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread Simon Wilcox

On 22/4/09 23:03, kakim...@tpg.com.au wrote:

IMO the best place for your business logic is the controller.


Then you're wrong, at least in the eyes of many people.

http://en.wikipedia.org/wiki/Model-view-controller

The Controller is just a layer that converts the input to something that 
can be passed to the Model and then sends the output back to the user 
via a View.


You *can* put all your logic in the controller but typically you will 
end up with two problems:


1. Your app is tightly bound to a web framework and adding some other 
sort of user interaction, or extending the application code elsewhere 
becomes difficult, which is what started this thread isn't it ?


2. It becomes hard to test as you need to have the web framework running 
to run the tests. You should be able to test all of the use cases & 
business interactions outside of the web framework. If you can't, then 
that's a code smell and an indicator that you have too much going on in 
your Controller classes.


The Catalyst Model classes should really be a very thin shim over the 
top of your DBIx::Class Schema objects which is where all the 'heavy 
lifting' of the business process takes place.


Hope that makes sense,

Simon.

___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread kakimoto
Hello. Matt,

  Good morning.
 Here's the execution output of the regression test and source code of
the regression test.




 Execution of test - start 
kakim...@dev-machine:~/projects/myApp/t$ prove -v userSubscriptions.t 
userSubscriptions.t .. 
ok 1 - use myApp::Schema::UserSubscriptions;
ok 2 - The object isa myApp::Schema::UserSubscriptions
ok 3 - myApp::Schema::UserSubscriptions->can('subscriptions_id')
ok 4 - myApp::Schema::UserSubscriptions->can('name')
ok 5 - myApp::Schema::UserSubscriptions->can('user_id')
ok 6 - myApp::Schema::UserSubscriptions->can('comments')
ok 7 - myApp::Schema::UserSubscriptions->can('rea_agent_code')
1..7
Can't call method "resolve" on an undefined value at
/usr/local/lib/perl5/site_perl/5.8.9/DBIx/Class/Row.pm line 720.
# Looks like your test exited with 255 just after 7.
Dubious, test returned 255 (wstat 65280, 0xff00)
All 7 subtests passed 

Test Summary Report
---
userSubscriptions.t (Wstat: 65280 Tests: 7 Failed: 0)
  Non-zero exit status: 255
Files=1, Tests=7,  3 wallclock secs ( 0.02 usr  0.01 sys +  0.17 cusr 
0.03 csys =  0.23 CPU)
Result: FAIL


 Execution of test - end 

-- Regression test source-start--
use strict;
use warnings;
use FindBin;
use File::Spec qw();
use lib File::Spec->catdir($FindBin::Bin, qw(.. lib));

use Test::More qw(no_plan);

my $package_name = 'myApp::Schema::UserSubscriptions';

BEGIN {
use_ok( 'myApp::Schema::UserSubscriptions' );
}

# Set up a user's subscriptions.

my %existing_agent = (
qq{username} => qq{test_back_end_agent},
);


my @user_subscriptions = (
{
'name' => 'first subscription',
'subscriptions_id' => '12',
'user_id' => $existing_agent{'username'},
'comments' => 'test user subscription',
'agent_code' => 'LATHAM',
},
);

foreach my $new_subscription ( @user_subscriptions )
{
my $new_user_sub = $package_name->new();
isa_ok ( $new_user_sub, $package_name );

foreach my $attr ( keys %{$new_subscription} )
{
can_ok ($new_user_sub, $attr);
$new_user_sub->$attr($new_subscription);
}
$new_user_sub->insert();
}

-- Regression test source-end--




Thank you.

K.akimoto












Quoting Matt S Trout :

> On Wed, Apr 22, 2009 at 02:41:34PM +1000, kakim...@tpg.com.au wrote:
> > hi guys,
> >   I just looked at my app and found that I need to reuse the
> Schema
> > files found in my 'Schema' directory.
> 
> Your DBIC classes aren't connected to the Catalyst app at all.
> That's
> intentional. Just use DBIx::Class the way DBIx::Class is documented
> in and
> of itself. The DBIx::Class list is also on http://lists.scsys.co.uk/
> if you
> get stuck - if you're getting an error show your code and the
> complete error
> on there.
> 
> -- 
>   Matt S Trout   Need help with your Catalyst or DBIx::Class
> project?
>Technical Director   
> http://www.shadowcat.co.uk/catalyst/
>  Shadowcat Systems Ltd.  Want a managed development or deployment
> platform?
> http://chainsawblues.vox.com/   
> http://www.shadowcat.co.uk/servers/
> 
> ___
> 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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread Peter Edwards
2009/4/22 

>   Good morning. I am interested in hearing more about this.
> IMO the best place for your business logic is the controller.
> A view is made out of the html (usually templated with a templating
> system such as template toolkit).

For example, in an application that sells insurance (doing away with any
> javascript which does any business logic):
>

Okay, imagine the situation where you wish to send out insurance renewal
reminders.
You want to run it from a batch program so you can merge it to PDF and email
/ print and snailmail all the customers. Obviously, there is no web screen
involved!
You wish to use the Catalyst DBIC business object Model to get at the data.
How are you going to do that if you need to use the web controller? Agreed,
you *could* run the web transactions and collect the data as, say, XML, but
that would be very inefficient.
That is why the recommendation is to make the Controller a very thin layer
and to put as much business logic as possible in the Model.
I wrote a (somewhat outdated) article for the Catalyst advent calendar a
couple of years ago on how to do this:
http://www.catalystframework.org/calendar/2007/14

Best wishes,
Peter
http://perl.dragonstaff.co.uk
___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread oliver . g . charles
kakim...@tpg.com.au wrote:
>Good morning. I am interested in hearing more about this.
> IMO the best place for your business logic is the controller.
> A view is made out of the html (usually templated with a templating
> system such as template toolkit).

I believe the main suggestion is not to move the logic into another part
of MVC, it's to move it *out* of MVC completely. A well structured
Catalyst application will have MVC for Catalyst that are all just glue
to your applications backend - which should be totally independant of
Catalyst.

--
Oliver Charles / aCiD2

___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread kakimoto
hi there Simon,


   Good morning. I am interested in hearing more about this.
IMO the best place for your business logic is the controller.
A view is made out of the html (usually templated with a templating
system such as template toolkit).


For example, in an application that sells insurance (doing away with any
javascript which does any business logic):
1) customer will pick out a premium and associated options on a webform
2) the submit button on the webform gets clicked
3) a method in the controller gets called and before data gets saved,
two things typically happen:
- validation of input
- working out of some values. For example, with the chosen premium
and associated options, a method within the controller will need to be
called to work out the exact pricing),
 4) confirmation screen gets generated and with the click of the submit
button on the screen, the 
 saving of data to the database tables will take place.


 Perhaps I am subscribing to another school of thought but I would like
to hear your thoughts in this.


Thank you.

K. akimoto


Quoting Simon Wilcox :

> On 22/4/09 14:52, Matt S Trout wrote:
> > On Wed, Apr 22, 2009 at 02:41:34PM +1000, kakim...@tpg.com.au
> wrote:
> >
> >>   I just looked at my app and found that I need to reuse the
> Schema
> >> files found in my 'Schema' directory.
> > 
> > Your DBIC classes aren't connected to the Catalyst app at all.
> 
> Unless you've fallen into the trap of putting business logic in your
> 
> Controller classes.
> 
> See this as a good opportunity to refactor the logic back into the 
> Schema classes where it belongs (or to a set of business objects if
> that 
> suits your application better).
> 
> Your code will be better for it :-)
> 
> S.
> 
> 
> 
> ___
> 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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread Alexander Hartmaier
I have a MyNamespace::Model::DBIC module containing all ResultSet,
ResultSource and Table classes.
This module is a requirement for my Cat apps and is used in the apps
schema:

package MyNamespace::Web::AppName::Schema::AppName;
use base qw/DBIx::Class::Schema/;

# load subclassed tables
__PACKAGE__->load_classes(qw/
Table3
/);

__PACKAGE__->load_classes({
'MyNamespace::Model::DBIC::Table' => [qw/
Table1
Table2
/]}
);

1;


--
BR Alex


Am Mittwoch, den 22.04.2009, 16:30 +0200 schrieb Simon Wilcox:
> On 22/4/09 14:52, Matt S Trout wrote:
> > On Wed, Apr 22, 2009 at 02:41:34PM +1000, kakim...@tpg.com.au wrote:
> >
> >>   I just looked at my app and found that I need to reuse the Schema
> >> files found in my 'Schema' directory.
> >
> > Your DBIC classes aren't connected to the Catalyst app at all.
>
> Unless you've fallen into the trap of putting business logic in your
> Controller classes.
>
> See this as a good opportunity to refactor the logic back into the
> Schema classes where it belongs (or to a set of business objects if that
> suits your application better).
>
> Your code will be better for it :-)
>
> S.
>
>
>
> ___
> 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/


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be 
privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*

___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread Simon Wilcox

On 22/4/09 14:52, Matt S Trout wrote:

On Wed, Apr 22, 2009 at 02:41:34PM +1000, kakim...@tpg.com.au wrote:


  I just looked at my app and found that I need to reuse the Schema
files found in my 'Schema' directory.


Your DBIC classes aren't connected to the Catalyst app at all.


Unless you've fallen into the trap of putting business logic in your 
Controller classes.


See this as a good opportunity to refactor the logic back into the 
Schema classes where it belongs (or to a set of business objects if that 
suits your application better).


Your code will be better for it :-)

S.



___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-22 Thread Matt S Trout
On Wed, Apr 22, 2009 at 02:41:34PM +1000, kakim...@tpg.com.au wrote:
> hi guys,
>   I just looked at my app and found that I need to reuse the Schema
> files found in my 'Schema' directory.

Your DBIC classes aren't connected to the Catalyst app at all. That's
intentional. Just use DBIx::Class the way DBIx::Class is documented in and
of itself. The DBIx::Class list is also on http://lists.scsys.co.uk/ if you
get stuck - if you're getting an error show your code and the complete error
on there.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical Directorhttp://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/http://www.shadowcat.co.uk/servers/

___
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] how to reuse Catalyst Schema for non-web purposes?

2009-04-21 Thread Devin Austin
Can you show us the exact error that came up?

You should be able to literally copy and paste your existing schema into
your application's lib/ directory and use it thusly.  You'll have to change
the package name unless you put it directly under lib/.

On Tue, Apr 21, 2009 at 10:41 PM,  wrote:

> hi guys,
>  I just looked at my app and found that I need to reuse the Schema
> files found in my 'Schema' directory.
> This is because i need to write some batch scripts which will read the
> data in the databases and output to files in the server.
>
>
> I tried writing a regression test and put in 'use
> MyApp::Schema::SubscriptionPlans;'
>
> The problem was that there was always a 'resolve' error that came up.
>
> Basically, what I am doing is the opposite of "Using existing DBIC
> (etc.) classes with Catalyst" found in
>
> http://search.cpan.org/~hkclark/Catalyst-Manual-5.7020/lib/Catalyst/Manual/Cookbook.pod#___top
> .
>
>
> any ideas?
>
> thank you
>
> K. akimoto
>
>
> ___
> 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/
>



-- 
Devin Austin
http://www.codedright.net
http://www.dreamhost.com/r.cgi?326568/hosting.html - Host with DreamHost!
___
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/


[Catalyst] how to reuse Catalyst Schema for non-web purposes?

2009-04-21 Thread kakimoto
hi guys,
  I just looked at my app and found that I need to reuse the Schema
files found in my 'Schema' directory.
This is because i need to write some batch scripts which will read the
data in the databases and output to files in the server.


I tried writing a regression test and put in 'use
MyApp::Schema::SubscriptionPlans;'

The problem was that there was always a 'resolve' error that came up.

Basically, what I am doing is the opposite of "Using existing DBIC
(etc.) classes with Catalyst" found in
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7020/lib/Catalyst/Manual/Cookbook.pod#___top.


any ideas?

thank you

K. akimoto


___
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/