[Catalyst] perl -d chokes in namespace-clean ...

2009-05-27 Thread Kiffin Gish
For some reason I cannot use the Perl debugger to debug my Catalyst
application, which normally starts up and runs just fine without the
debugger.

Here is an example of the error output generated:

start

kif...@kiffin-laptop:~/opencmt $ perl -d bin/cmt_server.pl 

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(bin/cmt_server.pl:17):   my $debug = 0;

DB1 c
Can't use an undefined value as a symbol reference
at /usr/local/share/perl/5.10.0/namespace/clean.pm line 171.
 at /usr/local/share/perl/5.10.0/namespace/clean.pm line 171

namespace::clean::__ANON__[/usr/local/share/perl/5.10.0/namespace/clean.pm:182]('CMT::Web::Model::User',
 'HASH(0x95c1e10)', 'around', 'has', 'super', 'blessed', 'confess', 'after', 
'augment', ...) called at /usr/local/share/perl/5.10.0/namespace/clean.pm line 
245

namespace::clean::__ANON__[/usr/local/share/perl/5.10.0/namespace/clean.pm:246]()
 called at /usr/local/share/perl/5.10.0/B/Hooks/EndOfScope.pm line 47

B::Hooks::EndOfScope::__ANON__[/usr/local/share/perl/5.10.0/B/Hooks/EndOfScope.pm:47]('HASH(0x9efa100)',
 'ARRAY(0xac5ced8)') called at 
/home/kiffin/opencmt/bin/../lib/CMT/Web/Model/User.pm line 20
eval {...} called
at /home/kiffin/opencmt/bin/../lib/CMT/Web/Model/User.pm line 20
require CMT/Web/Model/User.pm called
at /usr/local/share/perl/5.10.0/Catalyst/Utils.pm line 278
eval {...} called at /usr/local/share/perl/5.10.0/Catalyst/Utils.pm
line 278
Catalyst::Utils::ensure_class_loaded('CMT::Web::Model::User',
'HASH(0xacdbb08)') called at /usr/local/share/perl/5.10.0/Catalyst.pm
line 2153
Catalyst::setup_components('CMT::Web') called
at /usr/local/share/perl/5.10.0/Catalyst.pm line 1071
Catalyst::setup('CMT::Web', '-Log=debug,info,warn,error,fatal') called
at /home/kiffin/opencmt/bin/../lib/CMT/Web.pm line 60
require CMT/Web.pm called at bin/cmt_server.pl line 58
Compilation failed in require
at /usr/local/share/perl/5.10.0/Catalyst/Utils.pm line 278.
 at /usr/local/share/perl/5.10.0/Catalyst/Utils.pm line 282
Catalyst::Utils::ensure_class_loaded('CMT::Web::Model::User',
'HASH(0xacdbb08)') called at /usr/local/share/perl/5.10.0/Catalyst.pm
line 2153
Catalyst::setup_components('CMT::Web') called
at /usr/local/share/perl/5.10.0/Catalyst.pm line 1071
Catalyst::setup('CMT::Web', '-Log=debug,info,warn,error,fatal') called
at /home/kiffin/opencmt/bin/../lib/CMT/Web.pm line 60
require CMT/Web.pm called at bin/cmt_server.pl line 58
Compilation failed in require at bin/cmt_server.pl line 58.
 at bin/cmt_server.pl line 58
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.  

DB1 

end

I've updated to the most recent versions of namespace::clean but that
doesn't help either. Searching through the code didn't reveal anything
to me at all.

Any ideas what's wrong?

-- 
Kiffin Gish kiffin.g...@planet.nl
Gouda, The Netherlands



___
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] Mason + DBI + Catalyst?

2009-05-27 Thread Marcello Romani

Octavian Râsnita ha scritto:

On Tue, May 26, 2009 at 01:37:40AM +0200, Daniel Carrera wrote:

Being able to chain resultsets makes it much much easier than using
straight SQL, and you write less code.  If you have a query you've
constructed called $query, and lets say you now only want active 
records

you can do $query = $query-search({ active = 1 });  In this way you
can filter many things incrementally.

