Peer review request: weak reference patch for CGI::Application::Plugin::HTDot

View: New views
15 Messages — Rating Filter:   Alert me  

Peer review request: weak reference patch for CGI::Application::Plugin::HTDot

by Mark Stosberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


CGI::Application::Plugin::HTDot currently creates a circular reference,
by adding a reference back to the application object from the template
object, which is already referenced by the application object.

The line of code is this:

 $t->param( c => $self ) if $var =~ /^c\./;

Is it correct that it should actually be this?

  use Scalar::Util 'weaken';
  $t->param( c => weaken($self) ) if $var =~ /^c\./;

The unpatched version once caused a problem for me because I depended on
CGI::Session's behavior of calling "flush()" automatically when that
object goes out of scope.

Because of the circular reference, the object didn't go out of scope in
time, and the flush didn't happen.

   Mark




#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: Peer review request: weak reference patch for CGI::Application::Plugin::HTDot

by Rhesa Rozendaal-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mark Stosberg wrote:
> CGI::Application::Plugin::HTDot currently creates a circular reference,
> by adding a reference back to the application object from the template
> object, which is already referenced by the application object.

Where do you have a reference to the template object? Aren't your template
objects local to the run mode?

> The line of code is this:
>
>  $t->param( c => $self ) if $var =~ /^c\./;
>
> Is it correct that it should actually be this?
>
>   use Scalar::Util 'weaken';
>   $t->param( c => weaken($self) ) if $var =~ /^c\./;

I think it's a good idea in general. I certainly don't see a drawback. The
template shouldn't use (or change!) the value of $self anyway, and weakrefs
work just as well for objects.

rhesa

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: Peer review request: weak reference patch for CGI::Application::Plugin::HTDot

by Mark Stosberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, 2008-06-21 at 20:05 +0200, Rhesa Rozendaal wrote:
> Mark Stosberg wrote:
> > CGI::Application::Plugin::HTDot currently creates a circular reference,
> > by adding a reference back to the application object from the template
> > object, which is already referenced by the application object.
>
> Where do you have a reference to the template object? Aren't your template
> objects local to the run mode?

<thinks>. Right. On second thought I don't believe they are connected
that way. That also supports my recollection that I tried using
"weakref" to fix the conflict with CGI::Session and it didn't work.

In any case, as a CGI::Session maintainer, the docs in several places
say to explicitly flush(), which is a fine solution to that problem.

At the time I had several hours on this debugging tour with the "Dot"
plugin, but perhaps I'll give it a second try now.

Rhesa: Since you've used it for quite some time how, how have you liked
it?

   Mark



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: Re: Peer review request: weak reference patch for CGI::Application::Plugin::HTDot

by Rhesa Rozendaal-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mark Stosberg wrote:
> Rhesa: Since you've used it for quite some time how, how have you liked
> it?


We've been using it in production for over two years now, and it works well.
It does what we need just fine, and that's accessing nested data structures or
nested objects.


It's certainly the slowest option available. That hasn't hurt us sofar, and
we've had some high-profile events (during the Miss Universe competition we
had about 40 million hits per day). On the other hand, we're getting so big
that I'm now looking into the faster options (TT2, Template::Alloy), because
shaving 50ms off every request adds up.


My biggest gripe with its functionality is that it's tricky to use one param
value as argument to a method call on another param. Here's what I mean:

$t->param(
    an_object   => $an_object,
    a_formatter => $a_formatter,
);

with this in the template:

     <tmpl_var a_formatter.format_fancy(an_object.some_value)>

That only works if you also have something in the template referencing
"an_object.some_value" directly, for example:

     <tmpl_if an_object.some_value></tmpl_if>

Otherwise the thing isn't recognised as a variable, because it doesn't appear
in HTML::Template's param_map.

I've been experimenting with adding a filter to add those empty tmpl_if
blocks. That seems the wrong approach, but it's the only thing I could think
of other than changing big parts of HTML::Template. I'd rather defect than do
that :-)


Rhesa



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: HTML::Template vs Template::Alloy

by Mark Stosberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> It's certainly the slowest option available. That hasn't hurt us sofar, and
> we've had some high-profile events (during the Miss Universe competition we
> had about 40 million hits per day). On the other hand, we're getting so big
> that I'm now looking into the faster options (TT2, Template::Alloy), because
> shaving 50ms off every request adds up.

Rhesa,

I hadn't noticed Template::Alloy before. It does like interesting as an
option that is like HTML::Template with the dot notation, but faster.

It doesn't support filters, which is an H::T feature that I use, but I
could find a way to do that pre-processing before handing the templates
off to Allow.


I'm not thrilled that the Alloy  H::T mode includes every templating
feature on the sun, but perhaps they could be ignored.

I had followed HTML::Template::Compiled with interest in the past, but
now it has become a suite of about 20 modules with more features and
complexity than suits me.

If you do try Template::Alloy, I'll be interested to hear a review of
that.

    Mark




#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: Re: HTML::Template vs Template::Alloy

by Ron Savage :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Mark

> I hadn't noticed Template::Alloy before. It does like interesting as an
> option that is like HTML::Template with the dot notation, but faster.

For me, Template::Alloy hung during make test, so I gave up trying to
use it.

--
Ron Savage
ron@...
http://savage.net.au/index.html



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: Peer review request: weak reference patch for CGI::Application::Plugin::HTDot

by Ricardo SIGNES-12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Mark Stosberg <mark@...> [2008-06-21T10:53:56]
>  $t->param( c => $self ) if $var =~ /^c\./;
>
> Is it correct that it should actually be this?
>
>   use Scalar::Util 'weaken';
>   $t->param( c => weaken($self) ) if $var =~ /^c\./;

