Mailing List Archive

Error: "You requested a stash, but one does not exist" #2
Hey all,

i'm testing an update to the latest Catalyst version.
the web-application via FCGI works fine, but i do run Catalyst from command line scripts as well.

like
use MyApp;

my $c = MyApp->new();


my $val = "12345";
$c->stash->{val} = $val;

my $stash = $c->stash->{val};
print "from stash: $stash\n";

since the upgrade i get the following error:

You requested a stash, but one does not exist at .....\site\lib\Catalyst.pm line 517.

As i read stash is now a middleware plugin; and is stored in the PSGI? environment; for sure thats not available when running from CLI.

how to i make the good old stash working if i'm from command line ?

thanks for support,
bernhard





Bernhard Bauch
Webdevelopment

ZSI-Zentrum für Soziale Innovation GmbH
Centre for Social Innovation

Linke Wienzeile 246, A-1150 Wien, Austria
Mail: bauch@zsi.at
Skype: berni-zsi
Re: Error: "You requested a stash, but one does not exist" #2 [ In reply to ]
Hi so

my $c = MyApp->new();

when you do that you don't have a context, its an instance of your application. Since Catalyst conflates the two this is a common thing to think :) But you only get a context IF you have a request. So $app->stash isn't going to work.

I'd be happy to take a patch to do something sorta correct in application context, but I'd rather help you not use the stash like this. Its probably going to make sad pandas down the road. That's half the reason I went this direction (to help move us along toward the application/context split we've talked about for years and years...)

You could fake it by giving your instance a request object. But tell me more about the use case

Jnap



On Wednesday, May 20, 2015 6:05 AM, Bernhard Bauch <bauch@zsi.at> wrote:



Hey all,

i'm testing an update to the latest Catalyst version.
the web-application via FCGI works fine, but i do run Catalyst from command line scripts as well.

likeuse MyApp;


my $c = MyApp->new();


my $val = "12345";
$c->stash->{val} = $val;

my $stash = $c->stash->{val};
print "from stash: $stash\n";

since the upgrade i get the following error:

You requested a stash, but one does not exist at .....\site\lib\Catalyst.pm line 517.

As i read stash is now a middleware plugin; and is stored in the PSGI? environment; for sure thats not available when running from CLI.

how to i make the good old stash working if i'm from command line ?

thanks for support,
bernhard






—
Bernhard Bauch
Webdevelopment

ZSI-Zentrum für Soziale Innovation GmbH
Centre for Social Innovation

Linke Wienzeile 246, A-1150 Wien, Austria
Mail: bauch@zsi.at
Skype: berni-zsi




_______________________________________________
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: Error: "You requested a stash, but one does not exist" #2 [ In reply to ]
Hey again,

> You could fake it by giving your instance a request object.

actually in my usecase, i already do fake a request object...
but that does not help either :(

looks like this.....

> my $c = MyApp->new();
>

my $base_url = "http://somedomain.com";
my $uri_path = '/';
my $uri = \$uri_path;
bless $uri, 'URI::http';

my $base = \$base_url;
bless $base, 'URI::http';

# load request
$c->request(Catalyst::Request->new({
'cookies' => {},
'base' => $base,
'uri' => $uri,
'secure' => 1,
'headers' => HTTP::Headers->new,
'_log' => $c->log,
}));

>
> my $val = "12345";
> $c->stash->{val} = $val;
>
> my $stash = $c->stash->{val};
> print "from stash: $stash\n";


I needed to have a request object to have
$c->uri_for(....);
working for my commandline script to be able to generate real URIs.

Do i need to add further magic while creating request object, so that stash would also work ? tried to

> But tell me more about the use case
the CLI scripts are triggering different actions from Controllers and using the stash to passaround data from action to action or make some data available to all actions..
i guess that did not help much ;)

cheerz
bernhard


On 20 May 2015, at 21:27, John Napiorkowski <jjn1056@yahoo.com> wrote:

