Re: [Catalyst] FormFu edit form problem

2009-05-26 Thread Toby Corkindale

Toby Corkindale wrote:

Moritz Onken wrote:


Am 20.05.2009 um 00:37 schrieb Greg Coates:


I'm using HTML::FormFu::Model::DBIC version 0.04002, and this problem is
still there.  Do we know when a patch might be available?

Greg



Hi Greg,

which problem are you referring to? Can you provide some code?

moritz



I'm not sure, but they might be referring to this post:
http://www.mail-archive.com/html-for...@lists.scsys.co.uk/msg01528.html


(For the record, I'm hitting the same error message about The primary 
key and the foreign key may not be the same column with version 0.04002 
of HFM-DBIC)


...
And after applying the patch linked above, the problem went away. Presto!

I'm looking forward to that being included in a 0.04004 release soon..

-T

___
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] FormFu edit form problem

2009-05-26 Thread Toby Corkindale

Moritz Onken wrote:


Am 20.05.2009 um 00:37 schrieb Greg Coates:


I'm using HTML::FormFu::Model::DBIC version 0.04002, and this problem is
still there.  Do we know when a patch might be available?

Greg



Hi Greg,

which problem are you referring to? Can you provide some code?

moritz



I'm not sure, but they might be referring to this post:
http://www.mail-archive.com/html-for...@lists.scsys.co.uk/msg01528.html


(For the record, I'm hitting the same error message about The primary 
key and the foreign key may not be the same column with version 0.04002 
of HFM-DBIC)


Toby

___
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] FormFu edit form problem

2009-05-26 Thread Carl Franks
2009/5/26 Toby Corkindale toby.corkind...@strategicdata.com.au:
 And after applying the patch linked above, the problem went away. Presto!

 I'm looking forward to that being included in a 0.04004 release soon..

Thanks - that patch had gotten past my radar!

It's now applied, and new releases of HTML-FormFu and
HTML-FormFu-Model-DBIC have been uploaded to pause, and should be
available on cpan within a couple of hours.

Carl

___
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-26 Thread Tomas Doran

Gordon Stewart wrote:

Does anyone know where in the catalyst code it contacts the database to
check if a user has the rights in question?


It should be calling $c-user-roles, and this gets the list of roles 
for the user in question.


How this lookup is performed will vary depending on which authentication 
store you're using, how it's configured etc.


  I have looked into the catalyst

code (Catalyst/Plugin/Authorization/ACL/Engine.pm )and found out that the
function in question is returning Denied without contacting the database.
I know it is not contacting the database because I have turn on the Mysql
logs and see no sql query.

I am running the most up to date version of the catalyst code (5.8004). 

Has any one got roles and ACL working in Catalyst 5.8004  


There have been a few people having problems with this.

I know that I fixed ACL to work with Catalyst 5.80 specifically, in that 
I had to do some work to make it pass all of it's tests. However, 
obviously, as people are having issues - the tests may not be 
comprehensive enough..


So I guess we need to produce a minimal TestApp demonstrating the issue, 
and then we can either fix ACL, or fix core Catalyst as appropriate to 
sort the issue out.


This minimal test app would use the minimal authentication store (so no 
DB needed), and just demonstrate the issue (i.e. t/01app.t fails).


If you can produce such a TestApp, then I'll be more than happy to take 
a look, or beat someone else into doing so ;)


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

2009-05-26 Thread Matt S Trout
On Tue, May 26, 2009 at 01:14:18AM +0200, Daniel Carrera wrote:
 I hesitate to make predictions like this. I don't know DBIC, and you 
 don't know my queries. I know that I find SQL no harder than Perl, and 
 that I appreciate being able to experiment with queries with phpMyAdmin. 
 So I can't help but wonder if it really makes sense to use a Perl module 
 to write the SQL for me rather than write the SQL directly. How would 
 you tell DBIC to use a sub query or to use a temporary table? Is it hard?

If you can't make DBIC produce the exact SQL you would have written by hand,
that's a missing feature in DBIC - at least so far as the development team
is concerned.

I often prototype queries by fiddling at the SQL level and then rewrite them
into DBIC syntax afterwards - though equally as often I fire up a Devel::REPL
re.pl and play around with resultsets with DBIC_TRACE on so it shows me the
queries as it runs them.

DBIx::Class -does- have a learning curve, but that's because it's an ORM
written by people who actually like SQL and the relational model - so once
you get to grips with it you should be able to write DBIC code and be able
to see the SQL that's going to eventually be executed in your head, except
be typing a lot less - and be able to use resultset chaining to put complex
queries together in a piecemeal, reusable fashion.

-- 
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
 Technical Director  and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.ukhttp://shadowcat.co.uk/blog/matt-s-trout/