No.  Scalar::Util weakens the actual reference.  It does not return a new, weak
reference.

What you're doing is this:

  $t->param(c => $self);
  weaken $self;

The $self in the template stash is a strong reference, and the object itself is
weak.  I'm not sure of the scope of $t, here, but were $t to go out of scope,
taking its params with it, and if there were no other references to the object,
$self would become undef.

What you want is something like:

  $t->param(c => $self);
  weaken $t->param('c');

I suggest testing my assertions with Scalar::Util::isweak.

--
rjbs

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: Re: HTML::Template vs Template::Alloy

by Rhesa Rozendaal-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mark Stosberg wrote:

>> It's certainly the slowest option available. That hasn't hurt us sofar, and
>> we've had some high-profile events (during the Miss Universe competition we
>> had about 40 million hits per day). On the other hand, we're getting so big
>> that I'm now looking into the faster options (TT2, Template::Alloy), because
>> shaving 50ms off every request adds up.
>
> Rhesa,
>
> I hadn't noticed Template::Alloy before. It does like interesting as an
> option that is like HTML::Template with the dot notation, but faster.
>
> It doesn't support filters, which is an H::T feature that I use, but I
> could find a way to do that pre-processing before handing the templates
> off to Allow.

Yeah, lack of filters is slightly annoying, but I'm sure that's easy to work
around.

> I'm not thrilled that the Alloy  H::T mode includes every templating
> feature on the sun, but perhaps they could be ignored.

As I understand it, all of the extra features are turned off by default when
you use the HT mode: see the NO_TT flag under "CONFIGURATION (HTML::Template
STYLE)".

But I base that solely on reading the documentation, I haven't really tried it.

> I had followed HTML::Template::Compiled with interest in the past, but
> now it has become a suite of about 20 modules with more features and
> complexity than suits me.

Yeah, I tend to agree. I took it for a spin briefly, and it's fast enough. But
it specifically didn't implement the feature I needed (nested variables), so I
basically ignore it now.

> If you do try Template::Alloy, I'll be interested to hear a review of
> that.

I've put it on my to-do list :)
Hiveminder rocks, BTW.

Rhesa

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


OT: HiveMinder

by Mark Stosberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Hiveminder rocks, BTW.

I agree. I have a pro account myself. It's a nice example of a Web 2.0
service in Perl.

I find it most useful for shared to-do lists, but use it for some
personal organization as well.

   Mark



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: OT: HiveMinder

by Ricardo SIGNES-12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Mark Stosberg <mark@...> [2008-06-23T16:05:54]
> I agree. I have a pro account myself. It's a nice example of a Web 2.0
> service in Perl.
>
> I find it most useful for shared to-do lists, but use it for some
> personal organization as well.

I really like it, and have blagged about that in the past.  I need to write
about all the things I don't like, or want, though...

--
rjbs

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: OT: HiveMinder

by Brad Cathey-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In the OT vein, I'm curious what makes Hiveminder a Web 2.0 app, other  
than the presence of a blog? Just curious.

Also, any idea what framework it is built on?

Breadwild

On Jun 23, 2008, at 3:05 PM, Mark Stosberg wrote:

>
>> Hiveminder rocks, BTW.
>
> I agree. I have a pro account myself. It's a nice example of a Web 2.0
> service in Perl.
>
> I find it most useful for shared to-do lists, but use it for some
> personal organization as well.
>
>   Mark
>
>
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>


#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: OT: HiveMinder

by Emmanuel Seyman-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Gmail [24/06/2008 10:29] :
>
> Also, any idea what framework it is built on?

Hiveminder is built using Jifty, a framework created by Jesse Vincent.
http://search.cpan.org/~sartak/Jifty-0.80408/

Emmanuel

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: OT: HiveMinder

by Ricardo SIGNES-12 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Gmail <breadwild@...> [2008-06-23T22:18:46]
> In the OT vein, I'm curious what makes Hiveminder a Web 2.0 app, other than
> the presence of a blog? Just curious.

It has some XMLHTTPRequest stuff, and a JSON API and probably some rounded
corners.

Does anybody know what Web 2.0 really means, apart from the above?  I hate that
darn phrase.

--
rjbs

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: OT: HiveMinder

by Dan Horne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ricardo SIGNES wrote:

> * Gmail <breadwild@...> [2008-06-23T22:18:46]
>  
>> In the OT vein, I'm curious what makes Hiveminder a Web 2.0 app, other than
>> the presence of a blog? Just curious.
>>    
>
> It has some XMLHTTPRequest stuff, and a JSON API and probably some rounded
> corners.
>
> Does anybody know what Web 2.0 really means, apart from the above?  I hate that
> darn phrase.
>
>  
Well, here's one explanation...

http://www.oreillynet.com/pub/a/oreilly/tim/news/2005/09/30/what-is-web-20.html

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################


Re: OT: What's Web2.0 really mean?

by Mark Stosberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 2008-06-24 at 08:07 -0400, Ricardo SIGNES wrote:
> * Gmail <breadwild@...> [2008-06-23T22:18:46]
> > In the OT vein, I'm curious what makes Hiveminder a Web 2.0 app, other than
> > the presence of a blog? Just curious.
>
> It has some XMLHTTPRequest stuff, and a JSON API and probably some rounded
> corners.
>
> Does anybody know what Web 2.0 really means, apart from the above?  I hate that
> darn phrase.

In Web2.0, there's a comment box on the bottom of most every page.

It's the social, read/write web with AJAX sprinkled on top.

   Mark



#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################