> Hi so
>
> my $c = MyApp->new();
>
> when you do that you don't have a context, its an instance of your application. Since Catalyst conflates the two this is a common thing to think :) But you only get a context IF you have a request. So $app->stash isn't going to work.
>
> I'd be happy to take a patch to do something sorta correct in application context, but I'd rather help you not use the stash like this. Its probably going to make sad pandas down the road. That's half the reason I went this direction (to help move us along toward the application/context split we've talked about for years and years...)
>
> You could fake it by giving your instance a request object. But tell me more about the use case
>
> Jnap
>
>
>
> On Wednesday, May 20, 2015 6:05 AM, Bernhard Bauch <bauch@zsi.at> wrote:
>
>
>
> Hey all,
>
> i'm testing an update to the latest Catalyst version.
> the web-application via FCGI works fine, but i do run Catalyst from command line scripts as well.
>
> likeuse MyApp;
>
>
> my $c = MyApp->new();
>
>
> my $val = "12345";
> $c->stash->{val} = $val;
>
> my $stash = $c->stash->{val};
> print "from stash: $stash\n";
>
> since the upgrade i get the following error:
>
> You requested a stash, but one does not exist at .....\site\lib\Catalyst.pm line 517.
>
> As i read stash is now a middleware plugin; and is stored in the PSGI? environment; for sure thats not available when running from CLI.
>
> how to i make the good old stash working if i'm from command line ?
>
> thanks for support,
> bernhard
>
>
>
>
>
>
> —
> Bernhard Bauch
> Webdevelopment
>
> ZSI-Zentrum für Soziale Innovation GmbH
> Centre for Social Innovation
>
> Linke Wienzeile 246, A-1150 Wien, Austria
> Mail: bauch@zsi.at
> Skype: berni-zsi
>
>
>
>
> _______________________________________________
> 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/
>
> !DSPAM:555ce08316081354624907!
>
>


Bernhard Bauch
Webdevelopment

ZSI-Zentrum für Soziale Innovation GmbH
Centre for Social Innovation

Linke Wienzeile 246, A-1150 Wien, Austria
Mail: bauch@zsi.at
Skype: berni-zsi
Re: Error: "You requested a stash, but one does not exist" #2 [ In reply to ]
Hey sorry to top post, but let me try to summarize:

1) You need to make URLs

Ok, perfect you should find that uri_for works in application context

MyApp->uri_for

and that should return a uri::generic object. Hobbs thought it would be easy to add a util to Catalyst utils that takes a URI::generic and base URL and returns a real URL. So that should work. Give it a try and let me know?

2) Calling controllers from a script, etc.

I know you probably don't want to hear it (:) ) but I would strive to have all that business logic elsewhere (not in the controller), so that you can make this easier.

However if you can't do that we could take a patch to make stash do something not insane in application context or a plugin to make the stash like the old stash for people that can't make the leap. How does that sound?

Jnap



On Wednesday, May 20, 2015 5:09 PM, Bernhard Bauch <bauch@zsi.at> wrote:
Hey again,

> You could fake it by giving your instance a request object.

actually in my usecase, i already do fake a request object...
but that does not help either :(

looks like this.....

> my $c = MyApp->new();
>

my $base_url = "http://somedomain.com";
my $uri_path = '/';
my $uri = \$uri_path;
bless $uri, 'URI::http';

my $base = \$base_url;
bless $base, 'URI::http';

# load request
$c->request(Catalyst::Request->new({
'cookies' => {},
'base' => $base,
'uri' => $uri,
'secure' => 1,
'headers' => HTTP::Headers->new,
'_log' => $c->log,
}));

>
> my $val = "12345";
> $c->stash->{val} = $val;
>
> my $stash = $c->stash->{val};
> print "from stash: $stash\n";


I needed to have a request object to have
$c->uri_for(....);
working for my commandline script to be able to generate real URIs.

Do i need to add further magic while creating request object, so that stash would also work ? tried to

> But tell me more about the use case
the CLI scripts are triggering different actions from Controllers and using the stash to passaround data from action to action or make some data available to all actions..
i guess that did not help much ;)

cheerz
bernhard


