component-less rendering

10 views
Skip to first unread message

Terrence Brannon

unread,
Apr 24, 2015, 1:52:37 PM4/24/15
to nagare...@googlegroups.com
In the Presentation Tier docs, we see a number of examples of using xhmlt.Renderer() without any component. Motivated by this,
I am attempting to create a renderer for my mixin. That is to say, I
mixin a number of classes into a class and then when I render the
class, I want to render its mixins using each mixins rendeing method. 

Here is the code for one such mixin:

class ValueTyped(object):
    def __init__(self):
        super(ValueTyped, self).__init__()
        self.value_type = ''

    def valuetyped_render(self, editor):
        id_type = {
            '25': 'Timestamp with Jiffies',
            '26': 'Timestamp',
            '32': 'Date'
        }

        h = xhtml.Renderer()

        tp("H..: {0}".format(h))
        tp("H.S: {0}".format(h.select))
        hsr = h.select.renderer
        tp("HSR: {0}".format(hsr))
        hsrc = h.select.renderer.component()
        tp("HSRC {0}".format(hsrc))
        tp("E..: {0}".format(editor))
        tp("EVT: {0}".format(editor.value_type))

        with h.select.action(editor.value_type):
            with h.optgroup(label='xxx'):
                for id,type in id_type.iteritems():
                    h << h.option(type, value=type)

        tp("Returning H_ROOT: {0}".format(h.root))

        return h.root

Now, the problem is that the code breaks on the source line:
   with h.select.action(editor.value_type):

because nagare.namespaces.action() has this line:
   action = security.wrapper(action, permissions, subject or self.renderer.component())

And the part of that line that fails is `self.renderer.component())`

So my question is: 
1. is it wrong for one to create a renderer and not bind a component
to it? 
2. If a renderer needs a component, how will it get one? I attempted
to pass in the component that called this method and that was not
acceptable to lxml because a node realized that it's child was itself.

Sylvain Prat

unread,
Apr 27, 2015, 3:03:04 PM4/27/15
to nagare...@googlegroups.com
Hi,

The philosophy of Nagare is to use components and views, so that you can reuse components & views in different contexts, or wrap them into bigger ones. The presentation tier documentation just illustrates how to use the renderer to create HTML markup in a view of a component. It does not suggest to use the renderer without components. The error you see is because Nagare attaches the callbacks to their underlying component. 

Sylvain 

--
You received this message because you are subscribed to the Google Groups "Nagare users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nagare-users...@googlegroups.com.
To post to this group, send email to nagare...@googlegroups.com.
Visit this group at http://groups.google.com/group/nagare-users.
For more options, visit https://groups.google.com/d/optout.



--
Sylvain PRAT
+33 06 78 71 51 21
Reply all
Reply to author
Forward
0 new messages