But is that efficient? It looks like you are getting MySQL to return the
entire data set and then making Perl filter it. That can't be efficient.


Here it is a short code example that might appear in a controller:

sub author : Local {
 my ($self, $c) = @_;

#Variables you might get after the user submits a form:

 my $name = $c-req-params-{name};
 my $country = $c-req-params-{country};

#Search the database for all fiction authors:

 my $authors = $c-model(DB::Authors)-search({
   style = 'fiction',
 });

#Until this point DBIC doesn't touch the database.

#Add filters based on what the user searched using the form:

 $authors = $authors-search({name = {-like = %$name%}) if $name;

 $authors = $authors-search({country = $country}) if $country;

#Until this point, DBIC also didn't touch the database.

#Add the $authors object to the stash, to be able to print it in a 
template:

 $c-stash-{authors} = $authors;

#Until here, DBIC didn't touch the database
}

#And the subroutine ended.

And then you can print some things using a Template-Toolkit template 
(authors.tt):


[% IF some_variable = 1 %]
 [% FOREACH author = authors.next %]
   Name: [% author.name %]
   Country: [% author.country %]
   Localized birthday month: [% 
author.birthday.set_locale('fr').month_name %]


   The books of this author:
   [% FOREACH book = author.books %]
 [% book.title %] - [% book.editor %]
   [% END %]
 [% END %]
[% END %]


And at this point, DBIC still doesn't touch the database if the variable 
some_variable is not equal to 1 so the code below the IF line 
shouldn't be executed.


But if the variable is 1, only at this point DBIC executes the necessary 
queries and get the data. And you have seen that due to the relations 
that were created in the DBIC result classes, it would be very simple to 
access not only data about the authors, but about his books or data that 
can be found in other related tables, without needing to define a new 
query.


I wrote this code in Outlook Express and it might have bugs because I 
didn't test it, but I hope it helps to make an idea about what DBIC can do.


Octavian


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



I think this example is very interesting and should end up into the wiki 
somewhere!


I think it can be a good selling point for DBIC, but I've not seen it 
explained so well until now (but I admit I've not looked up the docs in 
a while...)


Thank you.

--
Marcello Romani

___
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] Mason + DBI + Catalyst?

2009-05-27 Thread Octavian Rasnita
From: Marcello Romani mrom...@ottotecnica.com Octavian Râsnita ha 
scritto:

On Tue, May 26, 2009 at 01:37:40AM +0200, Daniel Carrera wrote:

Being able to chain resultsets makes it much much easier than using
straight SQL, and you write less code.  If you have a query you've
constructed called $query, and lets say you now only want active
records
you can do $query = $query-search({ active = 1 });  In this way you
can filter many things incrementally.

But is that efficient? It looks like you are getting MySQL to return 
the
entire data set and then making Perl filter it. That can't be 
efficient.


Here it is a short code example that might appear in a controller:

sub author : Local {

[snip]

I think this example is very interesting and should end up into the wiki 
somewhere!


I think it can be a good selling point for DBIC, but I've not seen it 
explained so well until now (but I admit I've not looked up the docs in a 
while...)


Thank you.

--
Marcello Romani


Ok, I will correct it (because I remember at least an error in it), test it 
and put it in a wiki.


Can anyone recommend a good place for a thing like this?

Octavian


___
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] Where is the DAO equivalent?

2009-05-27 Thread Jarom Smith

Hello Catalysters:

First of all, a thousand apologies if this is a FAQ (and if it is, 
please point me in the right direction).  I have been programming in 
Perl for a while but I freely admit there's a lot I don't know, which is 
why I am here.  I have completed the Catalyst tutorial, purchased the 
book (which I am in the process of reading/completing) and I have 
scrutinized all sorts of web pages trying to figure this out, but have 
so far been unsuccessful.