On 20 May 2015, at 21:27, John Napiorkowski <jjn1056@yahoo.com> wrote:

> Hi so
>
> my $c = MyApp->new();
>
> when you do that you don't have a context, its an instance of your application. Since Catalyst conflates the two this is a common thing to think :) But you only get a context IF you have a request. So $app->stash isn't going to work.
>
> I'd be happy to take a patch to do something sorta correct in application context, but I'd rather help you not use the stash like this. Its probably going to make sad pandas down the road. That's half the reason I went this direction (to help move us along toward the application/context split we've talked about for years and years...)
>
> You could fake it by giving your instance a request object. But tell me more about the use case
>
> Jnap
>
>
>
> On Wednesday, May 20, 2015 6:05 AM, Bernhard Bauch <bauch@zsi.at> wrote:
>
>
>
> Hey all,
>
> i'm testing an update to the latest Catalyst version.
> the web-application via FCGI works fine, but i do run Catalyst from command line scripts as well.
>
> likeuse MyApp;
>
>
> my $c = MyApp->new();
>
>
> my $val = "12345";
> $c->stash->{val} = $val;
>
> my $stash = $c->stash->{val};
> print "from stash: $stash\n";
>
> since the upgrade i get the following error:
>
> You requested a stash, but one does not exist at .....\site\lib\Catalyst.pm line 517.
>
> As i read stash is now a middleware plugin; and is stored in the PSGI? environment; for sure thats not available when running from CLI.
>
> how to i make the good old stash working if i'm from command line ?
>
> thanks for support,
> bernhard
>
>
>
>
>
>
> —
> Bernhard Bauch
> Webdevelopment
>
> ZSI-Zentrum für Soziale Innovation GmbH
> Centre for Social Innovation
>
> Linke Wienzeile 246, A-1150 Wien, Austria
> Mail: bauch@zsi.at
> Skype: berni-zsi
>
>
>
>
> _______________________________________________
> 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/
>
> !DSPAM:555ce08316081354624907!

>
>

—
Bernhard Bauch
Webdevelopment

ZSI-Zentrum für Soziale Innovation GmbH
Centre for Social Innovation

Linke Wienzeile 246, A-1150 Wien, Austria
Mail: bauch@zsi.at
Skype: berni-zsi





_______________________________________________
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: Error: "You requested a stash, but one does not exist" #2 [ In reply to ]
Hey,

On 21 May 2015, at 01:20, John Napiorkowski <jjn1056@yahoo.com> wrote:

> Hey sorry to top post, but let me try to summarize:
>
> 1) You need to make URLs
>
> Ok, perfect you should find that uri_for works in application context
>
> MyApp->uri_for
>
> and that should return a uri::generic object. Hobbs thought it would be easy to add a util to Catalyst utils that takes a URI::generic and base URL and returns a real URL. So that should work. Give it a try and let me know?

# MyApp->uri_for
returns an path.

# $c->uri_for
returns nothing useful.

creating kind of a fake request object, as written in the last email, actually works well for me. also with the latest catalyst version.
i need to generated URLs in the TT2, and there i can't use MyApp->uri_for ...or i'd need to change all the templates..
soo, thats fine for me as it is.

>
> 2) Calling controllers from a script, etc.
>
> I know you probably don't want to hear it (:) ) but I would strive to have all that business logic elsewhere (not in the controller), so that you can make this easier.
>
> However if you can't do that we could take a patch to make stash do something not insane in application context or a plugin to make the stash like the old stash for people that can't make the leap. How does that sound?

i now changed the code, so i'm not putting data in the stash anymore, works fine; and maybe is also a better solution. so actually that thing is solved for me.
anyway, maybe it would be good, to have a plugin that provides the old stash logic for backward compatibility?

cheers,
bernhard

