Joubert | 2 Jan 2008 06:20
Picon
Gravatar

Render-widget-body for my own widget


Hi,

I have created a new widget with (defwidget) and want to render it.
After much guessing, I got it working, but now want to know why the
more natural solution doesn't work.

To render my widget I've defined the following method:
------------------------
(defmethod render-widget-body ((obj linkwidget) &rest args)
  (declare (ignore args))
  (with-html
    (:p (render-widget (title obj))))
    (:p "Link")))
------------------------

My question is, why do I need to have the form (render-widget) if the
form (title obj) returns a string?
In other words, I had this first:
------------------------
(defmethod render-widget-body ((obj linkwidget) &rest args)
  (declare (ignore args))
  (with-html
    (:p (title obj)))
    (:p "Link")))
------------------------

Thanks
Joubert
--~--~---------~--~----~------------~-------~--~----~
(Continue reading)

Sohail Somani | 2 Jan 2008 07:10
Gravatar

Re: Render-widget-body for my own widget


On Tue, 01 Jan 2008 21:20:58 -0800, Joubert wrote:

[snip too much, no undo wtf?]
> ------------------------
> (defmethod render-widget-body ((obj linkwidget) &rest args)
>   (declare (ignore args))
>   (with-html
>     (:p (render-widget (title obj))))
>     (:p "Link")))

Thats to do with cl-who. cl-who doesn't know what that is (I think), so 
you have to do something like:

(with-html
 (:p (str (title obj))...

--

-- 
Sohail Somani
http://uint32t.blogspot.com

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

Joubert | 2 Jan 2008 07:27
Picon
Gravatar

Re: Render-widget-body for my own widget


Hi Sohail,

STR also works.

I haven't looked at the source code yet, but I wonder whether the
weblocks WITH-HTML form actually processes the RENDER-WIDGET form
before handing over work to CL-WHO's WITH-HTML-OUTPUT, because RENDER-
WIDGET works even though CL-WHO has no knowledge of it.

Joubert

On Jan 2, 1:10 am, Sohail Somani <soh...@...> wrote:
> On Tue, 01 Jan 2008 21:20:58 -0800, Joubert wrote:
>
> [snip too much, no undo wtf?]
>
> > ------------------------
> > (defmethod render-widget-body ((obj linkwidget) &rest args)
> >   (declare (ignore args))
> >   (with-html
> >     (:p (render-widget (title obj))))
> >     (:p "Link")))
>
> Thats to do with cl-who. cl-who doesn't know what that is (I think), so
> you have to do something like:
>
> (with-html
>  (:p (str (title obj))...
>
(Continue reading)

Vyacheslav Akhmechet | 2 Jan 2008 15:41
Picon
Gravatar

Re: Render-widget-body for my own widget


Weblocks doesn't process render-widget in with-html. Your example
works because render-widget is defined for strings (for convenience),
so that you could add a string to the widget tree and have the system
render it. The same is true for functions.

Regards,
Slava Akhmechet.

On Jan 2, 2008 1:27 AM, Joubert <joubert.nel@...> wrote:
>
> Hi Sohail,
>
> STR also works.
>
> I haven't looked at the source code yet, but I wonder whether the
> weblocks WITH-HTML form actually processes the RENDER-WIDGET form
> before handing over work to CL-WHO's WITH-HTML-OUTPUT, because RENDER-
> WIDGET works even though CL-WHO has no knowledge of it.
>
> Joubert
>
>
> On Jan 2, 1:10 am, Sohail Somani <soh...@...> wrote:
> > On Tue, 01 Jan 2008 21:20:58 -0800, Joubert wrote:
> >
> > [snip too much, no undo wtf?]
> >
> > > ------------------------
> > > (defmethod render-widget-body ((obj linkwidget) &rest args)
(Continue reading)

Joubert | 3 Jan 2008 00:02
Picon
Gravatar

Re: Render-widget-body for my own widget


Hello Slava,

On Jan 2, 9:41 am, "Vyacheslav Akhmechet" <coffee...@...> wrote:
> Weblocks doesn't process render-widget in with-html. Your example
> works because render-widget is defined for strings (for convenience),
> so that you could add a string to the widget tree and have the system
> render it. The same is true for functions.

Why does the RENDER-WIDGET form inside a WITH-HTML form work but calls
to other functions don't?

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

Vyacheslav Akhmechet | 3 Jan 2008 01:58
Picon
Gravatar

Re: Render-widget-body for my own widget


On 1/2/08, Joubert <joubert.nel@...> wrote:
> Why does the RENDER-WIDGET form inside a WITH-HTML form work but calls
> to other functions don't?
Calls to other functions work in with-html. You expected the macro to
automatically render the return value of the function, but cl-who
doesn't do that, you need to wrap the call in STR for that. The
function itself, however, gets called. When you use render-widget, its
return value also doesn't get rendered, but internally render-widget
renders its argument (the string) itself. This is why it seems like
render-widget works but other functions don't.

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

Sohail Somani | 3 Jan 2008 02:30
Gravatar

Re: Render-widget-body for my own widget


On Wed, 02 Jan 2008 19:58:29 -0500, Vyacheslav Akhmechet wrote:

> When you use render-widget, its return value also doesn't get rendered,
> but internally render-widget renders its argument (the string) itself.
> This is why it seems like render-widget works but other functions don't.

Ooh... That might be evil. What if the compiler reordered things?

Are my C++ roots showing?

--

-- 
Sohail Somani
http://uint32t.blogspot.com

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

Vyacheslav Akhmechet | 3 Jan 2008 04:56
Picon
Gravatar

Re: Render-widget-body for my own widget


On 1/2/08, Sohail Somani <sohail@...> wrote:
> Ooh... That might be evil. What if the compiler reordered things?
How is this different from the compiler reordering any other two
expressions that have side effects? This would be a bug in the
compiler...

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

Sohail Somani | 3 Jan 2008 05:31
Gravatar

Re: Render-widget-body for my own widget


On Wed, 02 Jan 2008 22:56:39 -0500, Vyacheslav Akhmechet wrote:

> On 1/2/08, Sohail Somani
> <sohail@...> wrote:
>> Ooh... That might be evil. What if the compiler reordered things?
> How is this different from the compiler reordering any other two
> expressions that have side effects? This would be a bug in the
> compiler...

It seems that with-html makes the execution sequential using progn 
anyway. I was thinking along the lines of:

(concatenate (foo) (bar))

--

-- 
Sohail Somani
http://uint32t.blogspot.com

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

Vyacheslav Akhmechet | 3 Jan 2008 05:39
Picon
Gravatar

Re: Render-widget-body for my own widget


I see. Even that has a guranteed evaluation order in Common Lisp (left
to right). You're probably thinking Scheme...

On 1/2/08, Sohail Somani <sohail@...> wrote:
>
> On Wed, 02 Jan 2008 22:56:39 -0500, Vyacheslav Akhmechet wrote:
>
> > On 1/2/08, Sohail Somani
> > <sohail@...> wrote:
> >> Ooh... That might be evil. What if the compiler reordered things?
> > How is this different from the compiler reordering any other two
> > expressions that have side effects? This would be a bug in the
> > compiler...
>
> It seems that with-html makes the execution sequential using progn
> anyway. I was thinking along the lines of:
>
> (concatenate (foo) (bar))
>
> --
> Sohail Somani
> http://uint32t.blogspot.com
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "weblocks" group.
(Continue reading)


Gmane