silent_mobius ([info]silent_mobius) wrote,
@ 2006-11-23 15:17:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Arrrrgh

Y'see this is why I "Just don't get" Catalyst.

Ok so I have a list "method" for a table purchase_order right? The stuff that InstantCRUD spat out for Template::Toolkit actually makes sense this time (rather than the form handler that delegated everything to HTML::Widget which is _really_ starting to get on my nerves.) now there is a 1 to many relationship with the purchase_order_row table so InstantCRUD show an entry in the list view formed by:

[% FOR val = row.purchase_order_rows; val; ', '; END %]

This lists all of the id's of the purchase_order_row rows that are associated with the current purchase_order row (still with me?) So I'd like that to simply be a count of those rows, after all I don't want the users to see the id's if I can help it.

So does TT have some way of doing scalar(@array) because that row.purchase_order_rows its a list right? No, its an object, its PurchaseOrder::Model::DBICSchemamodel::PurchaseOrderRow which doesn't exist it seem to be constructed by PurchaseOrder::Model::DBICSchemamodel's parent Catalyst::Model::DBIC::Schema and looking at the source to that doen't really tell me much because it's so abstracted.

So how the hell do I get a count of row.purchase_order_rows in TT is there a method I can use to get at it? This is why Catalyst _needs_ some explicit docs. You can't spend an hour searching through inheritance just to work out what methods you can use, there should be a list, somewhere and it should never be unclear what a object _really_ is, maybe something like:

The default resultset passed to the default TT list controller (/MyApp/root/MyTableObject/list) created by the InstantCrud helper is a XXX that inherets from YYY and ZZZ. Supported methods are:

oooo (link) from YYY
pppp (link from ZZZ
...

 




(2 comments) - (Post a new comment)

Catalyst
(Anonymous)
2006-11-23 04:20 pm UTC (link)
Is row.purchase_order_rows a DBIx::Class::Resultset?
If so, try row.purchase_order_rows.count (that should
work according to the docs for the aformentioned
module).

Anyway, there's a fairly active community:

http://www.gossamer-threads.com/lists/catalyst/users/

http://www.mail-archive.com/dbix-class@lists.rawmode.org/

http://blog.gmane.org/gmane.comp.lang.perl.modules.html-widget.general

so post more code and ask for help.

(Reply to this) (Thread)

Re: Catalyst
[info]silent_mobius
2006-11-24 10:52 am UTC (link)
Wow, random reply, thanks. I did try that almost first in fact. (as row.purchase_order_rows did indeed act as DBIx::Class::Resultset) however (as I later found out by asking in #Catalyst) it turns out that TT has a problem with it's dot opperator.

row.purchase_order_rows.count was getting row.purchase_order_rows in list context and then trying to coerce that into a hash and find entry {'count'} the recommendation was to use: row.purchase_order_rows_rs.count as purchase_order_rows_rs wouldn't provide the option to be taken in list context (I think) hence would actually call the ->count() method. I'm actually on the Catalyst mailing list, but keeping up can be tough at times.

(Reply to this) (Parent)


(2 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…