>
> Jnap
>
>
>
> On Wednesday, May 20, 2015 5:09 PM, Bernhard Bauch <bauch@zsi.at> wrote:
> Hey again,
>
>> You could fake it by giving your instance a request object.
>
> actually in my usecase, i already do fake a request object...
> but that does not help either :(
>
> looks like this.....
>
>> my $c = MyApp->new();
>>
>
> my $base_url = "http://somedomain.com";
> my $uri_path = '/';
> my $uri = \$uri_path;
> bless $uri, 'URI::http';
>
> my $base = \$base_url;
> bless $base, 'URI::http';
>
> # load request
> $c->request(Catalyst::Request->new({
> 'cookies' => {},
> 'base' => $base,
> 'uri' => $uri,
> 'secure' => 1,
> 'headers' => HTTP::Headers->new,
> '_log' => $c->log,
> }));
>
>>
>> my $val = "12345";
>> $c->stash->{val} = $val;
>>
>> my $stash = $c->stash->{val};
>> print "from stash: $stash\n";
>
>
> I needed to have a request object to have
> $c->uri_for(....);
> working for my commandline script to be able to generate real URIs.
>
> Do i need to add further magic while creating request object, so that stash would also work ? tried to
>
>> But tell me more about the use case
> the CLI scripts are triggering different actions from Controllers and using the stash to passaround data from action to action or make some data available to all actions..
> i guess that did not help much ;)
>
> cheerz
> bernhard
>
>
> On 20 May 2015, at 21:27, John Napiorkowski <jjn1056@yahoo.com> wrote:
>
>> Hi so
>>
>> my $c = MyApp->new();
>>
>> when you do that you don't have a context, its an instance of your application. Since Catalyst conflates the two this is a common thing to think :) But you only get a context IF you have a request. So $app->stash isn't going to work.
>>
>> I'd be happy to take a patch to do something sorta correct in application context, but I'd rather help you not use the stash like this. Its probably going to make sad pandas down the road. That's half the reason I went this direction (to help move us along toward the application/context split we've talked about for years and years...)
>>
>> You could fake it by giving your instance a request object. But tell me more about the use case
>>
>> Jnap
>>
>>
>>
>> On Wednesday, May 20, 2015 6:05 AM, Bernhard Bauch <bauch@zsi.at> wrote:
>>
>>
>>
>> Hey all,
>>
>> i'm testing an update to the latest Catalyst version.
>> the web-application via FCGI works fine, but i do run Catalyst from command line scripts as well.
>>
>> likeuse MyApp;
>>
>>
>> my $c = MyApp->new();
>>
>>
>> my $val = "12345";
>> $c->stash->{val} = $val;
>>
>> my $stash = $c->stash->{val};
>> print "from stash: $stash\n";
>>
>> since the upgrade i get the following error:
>>
>> You requested a stash, but one does not exist at .....\site\lib\Catalyst.pm line 517.
>>
>> As i read stash is now a middleware plugin; and is stored in the PSGI? environment; for sure thats not available when running from CLI.
>>
>> how to i make the good old stash working if i'm from command line ?
>>
>> thanks for support,
>> bernhard
>>
>>
>>
>>
>>
>>
>> —
>> Bernhard Bauch
>> Webdevelopment
>>
>> ZSI-Zentrum für Soziale Innovation GmbH
>> Centre for Social Innovation
>>
>> Linke Wienzeile 246, A-1150 Wien, Austria
>> Mail: bauch@zsi.at
>> Skype: berni-zsi
>>
>>
>>
>>
>> _______________________________________________
>> 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/
>>
>>
>
>>
>>
>
> —
> Bernhard Bauch
> Webdevelopment
>
> ZSI-Zentrum für Soziale Innovation GmbH
> Centre for Social Innovation
>
> Linke Wienzeile 246, A-1150 Wien, Austria
> Mail: bauch@zsi.at
> Skype: berni-zsi
>
>
>
>
>
> _______________________________________________
> 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/
>
> !DSPAM:555d17c816084750615721!
>
>


Bernhard Bauch
Webdevelopment

ZSI-Zentrum für Soziale Innovation GmbH
Centre for Social Innovation

Linke Wienzeile 246, A-1150 Wien, Austria
Mail: bauch@zsi.at
Skype: berni-zsi