Here's the problem I'm trying to solve: I have a partially-written web 
application which I am trying to port to Catalyst.  My app has DBI 
methods to access the DB and return results -- things like 
get_vendor_by_name() or get_option_list().  In Java, which is the 
language I use most often these days, I would think of them as DAO 
methods.  Some of these methods are fairly trivial to replace in 
Catalyst; for example, get_vendor_by_name now becomes 
$c-resultset('Vendor')-search({name = $vendor_name})-all;  However, 
some of these methods are more complicated/complex and the proper DBIC 
invocation to produce an equivalent result to my DBI method is more than 
I would want to try to remember or replace each time I need to perform 
that query.  I don't mind re-writing the methods to use DBIC instead of 
DBI (in fact, I kind of look forward to it), but I would like to 
continue to have complex or semi-complex queries abstracted into their 
own methods which I can re-use easily.  The problem is that I don't know 
where to put them or how to access them.


So, my question is: In a Catalyst context, where do I put these kinds of 
helper DB methods and how do I access them? (both from within a 
Catalyst app, as well as from the command-line like in a Cron job or 
whatever...)  Some actual specific examples would be great.  I'm sure 
there is a way, and I'm guessing it involves the model somehow (possibly 
by creating a new model class?) but I haven't been able to figure it out 
yet.  I tried adding methods to the classes created by Catalyst/DBIC in 
the Schema/Result directory, but gradually it dawned on me that methods 
placed here are only dealing with a single entity of that type.  To go 
back to Java-speak, it seems like the stuff in Schema/Result are DTO 
methods; what I'm trying to figure out is how/where to put the DAO methods.


Help!  :-)  Thanks.

jarom smith
tech go-to guy


___
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] Multiple instances of same app with 5.80 under mod_perl

2009-05-27 Thread Stephen Clouse
Hello all,

I am fairly new to Catalyst and am currently evaluating it for use on
several projects, a couple of them being conversions of an existing system
to use Catalyst instead of the hacked-together in-house framework currently
in use.  Those apps have the old per-customer/mass-blog-hosting model going
-- the exact same app deployed with different database/filesystem path
configurations (currently set using mod_perl configuration directives inside
VirtualHost sections in Apache config), previously accomplished with
Catalyst either with FastCGI deployment or ACCEPT_CONTEXT magic that I don't
quite understand yet.

I have seen hints dropped in places such as
http://osdir.com/ml/lang.perl.modules.dbix-class/2006-08/msg00188.html that
Catalyst 5.80 has gained more explicit support for such a deployment model
under mod_perl, but so far I have come up empty on finding references or
examples of how to actually do it.

Some guidance would be greatly appreciated.

-- 
Stephen Clouse stephenclo...@gmail.com
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Where is the DAO equivalent?

2009-05-27 Thread Tobias Kremer

Hi Jarom,

On 27.05.2009, at 18:59, Jarom Smith wrote:
$vendor_name})-all;  However, some of these methods are more  
complicated/complex and the proper DBIC invocation to produce an  
equivalent result to my DBI method is more than I would want to try  
to remember or replace each time I need to perform that query.  I  
don't mind re-writing the methods to


I suppose you want Predefined searches:

http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod#Predefined_searches

If you don't want to manually set your ResultSet classes with - 
resultset_class take a look at load_namespaces() which will  
automatically do this based on two distinct namespaces for  
ResultSources and ResultSets:


http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Schema.pm#load_namespaces

By the way, there's also a dedicated DBIC mailing list for which this  
question is probably better suited :)


HTH,
--Tobias

___
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] Multiple instances of same app with 5.80 under mod_perl

2009-05-27 Thread Stuart Watt
I did a simple tweak to the configuration file management so environment 
variables could be substituted into configuration files. All I added to 
MyApp.pm was:


__PACKAGE__-config('Plugin::ConfigLoader' =
   {file = 'MyApp.yaml',
substitutions = {
   ENV = sub {
   my ($c, $v) = @_;
   if (! defined($ENV{$v})) {
   die(Missing environment variable: $v);
   } else {
   return $ENV{$v};
   }
   }
}
   }
);

Then, I could use YAML settings like:

session:
 storage:   '__ENV(TEMP)__/sessions'

It was pretty easy for us to get web servers to set environment 
variables, so this trick allowed us to have multiple systems with 
different database and file directories set pretty straightforwardly.


