Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
FlotWidget - tw.jquery 0.9.4 and tg2b7 - empty
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andrew Basson  
View profile  
 More options Mar 20 2009, 9:05 pm
From: Andrew Basson <andrew.bas...@gmail.com>
Date: Sat, 21 Mar 2009 03:05:54 +0200
Local: Fri, Mar 20 2009 9:05 pm
Subject: FlotWidget - tw.jquery 0.9.4 and tg2b7 - empty
Hi list,

Does anyone have example code of tw.jquery.FlotWidget working with the
versions listed? I only seem to be getting blank pieces of canvas
being rendered on my pages.

I have this in my controller:
...
from tw.jquery import FlotWidget
fw = FlotWidget()
tmpl_context.graphic = fw
...

In my template:
tmpl_context.graphic(data=data)

Here is a paste of the output from the rendered webpage sans a pretty chart.

http://paste.turbogears.org/paste/39329

Using ToscaWidgets-0.9.4 too.

Thanks, Andrew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Basson  
View profile  
 More options Mar 20 2009, 10:32 pm
From: Andrew Basson <andrew.bas...@gmail.com>
Date: Sat, 21 Mar 2009 04:32:57 +0200
Local: Fri, Mar 20 2009 10:32 pm
Subject: Re: FlotWidget - tw.jquery 0.9.4 and tg2b7 - empty
Hi,

With further investigation and editing the output of the rendered
template as a static page and trying to get that to work...

It seems that tw.core.js is escaping the id of the widget and this is
breaking tw.jquery.FlotWidget

Here is a snippet from tw.core.js that shows the escaping behaviour of
the id selector as per the paste above.

class TWEncoder(simplejson.encoder.JSONEncoder):
    """A JSON encoder that can encode Widgets, js_calls, js_symbols and
    js_callbacks.

    Example::

        >>> encode = TWEncoder().encode
        >>> print encode({'onLoad':
js_function("do_something")(js_symbol("this"))})
        {"onLoad": do_something(this)}

        >>> from tw.api import Widget
        >>> w = Widget("foo")
        >>> args = {'onLoad':
js_callback(js_function('jQuery')(w).click(js_symbol('onClick')))}
        >>> print encode(args)
        {"onLoad": function(){jQuery(\\"foo\\").click(onClick)}}
        >>> print encode({'args':args})
        {"args": {"onLoad": function(){jQuery(\\"foo\\").click(onClick)}}}

Although I now know what the problem is, I haven't a clue where to
begin to fix it...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Basson  
View profile  
 More options Mar 20 2009, 10:45 pm
From: Andrew Basson <andrew.bas...@gmail.com>
Date: Sat, 21 Mar 2009 04:45:50 +0200
Local: Fri, Mar 20 2009 10:45 pm
Subject: Re: FlotWidget - tw.jquery 0.9.4 and tg2b7 - empty
Hi,

Ok, I hacked and got a chart...

2009/3/21 Andrew Basson <andrew.bas...@gmail.com>:

> Hi,

>> http://paste.turbogears.org/paste/39329

> With further investigation and editing the output of the rendered
> template as a static page and trying to get that to work...

> It seems that tw.core.js is escaping the id of the widget and this is
> breaking tw.jquery.FlotWidget

> Here is a snippet from tw.core.js that shows the escaping behaviour of
> the id selector as per the paste above.

Ok, so I hacked __get_js_repr on _js_call and put in a replace as per below.

class _js_call(object):
    __slots__ = ('__name', '__call_list', '__args', '__called')

    def __init__(self, name, call_list, args=None, called=False):
        self.__name = name
        self.__args = args
        call_list.append(self)
        self.__call_list = call_list
        self.__called = called

    def __getattr__(self, name):
        return self.__class__(name, self.__call_list)

    def __call__(self, *args):
        self.__args = args
        self.__called = True
        return self

    def __get_js_repr(self):
        if self.__called:
            args = self.__args
            return '%s(%s)' % (self.__name, ', '.join(imap(encode,
args)).replace('\\',''))
        else:
            return self.__name

Don't know what else will break, but for now I'm happy to fall into
bed knowing I can finally produce a chart.

Cheers, Andrew.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »