No subject
Thu Mar 10 16:39:45 CET 2011
# disable layout
my $layout = setting('layout');
setting('layout' => undef);
my $response = $code->();
setting('layout' => $layout);
return $response;
I guess my $response = $code->() is where inner views are executed and a
call to config::load will cause 'layout' to be initialised.
On Wed, Jun 29, 2011 at 6:10 PM, sawyer x <xsawyerx at gmail.com> wrote:
> I could not replicate your case using your code.
>
>
> On Wed, Jun 29, 2011 at 7:44 PM, sawyer x <xsawyerx at gmail.com> wrote:
>
>> It would appear as though reloading the config disables
>> Dancer::Plugin::Ajax.
>>
>> Let me look into that...
>>
>> On Wed, Jun 29, 2011 at 6:17 PM, Stephen Fenwick-Paul <
>> stephen at activeg.org> wrote:
>>
>>> Hi,
>>>
>>>
>>> V. simple app:
>>>
>>> package MyApp;
>>>
>>> use Dancer ':syntax';
>>> use Dancer::Plugin::Ajax;
>>>
>>> ajax '/hellox/:name' => sub {
>>> template 'hello';
>>> };
>>>
>>> true;
>>>
>>> Produces:
>>>
>>>
>>> $ curl -H 'X-Requested-With: XMLHttpRequest'
>>> http://www.myapp.new/hellox/fred
>>>
>>> *<p>This is hello</p>*
>>> *
>>> *
>>> Which is to be expected.
>>>
>>> But:
>>>
>>> package MyApp;
>>>
>>> use Dancer ':syntax';
>>> use Dancer::Plugin::Ajax;
>>>
>>> ajax '/hellox/:name' => sub {
>>> * Dancer::Config::setting('appdir',$ENV{ROOT});*
>>> * Dancer::Config::load();*
>>>
>>> template 'hello';
>>> };
>>>
>>> true;
>>>
>>> $ curl -H 'X-Requested-With: XMLHttpRequest'
>>> http://www.myapp.new/hellox/fred
>>>
>>> Produces:
>>>
>>>
>>> *<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"*
>>> *"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">*
>>> *<html xmlns="http://www.w3.org/1999/xhtml">*
>>> *<head></head>*
>>> *<body>*
>>> * *
>>> *<p>This is hello</p>*
>>> *
>>> *
>>> *</body>*
>>> *</html>*
>>>
>>> So, running *Dancer::Config::load() *stops Plugin::Ajax working.
>>>
>>> This may seems a strange thing to do, but for me the load() was deep in a
>>> module that some times runs outside of Dancer but picks up stuff from the
>>> Dancer config.
>>>
>>> Handling the ajax call manually (as per the the Cookbox) there are no
>>> problems with using load().
>>>
>>> Stephen
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Dancer-users mailing list
>>> Dancer-users at perldancer.org
>>> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>>>
>>>
>>
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
>
--bcaec53f38f9475d3a04a6fd57cb
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>I think what is happening is not the=A0plugin=A0is getting disabled but=
the 'layout' setting is getting reset.<div><br></div><div><br></di=
v><div>From=A0package Dancer::Plugin::Ajax;</div><div><br><div><div>=A0 =A0=
=A0 =A0 # disable layout</div>
<div>=A0 =A0 =A0 =A0 my $layout =3D setting('layout');</div><div>=
=A0 =A0 =A0 =A0 setting('layout' =3D> undef);</div><div>=A0 =A0 =
=A0 =A0 my $response =3D $code->();</div><div>=A0 =A0 =A0 =A0 setting(&#=
39;layout' =3D> $layout);</div>
<div>=A0 =A0 =A0 =A0 return $response;</div></div><div><br></div><div>I gue=
ss=A0=A0my $response =3D $code->() is where inner views are executed and=
a call to config::load will cause 'layout' to be=A0initialised.</d=
iv><div><br>
</div><div><br></div><div><br></div><div><br><div class=3D"gmail_quote">On =
Wed, Jun 29, 2011 at 6:10 PM, sawyer x <span dir=3D"ltr"><<a href=3D"mai=
lto:xsawyerx at gmail.com">xsawyerx at gmail.com</a>></span> wrote:<br><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex;">
<div dir=3D"ltr">I could not replicate your case using your code.<div><div>=
</div><div class=3D"h5"><br><br><div class=3D"gmail_quote">On Wed, Jun 29, =
2011 at 7:44 PM, sawyer x <span dir=3D"ltr"><<a href=3D"mailto:xsawyerx@=
gmail.com" target=3D"_blank">xsawyerx at gmail.com</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">It would appear as though r=
eloading the config disables Dancer::Plugin::Ajax.<br><br>Let me look into =
that...<br>
<br><div class=3D"gmail_quote"><div><div></div><div>On Wed, Jun 29, 2011 at=
6:17 PM, Stephen Fenwick-Paul <span dir=3D"ltr"><<a href=3D"mailto:step=
hen at activeg.org" target=3D"_blank">stephen at activeg.org</a>></span> wrote=
:<br>
</div></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div><div></div><div><div class=
=3D"gmail_quote">Hi,<div><br></div><div><br></div><div>V. simple app:</div>
<div><br></div><div><div>package MyApp;</div>
<div><br></div><div>use Dancer ':syntax';</div><div>use Dancer::Plu=
gin::Ajax;</div>
<div><br></div><div>ajax '/hellox/:name' =3D> sub {</div><div>=
=A0 =A0 template 'hello';</div><div>};</div><div><br></div><div>tru=
e;</div></div><div><br></div><div>Produces:</div><div><br></div><div><br></=
div>
<div><div>$ curl -H 'X-Requested-With: XMLHttpRequest' <a href=3D"h=
ttp://www.myapp.new/hellox/fred" target=3D"_blank">http://www.myapp.new/hel=
lox/fred</a></div>
<div><br></div><div><i><p>This is hello</p></i></div></div><div=
><i><br></i></div><div>Which is to be expected.</div><div><br></div><div>Bu=
t:</div><div><br></div><div>package MyApp;</div><div><div><br></div><div>
use Dancer ':syntax';</div>
<div>use Dancer::Plugin::Ajax;</div><div><br></div><div>ajax '/hellox/:=
name' =3D> sub {</div><div><b>=A0 =A0 Dancer::Config::setting('a=
ppdir',$ENV{ROOT});</b></div><div><b>=A0 =A0 Dancer::Config::load();</b=
></div>
<div><br></div><div>=A0 =A0 template 'hello';</div><div>};</div><di=
v><br></div><div>true;</div></div><div><br></div><div>$ curl -H 'X-Requ=
ested-With: XMLHttpRequest' <a href=3D"http://www.myapp.new/hellox/fred=
" target=3D"_blank">http://www.myapp.new/hellox/fred</a></div>
<div>
<div><br></div><div><div>Produces:</div></div><div><br></div><div><br></div=
><div><i><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/=
/EN"</i></div>
<div><i>"<a href=3D"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona=
l.dtd" target=3D"_blank">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona=
l.dtd</a>"></i></div><div><i><html xmlns=3D"<a href=3D"http=
://www.w3.org/1999/xhtml" target=3D"_blank">http://www.w3.org/1999/xhtml</a=
>"></i></div>
<div><i><head></head></i></div><div><i><body></i></div><d=
iv><i>=A0 =A0=A0</i></div><div><i><p>This is hello</p></i></div=
><div><i><br></i></div><div><i></body></i></div><div><i></html>=
</i></div>
</div><div><br></div><div>So, running=A0<b>Dancer::Config::load() </b>stops=
Plugin::Ajax working.</div>
<div><br></div><div>This may seems a strange thing to do, but for me the lo=
ad() was deep in a module that some times runs outside of Dancer but picks =
up stuff from the Dancer config.=A0</div><div><br></div><div>Handling the a=
jax call manually (as per the the Cookbox) there are no problems with using=
load().</div>
<div><br></div><font color=3D"#888888"><div>Stephen</div>
<div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>=
<div>=A0</div>
</font></div><br>
<br></div></div>_______________________________________________<br>
Dancer-users mailing list<br>
<a href=3D"mailto:Dancer-users at perldancer.org" target=3D"_blank">Dancer-use=
rs at perldancer.org</a><br>
<a href=3D"http://www.backup-manager.org/cgi-bin/listinfo/dancer-users" tar=
get=3D"_blank">http://www.backup-manager.org/cgi-bin/listinfo/dancer-users<=
/a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
Dancer-users mailing list<br>
<a href=3D"mailto:Dancer-users at perldancer.org">Dancer-users at perldancer.org<=
/a><br>
<a href=3D"http://www.backup-manager.org/cgi-bin/listinfo/dancer-users" tar=
get=3D"_blank">http://www.backup-manager.org/cgi-bin/listinfo/dancer-users<=
/a><br>
<br></blockquote></div><br></div></div>
--bcaec53f38f9475d3a04a6fd57cb--
More information about the Dancer-users
mailing list