This may be one approach you could use, but there are likely better 
ones. Especially since I'm still stuck at 5.70 waiting for a good 
opportunity to upgrade without anyone (even my colleagues) noticing. 
This is a 5.70 solution, but should be OK in 5.80, I would guess.


All the best
Stuart


Stephen Clouse wrote:

Hello all,

I am fairly new to Catalyst and am currently evaluating it for use on 
several projects, a couple of them being conversions of an existing 
system to use Catalyst instead of the hacked-together in-house 
framework currently in use.  Those apps have the old 
per-customer/mass-blog-hosting model going -- the exact same app 
deployed with different database/filesystem path configurations 
(currently set using mod_perl configuration directives inside 
VirtualHost sections in Apache config), previously accomplished with 
Catalyst either with FastCGI deployment or ACCEPT_CONTEXT magic that I 
don't quite understand yet.


I have seen hints dropped in places such as 
http://osdir.com/ml/lang.perl.modules.dbix-class/2006-08/msg00188.html 
that Catalyst 5.80 has gained more explicit support for such a 
deployment model under mod_perl, but so far I have come up empty on 
finding references or examples of how to actually do it.


Some guidance would be greatly appreciated.

--
Stephen Clouse stephenclo...@gmail.com mailto:stephenclo...@gmail.com

--
This message was scanned by ESVA and is believed to be clean.
Click here to report this message as spam. 
http://antispam.infobal.com/cgi-bin/learn-msg.cgi?id=64AE2280C1.6F32B



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


--
Stuart Watt
ARM Product Developer
Information Balance
___
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] ACL Error: deny_access_unless

2009-05-27 Thread Gordon Stewart

Tomas

I have created a test application to use

Catalyst::Authentication::Store::Minimal

But I am still having the same issue. 

I am using perl 5.8.8 and ubuntu 8.04 if that has a bearing on why roles are
broken.

How easy is it to downgrade catalyst 5.7012, which I know will work?

Gordon 



___
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] Where is the DAO equivalent?

2009-05-27 Thread Johannes Plunien

On 27.05.2009, at 18:59, Jarom Smith wrote:

So, my question is: In a Catalyst context, where do I put these  
kinds of helper DB methods and how do I access them? (both from  
within a Catalyst app, as well as from the command-line like in a  
Cron job or whatever...)  Some actual specific examples would be  
great.  I'm sure there is a way, and I'm guessing it involves the  
model somehow (possibly by creating a new model class?) but I  
haven't been able to figure it out yet.  I tried adding methods to  
the classes created by Catalyst/DBIC in the Schema/Result directory,  
but gradually it dawned on me that methods placed here are only  
dealing with a single entity of that type.  To go back to Java- 
speak, it seems like the stuff in Schema/Result are DTO methods;  
what I'm trying to figure out is how/where to put the DAO methods.


http://www.pqpq.de/mt/2009/05/catalyst-dbic-dao.html

Cheers,
plu

--
Johannes Plunien | mailto:p...@pqpq.de | http://www.pqpq.de/contact/



smime.p7s
Description: S/MIME cryptographic signature
___
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] Why it is better to use an ORM like DBIx::Class

2009-05-27 Thread Octavian Râşniţă

Hi,

I corrected (re-written) that message in which I tried to show why it is 
better to use DBIC, because it doesn't affect the efficiency. Here it is. I 
hope it could be helpful. Please tell me if you think it needs improvements:


Why it is better to use an ORM like DBIx::Class

There are many advantages of using an ORM, but I won't remember all of them 
here.
I just want to show how clean it could be a code that uses DBIx::Class 
instead of manually adding parts for creating SQL queries.


And I would also like to show that this doesn't affect the efficiency.

DBIx::Class works the same in all apps, but I will show an example using the 
Catalyst framework.


# 1. Create the application named OurApp:

catalyst.pl OurApp

# 2. Go to the application's home dir:

cd OurApp

#3. Create the tables in the ourapp database using the definitions shown 
below:


create table continent(
id int unsigned not null auto_increment primary key,
name varchar(20),
hemisphere varchar(10)
) engine=InnoDB;

