Re: [Catalyst] Very Simple Question

2008-11-18 Thread Jonathan Rockway
* On Mon, Nov 17 2008, Amiri Barksdale wrote:
 I am a new user of Catalyst, and from reading the documents and
 reading blogs posts I have been able to set up my schema, my authz/
 authen, sessions, and my Mason view. I have a very simple question,
 though.

 This in a controller

 $c-stash-{elements} = [$c-model('DB::Elements')-all];

 Requires this in a view:

 % $element-{_column_data}-{title} %

To expand on the other reply to this message, I'd like to point out that
you should never access the hash values backing an object directly.
Although sometimes you might get the right data this way, it's not
guaranteed -- you need to call the documented accessor methods.  (For
example, sometimes the hash data is populated lazily; meaning that the
first time you call $object-foo, foo is calculated, stashed in
$object-{foo}, and returned.  Until you call the method, though, the
hash value doesn't exist.)

Anyway, I assume you arrived at $element-{_column_data}-{title} by
looking at the output of Data::Dumper.  That's a fine strategy, but you
should also add Class::Inspector to your debugging arsenal.  You can
find what methods you can call on an object with code like:

  use Class::Inspector;
  say join \n, @{Class::Inspector-methods(ref $object, 'public')};

I also recommend that you try out Devel::REPL if you haven't already.
At the very least, it will save you from typing the 'say join \n,
@{...}' part.

Regards,
Jonathan Rockway

--
print just = another = perl = hacker = if $,=$

___
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 could I pass a variable from Model to Controller?

2008-11-18 Thread J. Shirley
On Tue, Nov 18, 2008 at 6:13 AM, J. Shirley [EMAIL PROTECTED] wrote:
 On Mon, Nov 17, 2008 at 11:49 PM,  [EMAIL PROTECTED] wrote:
 HI all:
 I am a Catalyst beginner and run into this problem
 since I have a model like this

 package MyApp::Model::Trial;
 use strict;
 use warnings;

 sub new{
 my $pack = shift;
 my $self = bless {
 foo = 'default value foo',
 },$pack;
 return $self;
 }

 sub get{
 return shift-{'foo'};
 }
 1

 how could I pass this foo to the controller?
 I tried some code like this
 my $a = $c-model('Trial::new');
 $c-stash-{word} = $a-get;

 or
 my $a = $c-model('Trial');
 $c-stash-{word} = $a-get;

 both of them run into some exceptions


 thx for helping


 First off, models are instantiated by Catalyst so if you create your
 own 'new' method you are not going to be doing the right thing.

 Second, if all you are trying to do is having default configured
 values it is much better to use accessors and let Catalyst handle the
 configuration, like so:

 package MyApp::Model::Trial;

 use warnings;
 use strict;

 use base 'Catalyst::Model'; # You must inherit from this
 use Class::Accessor::Fast; # Use this to generate the accessor methods

 # Make an accessor for 'foo'
 __PACKAGE__-mk_accessors('foo');

 __PACKAGE__-config(
'foo' = 'default foo value'
 );

 1;

 __END__

 That really is all there is to it.  When Catalyst loads, it will load
 everything in the Controller, Model and View namespaces based on the
 base classes (Catalyst::Model, which in turn inherits from a common
 base class called Catalyst::Component)

 Now to acess 'foo' you can just use the simple accessor (and setter):

 $c-model('Trial')-foo;
 # or
 $c-model('Trial')-foo(new value);




Actually, I made a slight mistake because I was going down the Moose
route first and then changed it.  You also need to inherit from
Class::Accessor::Fast...

So, use: use base qw/Catalyst::Model Class::Accessor::Fast/;

-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] CatalystX::CRUD::YUI 0.008

2008-11-18 Thread Peter Karman
Uploaded last night to CPAN.

New in this version:

0.008   17 Nov 2008
* tweek CSS for a.box to fix padding in relation to form.inline,
  button.box
* fix crud.js bug to allow for sort column to include table
  prefix (e.g., t2.name)
* total refactor of UI to include:
* left menu instead of tabbed relationships view
* stricter dom structure
* yui_header.tt
* split up some .tt into smaller chunks
* RelOpts hash instead of separate *_relationships vars in
  .tt
* use LiveGrid instead of YUI DataTable

***NOTE*** all the YUI DataTable support is now dropped in favor of
ExtJS LiveGrid


-- 
Peter Karman  .  [EMAIL PROTECTED]  .  http://peknet.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] Auth::PAM??

2008-11-18 Thread Jose Luis Martinez

Michael Higgins escribió:

What we _do_ allow is SASL auth, as for SMTP service. So... there is an 
Authen::SASL, but no Catalyst hook? I'll try to get this working with Catalyst 
Auth stuff today, but I don't have great hopes of success.


Does Authen::Simple::SMTP do the trick?

Jose Luis Martinez
[EMAIL PROTECTED]   

___
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] Auth::PAM??

2008-11-18 Thread Michael Higgins
On Tue, 18 Nov 2008 20:38:41 +0100
Jose Luis Martinez [EMAIL PROTECTED] wrote:

 Michael Higgins escribió:
  What we _do_ allow is SASL auth, as for SMTP service. So... there
  is an Authen::SASL, but no Catalyst hook? I'll try to get this
  working with Catalyst Auth stuff today, but I don't have great
  hopes of success.
 
 Does Authen::Simple::SMTP do the trick?
 

Ahhh. '-)

Thanks for putting this wandering to an end. Works just like magic. 

Cheers,

-- 
 |\  /||   |  ~ ~  
 | \/ ||---|  `|` ?
 ||ichael  |   |iggins\^ /
 michael.higgins[at]evolone[dot]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/