[Dancer-users] Dancer::plugin:ajax & config:load

sawyer x xsawyerx at gmail.com
Sun Jul 17 13:41:14 CEST 2011


Trying to backtrack a bit.

Was this issue solved?

On Fri, Jul 1, 2011 at 10:55 AM, Stephen Fenwick-Paul
<stephen at activeg.org>wrote:

>
> I think what is happening is not the plugin is getting disabled but the
> 'layout' setting is getting reset.
>
>
> From package Dancer::Plugin::Ajax;
>
>         # 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
>>
>>
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110717/bc270621/attachment.htm>


More information about the Dancer-users mailing list