create table country(
id int unsigned not null auto_increment primary key,
id_continent int unsigned not null,
name varchar(30),
national_day date,
foreign key(id_continent) references continent(id)
) engine=InnoDB;

create table city(
id int unsigned not null auto_increment primary key,
id_country int unsigned not null,
name varchar(30),
population int unsigned,
foreign key(id_country) references country(id)
) engine=InnoDB;

# 4. Generate the DBIx::Class result classes:

perl script/ourapp_create.pl model DB DBIC::Schema OurApp::Schema 
create=static dbi:mysql:database=ourapp root


# 5. Create a Template-Toolkit view, named TT

perl script/ourapp_create.pl view TT TT

# 6. Create a controller named Continent, and change its content:

perl script/ourapp_create.pl controller Continent

package OurApp::Controller::Continent;

use strict;
use warnings;
use parent 'Catalyst::Controller';

sub index :Path :Args(0) {
 my ( $self, $c ) = @_;

 #Get a variable from a submitted form:
 my $continent_name = $c-req-params-{continent_name};

 #Select the continents from the Northern hemisphere:
 my $continents = $c-model(DB::Continent)-search({
   hemisphere = 'North',
 });

 #Until this point, no query is sent to the database.

 #If the user asked for a certain continent in this hemisphere, add it as a 
filter:
 $continents = $continents-search({name = $continent_name}) if 
$continent_name;


 #Until this point, no query is sent to the DB yet and more such filters 
may be applied.


 #Add the $continents object to the stash, for printing data from it in the 
templates

 $c-stash-{continents} = $continents;

 #This last line of the subroutine also didn't send anything to the 
database.

}

#And here the action subroutine ended, without sending anything to the 
database.


#The default TT template root/continent/index.tt is processed by the TT view 
at this point.


1;

# 7. Create the content of the template file (root/continent/index.tt):

htmlheadtitleContinents/title/headbody

form
 Continent: input type=text name=continent_name
 input type=submitbrbr
/form

h1Print the information for the selected continents:/h1

[% FOREACH continent IN continents.all %]
 Continent name: [% continent.name %]br
 Continent hemisphere: [% continent.hemisphere %]brbr

 h2Print the information for the countries from [% continent.name 
%]:/h2


 [% FOREACH country IN continent.countries %]
   Country name: [% country.name %]br
   Country national day localized: [% 
country.national_day.set_locale('fr').strftime('%e %b %Y') %]brbr


   h3Print here information for the cities from [% country.name %]:/h3

   [% FOREACH city IN country.cities %]
 City name: [% city.name %]br
 city population: [% city.population %]brbr
   [% END %]
 [% END %]
[% END %]

/body/html

# 8. Start the application using the development server:
perl script/ourapp_server.pl -p 80

# 9. And access the controller at the URL:
http://localhost/continent

By default, it will show the whole list of continents from the northern 
emisphere that were inserted in the database, their countries and their 
cities.


If you will filter the results and add the name of a certain continent in 
the form field, it will display only that continent, its countries and their 
cities.


Before starting the development server, set the environment variable 
DBIC_TRACE to 1, for printing the SQL queries that are generated on each 
request.


If you will type the name of the continent NonExistent in the text field 
of the form, the single SQL query that will be generated would be:


SELECT me.id, me.name, me.hemisphere FROM continent me WHERE ( ( name = ? 
AND hemisphere = ? ) ):

'NonExistent', 'North'

It won't find this continent, and it won't send the other SQL queries to the 
DB for getting information about countries and cities.


If the continent Asia is inserted in the DB, but no countries are inserted 
for it, the generated SQL queries will be:


SELECT me.id, me.name, me.hemisphere FROM 

[Catalyst] Connect Catalyst app to MS SQL Server 2005

2009-05-27 Thread Ascii King
I'm trying to connect my Catalyst app to a MS SQL server 2005. I have 
DBIx::Class loaded and I went through the documentation, but I can't 
seem to get the right connection string. Would someone be able to point 
out my mistake and suggest the proper connection string?


Here is the info from my .conf file.

Model::DB
   schema_class WebTest::Schema
   connect_info
  dsn dbi:odbc:WebTestODBC
  userWebGuy
  password   webtest
  AutoCommit   1
   /connect_info