___
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-26 Thread Matt S Trout
On Tue, May 26, 2009 at 01:37:40AM +0200, Daniel Carrera wrote:
 Do you write your queries using straight SQL? For my application, MySQL 
 is a bottleneck. So it is important to me that I have control over the 
 queries to try to make them efficient. I don't have any query that spans 
 8 tables though. So if you are happy with DBIC, then it should be good 
 enough for me too. I'll take a second look at DBIC.

Have a look at -

http://www.shadowcat.co.uk/catalyst/-talks/yapc-na-2008/dbix-masterclass.xul

http://www.shadowcat.co.uk/archive/conference-video/yapc-eu-2008/dbic-masterclass/

http://xrl.us/oubg6 

Those should give you an idea of the level of complexity that can be built
up elegantly.
 
 Btw, why is it called DBIC if CPAN says DBIx::Class?

DBIx is the namespace for DBI extensions.

So we use DBIC as an abbreviation.

 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.

-search just constructs another resultset.

DBIC doesn't hit the database until you make it via -count or -next/-all
(or something that calls one of those).

That's rather the key advantage of DBIC - a resultset is basically a sort of
lazy virtual view onto your database that turns itself into an SQL query as
and when (and only when) required to do so by something you want.

-- 
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
 Technical Director  and a commit bit: http://shadowcat.co.uk/catalyst/
 Shadowcat Systems Limited
  mst (@) shadowcat.co.ukhttp://shadowcat.co.uk/blog/matt-s-trout/

___
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-26 Thread Octavian Râsnita

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/


RE: [Catalyst] ACL Error: deny_access_unless

2009-05-26 Thread Gordon Stewart

Tomas

I have am not using an authentication store, I am just using:

Authentication
Authorization::Roles
Authorization::ACL

Session
Session::Store::FastMmap
Session::State::Cookie


If I include the store:

Authentication::Store::DBIC

Then I just get the following:

You must provide a user_class at /usr/local/share/perl/5.8.8/Catalyst.pm
line 1140

But I am passing the user_class though my yml file:

authorization:
dbic:
user_class: DnsEmail::Rights
#role_class: DnsEmail::Rights
role_field: description
role_rel: accesses
user_role_user_field: user_id

Regards

Gordon

-Original Message-
From: Tomas Doran [mailto:bobtf...@bobtfish.net] 
Sent: 26 May 2009 12:25
To: The elegant MVC web framework
Subject: Re: [Catalyst] ACL Error: deny_access_unless

Gordon Stewart wrote:
 Does anyone know where in the catalyst code it contacts the database to
 check if a user has the rights in question?

It should be calling $c-user-roles, and this gets the list of roles 
for the user in question.

How this lookup is performed will vary depending on which authentication 
store you're using, how it's configured etc.

   I have looked into the catalyst
 code (Catalyst/Plugin/Authorization/ACL/Engine.pm )and found out that the
 function in question is returning Denied without contacting the
database.
 I know it is not contacting the database because I have turn on the Mysql
 logs and see no sql query.
 
 I am running the most up to date version of the catalyst code (5.8004). 
 
 Has any one got roles and ACL working in Catalyst 5.8004  

There have been a few people having problems with this.

I know that I fixed ACL to work with Catalyst 5.80 specifically, in that 
I had to do some work to make it pass all of it's tests. However, 
obviously, as people are having issues - the tests may not be 
comprehensive enough..

So I guess we need to produce a minimal TestApp demonstrating the issue, 
and then we can either fix ACL, or fix core Catalyst as appropriate to 
sort the issue out.

This minimal test app would use the minimal authentication store (so no 
DB needed), and just demonstrate the issue (i.e. t/01app.t fails).

If you can produce such a TestApp, then I'll be more than happy to take 
a look, or beat someone else into doing so ;)

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] ACL Error: deny_access_unless

2009-05-26 Thread Tomas Doran


On 26 May 2009, at 21:07, Gordon Stewart wrote:



Tomas

I have am not using an authentication store, I am just using:

Authentication
Authorization::Roles
Authorization::ACL

Session
Session::Store::FastMmap
Session::State::Cookie


No, you are using an authentication store.

Catalyst::Plugin::Authentication loads and instantiates one store and  
one credential instance perl realm in your authentication configuration.


Note that this is wy more flexible than the session configuration  
(where you can only have 1 session store and 1 session state per app)  
- session will move in this direction also at some point to be more  
flexible.


Anyway, back to the point - rather than using the DBIC authentication  
store (or DBIC at all), your test application would be using  
Catalyst::Authentication::Store::Minimal (see the POD for a config  
example).


Hope that makes it clearer what I'm rambling about?

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/