Vyacheslav Akhmechet <[email protected]> writes:

> On Tue, Feb 24, 2009 at 8:05 AM, Leslie P. Polzer <[email protected]> 
> wrote:
>> What are your plans for implementing this?
> I can't commit to a timeline, unfortunately. There are a couple of
> things I'd like to see happen in weblocks - this, a jQuery rewrite
> (it's just more practical than Prototype at this point), 

If you do, could you please keep in mind that some people (like me) will
want to rip out both Prototype and jQuery and use YUI (or something
else)?

Thing is, I need YUI widgets, so since I'm pulling all of YUI anyway, I
might as well use the base functionality instead of additionally loading
Prototype of jQuery.

Perhaps a Weblocks API will emerge?

> and support for caching. I'm not sure when and in what order I'll need
> these things yet, so the only thing I can say is that I'll probably do
> them eventually. Sorry, that's the best I can do now.
>
> Btw, here's my idea for caching:
>
> (defun get-foo (...) ...)
> (defcache get-foo :request)
>
> (defun get-bar (...) ...)
> (defcache get-bar :application :timeout 5)

This is something I implemented in my usual "ain't pretty, but works as
a first shot" manner. I have a 'cached-content-mixin':

  (defclass cached-content-mixin ()
    ((last-update :accessor last-update-of :initarg :last-update :initform nil)
     (update-interval :accessor update-interval-of :initarg :update-interval 
:initform (* 5 60))))
  
  (defmethod update-if-needed ((obj cached-content-mixin) update-function)
    (unless (and (last-update-of obj)
               (< (- (current-time) (last-update-of obj)) (update-interval-of 
obj)))
      (setf (last-update-of obj) (current-time))
      (funcall update-function)))

Some widgets inherit from it, and have a :before method on
render-widget-body which updates the content if necessary:

  (defmethod render-widget-body :before ((w newsboard) &rest args)
    (declare (ignore args))
    (update-if-needed w (lambda () (update-items w))))

The update should really be done during tree shakedown, not during
render, but I haven't gotten around to that yet. And it isn't that
important.

Solves my immediate problem.

--J.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"weblocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/weblocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to