M/Model::DB

I have created an ODBC connection called WebTestODBC on the machine 
hosting the MSSQL server.

I have also tried the above with a change to the dsn:
dsn   dbi:MSSQL:WebTestODBC

But I always get the same error:

DBIx::Class::ResultSet::first(): DBI Connection failed: Can't connect to 
data source 'HASH(0x43477e8)' because I can't work out what driver to 
use (it doesn't seem to contain a 'dbi:driver:' prefix and the 
DBI_DRIVER env var is not set) at 
C:/Perl/site/lib/DBIx/Class/Storage/DBI.pm line 839


This suggests that it is not reading the connect_info properly and 
instead is looking at the entire thing as a hash. I don't know how to 
get around this. I don't even know if it is the right assumption.


Also, in my \Model\DB.pm I have the following code I took from the 
Catalyst tutorial and modified. I'm not sure if I should just remove it 
or what.


__PACKAGE__-config(
   schema_class = 'WebTest::Schema',
   connect_info = [
 'dbi:odbc:WebTestODBC',
   ],
);

___
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] Connect Catalyst app to MS SQL Server 2005

2009-05-27 Thread Johannes Plunien

On 27.05.2009, at 21:44, Ascii King wrote:


Model::DB
  schema_class WebTest::Schema
  connect_info
 dsn dbi:odbc:WebTestODBC
 userWebGuy
 password   webtest
 AutoCommit   1
  /connect_info
M/Model::DB


Model::DB
  schema_class WebTest::Schema
  connect_info dbi:odbc:WebTestODBC
  connect_info WebGuy
  connect_info webtest
  connect_info
AutoCommit   1
  /connect_info
/Model::DB

... should do the trick. See also: 
http://search.cpan.org/dist/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm#CONFIG_PARAMETERS

Cheers,
plu

--
Johannes Plunien | mailto:p...@pqpq.de | http://www.pqpq.de/contact/



smime.p7s
Description: S/MIME cryptographic signature
___
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] My experience porting to CataMoose

2009-05-27 Thread Tomas Doran


On 19 May 2009, at 02:38, Sebastian Willert wrote:


. Here is my first stab at creating
such a thing. Please bear in mind that English is not my native  
language

and this is my first dab into Moose so this document is probably rife
with factual and grammatical errors.


That was brilliant, apologies it's not gone anywhere for a couple of  
weeks. hkclark++ applied it and yelled at me as part of this round of  
tutorial updates.


I've corrected a few small points, made a couple of changes for best  
practices, and expanded a little on putting controller actions in  
roles (as you can now do this!), and munged the previous docs  
in ::ExtendingCatalyst to be a pointer to the file you added..


Thank you very much for the patch, it'll all be a lot better  
explained in the new release (which will be soon).


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/


Re: [Catalyst] My experience porting to CataMoose

2009-05-27 Thread hkclark
Agreed.  Sebastian++ for taking the initiative to do that!

Kennedy

On Wed, May 27, 2009 at 6:42 PM, Tomas Doran bobtf...@bobtfish.net wrote:

 On 19 May 2009, at 02:38, Sebastian Willert wrote:

 . Here is my first stab at creating
 such a thing. Please bear in mind that English is not my native language
 and this is my first dab into Moose so this document is probably rife
 with factual and grammatical errors.

 That was brilliant, apologies it's not gone anywhere for a couple of weeks.
 hkclark++ applied it and yelled at me as part of this round of tutorial
 updates.

 I've corrected a few small points, made a couple of changes for best
 practices, and expanded a little on putting controller actions in roles (as
 you can now do this!), and munged the previous docs in ::ExtendingCatalyst
 to be a pointer to the file you added..

 Thank you very much for the patch, it'll all be a lot better explained in
 the new release (which will be soon).

 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/


Re: [Catalyst] Multiple instances of same app with 5.80 under mod_perl

2009-05-27 Thread Matthias Dietrich

Hi Stuart,

