[Catalyst] Getting hashref instead of value

Alexander Hartmaier alexander.hartmaier at t-systems.at
Tue May 8 16:23:08 GMT 2012


Am 2012-05-08 18:15, schrieb Kenneth S Mclane:
> Yes, in changing things back and forth I forgot about that. I got that
> fixed and changed the relationship names. I have tried with "search"
> and "search_rs" and still have the same result of getting the object
> instead of the value. Can I use "get_column" in TT?
Yes, you only have to use . instead of -> for method calls.
>
>
> From: 	Alexander Hartmaier <alexander.hartmaier at t-systems.at>
> To: 	<catalyst at lists.scsys.co.uk>
> Date: 	05/08/2012 11:07 AM
> Subject: 	Re: [Catalyst] Getting hashref instead of value
>
>
> ------------------------------------------------------------------------
>
>
>
> Am 2012-05-08 17:46, schrieb Kenneth S Mclane:
> In checking through docs on line I find that prefetch is a better way
> to go so I have changed ny sub thusly:
>
> sub list :Local {
>        my ($self, $c, $page) =3D @_;
>        $page =3D $c->req->param('page') || 1;
>        my $rs =3D $c->model('ORANGES::Account')->search({}, {
>                prefetch =3D> 'progress',
>                prefetch =3D> 'compliance',
>                prefetch =3D> 'department_id',
>                prefetch =3D> 'metrics',
>                order_by =3D> 'account_code',
>                rows =3D> 15,
>                page =3D> $page,
>         });
>        $c->stash(accounts =3D> $rs);
>        $c->stash(pager =3D> $rs->pager());
>        $c->stash->{'template'}=3D>'accountview/list';
> }
> {} is a hashref in Perl. You're defining four values for the key
> 'prefetch', the last one overwrites the three previous ones.
> As already noted you need to specify the prefetch value as arrayref in
> your case:
> prefetch =3D> [qw( progress compliance department_id metrics )],
> FYI: qw() does nothing but saving you to quote every element of the
> list. It's equal to
> prefetch =3D> ['progress', 'compliance', 'department_id', 'metrics'],
>
> Note that this is all basic Perl and nothing specific of Catalyst or
> DBIx::Class.
>
> From:	Frank Schwach _<fs5 at sanger.ac.uk>_ <mailto:fs5 at sanger.ac.uk>
> To:	_catalyst at lists.scsys.co.uk_ <mailto:catalyst at lists.scsys.co.uk>
> Date:	05/08/2012 10:36 AM
> Subject:	Re: [Catalyst] Getting hashref instead of value
>
>
>
> ------------------------------------------------------------------------
>
>
>
> not sure if this is a problem but you should also collapse your joins,
> selects and as' into ArrayRefs, as in
> join =3D> [ qw( progress compliance department_id ...)]
>
> actually the last one looks suspicious. the relationships should be
> called something like "departments", not department_ids. If you have the
> same naming for accounts then an account_id is the name (presumably) of
> a field in accounts and also a relationship
> Frank
>
>
> On 08/05/12 16:25, Steve wrote:
> > The 'account.account_id' referenced in your template I believe is being
> > interpreted as an object. Try 'account.account_id.id' instead. I am
> > presuming that your DBIC relationship is called 'account_id', and that
> > is what you are referencing currently in your template.
> >
> > On 5/8/2012 11:13 AM, Kenneth S Mclane wrote:
> >> I am having a problem with my code and I cannot figure out why it is
> >> doing what it is doing. I have this sub:
> >>
> >> sub list :Local {
> >> my ($self, $c, $page) =3D @_;
> >> $page =3D $c->req->param('page') || 1;
> >> my $rs =3D $c->model('ORANGES::Account')->search({}, {
> >> join =3D> 'progress',
> >> '+select' =3D> ['progress.percent_complete'],
> >> '+as' =3D> ['progress.percent_complete'],
> >> join =3D> 'compliance',
> >> '+select' =3D> ['compliance.percent_compliant'],
> >> '+as' =3D> ['compliance.percent_compliant'],
> >> join =3D> 'department_id',
> >> '+select' =3D> ['department_id.department_id'],
> >> '+as' =3D> ['department_id.department_id'],
> >> join =3D> 'metrics',
> >> '+select' =3D> ['metrics.num_servers','metrics.num_subsystems'],
> >> '+as' =3D> ['metrics.num_servers','metrics.num_subsystems'],
> >> order_by =3D> 'account_code',
> >> rows =3D> 15,
> >> page =3D> $page,
> >> });
> >> $c->stash(accounts =3D> $rs);
> >> $c->stash(pager =3D> $rs->pager());
> >> $c->stash->{'template'}=3D>'accountview/list';
> >>
> >> }
> >> Which I have tried in several different ways to fix this problem, but
> >> none have worked so far. In my template file all my fields come up
> >> with the valyes expected, except, I am trying to use the account_id
> >> field value as part of a uri to take the user to a details page for
> >> the row. Where I am expecting a uri such as
> >> '_http://127.0.0.1:3000/accountdetails/detail/170_'
> >> I instead get a uri like this:
> >>
> >>
> _http://127.0.0.1:3000/accountdetails/detail/dbms::Model::ORANGES::Accoun=
t=3DHASH%280x5496460%29_
> >>
> >>
> >> This used to work when I was using a view as the basis for my list
> page.
> >>
> >> When I run the page I can see in the sub-queries that it runs that it
> >> has the "account_id" value as it uses it, but when I try to access it
> >> in my template I get the hash ref. None of the other fields do this.
> >>
> >> one of the sub queries using the account_id value:
> >> SELECT me.account_id, me.account_code, me.percent_compliant FROM
> >> HCDB_TEST.COMPLIANCE me WHERE ( me.account_id =3D ? ): '321'
> >>
> >>
> >> My template that cretaes the uri:
> >>
> >> <td><a href=3D"[% c.uri_for('/accountdetails/detail/') %][%
> >> account.account_id %]">[% account.account_code %]</a></td>
> >>
> >> If someone could point me in the right direction, Ive been fighting
> >> this for days.
> >>
> >>
> >>
> >> _______________________________________________
> >> List: _Catalyst at lists.scsys.co.uk_ <mailto:Catalyst at 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 at lists.scsys.co.uk_ <mailto:Catalyst at 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/_
>
>
> -- =

> The Wellcome Trust Sanger Institute is operated by Genome Research
> Limited, a charity registered in England with number 1021457 and a
> company registered in England with number 2742969, whose registered
> office is 215 Euston Road, London, NW1 2BE.
>
> _______________________________________________
> List: _Catalyst at lists.scsys.co.uk_ <mailto:Catalyst at 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 at lists.scsys.co.uk_ <mailto:Catalyst at 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 at 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 at 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.u=
k/
> Dev site: http://dev.catalyst.perl.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20120508/4965f=
ac3/attachment.htm


More information about the Catalyst mailing list