do you use Log::Log4perl in your Catalyst apps?  Months ago I wrote a  
message to the list about problems with Log::Log4perl and multiple  
instances of Catalyst within one Apache.  Nobody answered and because  
it's currently not very important to me (not in production environment  
yet) I didn't follow-up.


The problem was to separate each VirtualHosts Catalyst into different  
log files which didn't worked.  Catalyst always logged into the file  
from the latest VirtualHost.  Maybe I have some short time tomorrow to  
create a local test case (I use the included server now so I have to  
switch to Apache again).


Regards,
 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] Where is the DAO equivalent?

2009-05-27 Thread Jarom Smith

Thank you Tobias!  That is what I was looking for.

I note that Catalyst has automatically created a Schema.pm with 
__PACKAGE__-load_namespaces(), so all I needed to do was create 
ResultSet classes corresponding to my Result classes, and everything 
else just worked.


jarom smith
tech go-to guy


Tobias Kremer wrote:

Hi Jarom,

On 27.05.2009, at 18:59, Jarom Smith wrote:
$vendor_name})-all;  However, some of these methods are more 
complicated/complex and the proper DBIC invocation to produce an 
equivalent result to my DBI method is more than I would want to try to 
remember or replace each time I need to perform that query.  I don't 
mind re-writing the methods to


I suppose you want Predefined searches:

http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Cookbook.pod#Predefined_searches 



If you don't want to manually set your ResultSet classes with 
-resultset_class take a look at load_namespaces() which will 
automatically do this based on two distinct namespaces for ResultSources 
and ResultSets:


http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Schema.pm#load_namespaces 



By the way, there's also a dedicated DBIC mailing list for which this 
question is probably better suited :)


HTH,
--Tobias

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


[Catalyst] auto-generate ResultSet classes?

2009-05-27 Thread Jarom Smith
Sorry, one more question (and this one does have to do with Catalyst 
more than DBIC, I think...)


Is there any magical invocation for the create script which will make a 
bunch of stub ResultSet classes for me, similar to how the Result 
classes are auto-generated when I do


script/myapp_create.pl model MyAppDB DBIC::Schema MyApp::Schema 
create=static components=TimeStamp,EncodedColumn dbi:mysql:myapp 
'dbuser' 's3kr1t' '{ AutoCommit = 1 }'


?  (and if so, what is it?)

thanks,

jarom smith
tech go-to guy

___
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] auto-generate ResultSet classes?

2009-05-27 Thread J. Shirley
On Wed, May 27, 2009 at 5:31 PM, Jarom Smith ja...@jaromsmith.net wrote:

 Sorry, one more question (and this one does have to do with Catalyst more
 than DBIC, I think...)

 Is there any magical invocation for the create script which will make a
 bunch of stub ResultSet classes for me, similar to how the Result classes
 are auto-generated when I do

 script/myapp_create.pl model MyAppDB DBIC::Schema MyApp::Schema
 create=static components=TimeStamp,EncodedColumn dbi:mysql:myapp 'dbuser'
 's3kr1t' '{ AutoCommit = 1 }'

 ?  (and if so, what is it?)

 thanks,

 jarom smith
 tech go-to guy


What do you want/expect the resultset classes to contain?  Or do you want a
resultset class created for every result source?

I've found that using a custom resultset default via load_namespaces suits
most of my needs, but I'd be interested to hear other scenarios.

Thanks,
-J
___
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] auto-generate ResultSet classes?

2009-05-27 Thread Jarom Smith
Yes, I was thinking a very simple stub ResultSet class for every Result 
source.  Something like:


package MyApp::Schema::ResultSet::MyTable;

use strict;
use warnings;

use base 'DBIx::Class::ResultSet';

# example
#sub get_by_id {
#   my $self = shift;
#   my $id = shift;
#
#   return $self-find($id)-all;
#}

1;

In practice, it may be overkill to create a ResultSet class for each 
Result class, and admittedly it's not too difficult to create these 
ResultSet classes by just doing one and copying as needed.  I'm probably 
being lazier than I should be...



jarom smith
tech go-to guy


J. Shirley wrote:
On Wed, May 27, 2009 at 5:31 PM, Jarom Smith ja...@jaromsmith.net 
mailto:ja...@jaromsmith.net wrote:


Sorry, one more question (and this one does have to do with Catalyst
more than DBIC, I think...)

Is there any magical invocation for the create script which will
make a bunch of stub ResultSet classes for me, similar to how the
Result classes are auto-generated when I do

script/myapp_create.pl model MyAppDB DBIC::Schema MyApp::Schema
create=static components=TimeStamp,EncodedColumn dbi:mysql:myapp
'dbuser' 's3kr1t' '{ AutoCommit = 1 }'

?  (and if so, what is it?)

thanks,

jarom smith
tech go-to guy


What do you want/expect the resultset classes to contain?  Or do you 
want a resultset class created for every result source?


I've found that using a custom resultset default via load_namespaces 
suits most of my needs, but I'd be interested to hear other scenarios.


Thanks,
-J




___
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] auto-generate ResultSet classes?

2009-05-27 Thread J. Shirley
On Wed, May 27, 2009 at 6:52 PM, Jarom Smith ja...@jaromsmith.net wrote:

 Yes, I was thinking a very simple stub ResultSet class for every Result
 source.  Something like:

 package MyApp::Schema::ResultSet::MyTable;

 use strict;
 use warnings;

 use base 'DBIx::Class::ResultSet';

 # example
 #sub get_by_id {
 #   my $self = shift;
 #   my $id = shift;
 #
 #   return $self-find($id)-all;
 #}

 1;

 In practice, it may be overkill to create a ResultSet class for each Result
 class, and admittedly it's not too difficult to create these ResultSet
 classes by just doing one and copying as needed.  I'm probably being lazier
 than I should be...


 jarom smith
 tech go-to guy


 J. Shirley wrote:

 On Wed, May 27, 2009 at 5:31 PM, Jarom Smith ja...@jaromsmith.netmailto:
 ja...@jaromsmith.net wrote:

Sorry, one more question (and this one does have to do with Catalyst
more than DBIC, I think...)

Is there any magical invocation for the create script which will
make a bunch of stub ResultSet classes for me, similar to how the
Result classes are auto-generated when I do

script/myapp_create.pl model MyAppDB DBIC::Schema MyApp::Schema
create=static components=TimeStamp,EncodedColumn dbi:mysql:myapp
'dbuser' 's3kr1t' '{ AutoCommit = 1 }'

?  (and if so, what is it?)

thanks,

jarom smith
tech go-to guy


 What do you want/expect the resultset classes to contain?  Or do you want
 a resultset class created for every result source?

 I've found that using a custom resultset default via load_namespaces suits
 most of my needs, but I'd be interested to hear other scenarios.

 Thanks,
 -J



Catalyst::Helper::Model::DBIC::Schema doesn't do that, but you could submit
a patch :)

-J
___
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] Looking for a working example using DBIC and Authentication

2009-05-27 Thread Simon Baird
I've been struggling to get off the ground with
Catalyst/DBIC/Authentication. I'm new to Catalyst so I want to do
everything as standard as possible, (ie please don't tell me there is
more than one way to do it or I might have to cry.. :) and I would
like to use DBIC.

I won't go into the details[1] but I seem to be in a pattern where I
find good some good examples, get things close to working and then
discover at a certain point that I'm using deprecated stuff that
should only be used for legacy apps. And that stuff I can borrow from
example A just doesn't work with stuff from example B. So it's been
quite a frustrating exercise...

Anyway, thanks for listening and I was just wondering if someone has a
gzipped downloadable MyApp with DBIC and auth setup or maybe a blog
post somewhere that describes how to set things up the right way (and
that's new enough so there's no deprecated classes used...)

[1] Well perhaps some details in brief note form...
- The Authentication section of the Tutorial in CPAN uses some
deprecated stuff (I find out eventually)
- I got Auth working with DBIC as per the docs (with users, roles,
user_roles tables) but without a realm. So I can use (the deprecated)
$c-login but $c-authenticate doesn't work...
- After decided I would give up and just keep using the $c-login I
tried adding another table to my DBIC Schema. This caused Auth to stop
working...

Regards,
Simon.
-- 
simon.ba...@gmail.com

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/