ToscaWidgets

0 views
Skip to first unread message

TG-Martin Peschke

unread,
Dec 11, 2006, 10:11:13 PM12/11/06
to TurboGears
I implemented already some TG apps with SO/KID and some original
widgets and some self written ones, like AJAXian DB Grids for our
personal data model.

However now, since we need to implement a generic webapp with is more
focused on speed of development and execution, we chose to go for the
future proof SA/GENSHI versions.

However it is somewhat not easy to start out with SA and GENSHI since
the TG1.0b2 contains the SA bug (import line). And Genshi Documentation
at the moment is sparse at best (but luckily Genshi is so easy and
natural that that can be done anyways).

Now however, Genshi breaks widgets. There have been multiple
discussions around Genshi working with traditional widgets by using the
TRUNK or patching the widgets code. But I want to give ToscaWidgets a
try. If it can do simple round-trip form verification, I will be happy.

Now ToscaWidgets documentation is non-existent, which is well explained
on the website. What I do not understand is, why even the 'tg-sample'
breaks.


The Widgets get displayed as XML and are escaped by both Genshi and
KID. I found no clue as to why and of course they dont work like that.
I tried using KID's XML function which also breaks.

Please take a look at

http://trac.exilante.de:9000/trac/wiki/GenshiQuickStartLog

for details about the simple setup.

What can be done?
Martin

Alberto Valverde

unread,
Dec 12, 2006, 12:02:44 PM12/12/06
to turbo...@googlegroups.com

> Now however, Genshi breaks widgets. There have been multiple
> discussions around Genshi working with traditional widgets by using the
> TRUNK or patching the widgets code. But I want to give ToscaWidgets a
> try. If it can do simple round-trip form verification, I will be happy.

I don't recommend using the widgets in trunk as they will soon be
discontinued in favor of ToscaWidgets for TG 2.0

>
> Now ToscaWidgets documentation is non-existent, which is well explained
> on the website. What I do not understand is, why even the 'tg-sample'
> breaks.
>

tgsample uses kid as a default page template language
"tg.default_view='kid'". Are you sure tgsample breaks untouched? (works
fine in my system). If so, could you please checkout ToscaWidgets from
http://www.turbogears.org/svn/turbogears/projects/ToscaWidgets/trunk
and run "python setup.py test" and send me the results if they fail?

To use genshi as a default page template language you need to add a genshi
master.html and sitetemplate.html. I'll soon upload an example tg app
using genshi to show how it's done.

Alberto

Alberto Valverde

unread,
Dec 12, 2006, 12:49:29 PM12/12/06
to turbo...@googlegroups.com
I've just comitted a sample TG app using genshi as page template language
here:

http://tinyurl.com/y9tyvh

Please upgrade both the forms and core packages by:

easy_install -U ToscaWidgets
easy_install -U ToscaWidgetsForms

Before trying it so we are tuned in the same frequency ;)

The important bits are at:

* start-tgsamplegenshi.py

Where the TurboGears HostFramework object is initialized.

* tgsamplegenshi/config.app.cfg

Where genshi is set as tg.defaultview and options are passed to genshi,
errr, *should* be passed but aren't... looks like a bug in TG.... maybe
http://tinyurl.com/yz5pjk??

* templates/{master,sitetemplate,home}.html

The templates you should XInclude for resources to be included in pages
that need them


Please keep me up with how it goes...

Alberto


Suren

unread,
Dec 13, 2006, 5:03:08 PM12/13/06
to TurboGears
I have tried all that is described here and I am running into a weird
issue. I have myghty installed on my system and I am not sure why that
is getting invoked. Here is the error I get when I try to start python
start-tgsample-genshi.py.

No handlers could be found for logger "toscawidgets.view"
Traceback (most recent call last):
File "start-tgsample_genshi.py", line 30, in ?
from tgsample_genshi.controllers import Root
File
"c:\python24\lib\site-packages\myghty-1.1-py2.4.egg\myghty\importer.py",
line 54, in import_module
return builtin_importer(name, globals, locals, fromlist)
File "c:\Documents and
Settings\slingareddy\workspace\genshiproj\trunk\example
s\tgsample-genshi\tgsample_genshi\controllers.py", line 4, in ?
from tw_samples import AddUserForm
File
"c:\python24\lib\site-packages\myghty-1.1-py2.4.egg\myghty\importer.py",
line 54, in import_module
return builtin_importer(name, globals, locals, fromlist)
ImportError: No module named tw_samples

Suren

unread,
Dec 13, 2006, 5:08:36 PM12/13/06
to TurboGears

TG-Martin Peschke

unread,
Dec 19, 2006, 9:00:04 AM12/19/06
to TurboGears
Alberto, I didnt notice that Google Groups actually put up the post,
since it never updated the whole day back then. Now I'm back to the
question of widgets, since its getting serious now, I have implemented
many Genshi Templates meanwhile and even have to say I can live without
<?python ....?>

But I want to provide now a look-ahead-while-typing text field. So im
just right now at updating the TW installation. Ill be back in some
mins with more info.

TG-Martin Peschke

unread,
Dec 19, 2006, 9:18:32 AM12/19/06
to TurboGears
hmmm, I viewed the sample application, it is stripped down to the bare
bones and I have not checked the TW source, using the vanilla sample,
which should work out of the box (with updated TW rev:2224/TWF
rev:2217)

does break again, this time it breaks while trying to load all the JS
links:

{{{ File ...."\TurboGears-1.0b2-py2.4.egg\turbogears\controllers.py",
line 68, in _process_output
js[script.location].add(script)
KeyError: 'bodybottom'}}}

Alberto Valverde

unread,
Dec 19, 2006, 9:43:24 AM12/19/06
to turbo...@googlegroups.com


This is related to the samples not requiring TW post r2229. There's
been a change on how TG apps load the HostFramework object (now done
by a TG extension and configured in the config file) and the examples
require latest TW.

Try:

easy_install -U ToscaWidgets==dev

As a side note, if latest dev still breaks, would you mind sending me
privately the results of the tests? To run them you'll have to do a
checkout from http://www.turbogears.org/svn/turbogears/projects/
ToscaWidgets/trunk and run "python setup.py test" there.

Thanks for the feedback :)

Alberto

TG-Martin Peschke

unread,
Dec 19, 2006, 8:46:33 PM12/19/06
to TurboGears
Hi Alberto,

the update worked fine (now to TW rev:2235 and the TG App doesnt break
in the sense that it executes without complaining, but the following
source gives you an idea of what I ve been wondering in the first
place:

{{{
<body>
&lt;form id="form" action="save" method="POST"
class="adduserform"&gt;
&lt;input type="hidden" name="id" class="hiddenfield" id="form_id"
value="I'm hidden!"&gt;

&lt;ul class="field_list"&gt;
&lt;li class="even"&gt;
&lt;label id="form_name.label" for="form_name"
class="fieldlabel required"&gt;Name&lt;/label&gt;
&lt;input type="text" name="name" class="textfield
required" id="form_name" value="Your name here"&gt;
&lt;/li&gt;&lt;li class="odd"&gt;

&lt;label id="form_age.label" for="form_age"
class="fieldlabel"&gt;Age&lt;/label&gt;
&lt;select name="age" class="singleselectfield"
id="form_age"&gt;
&lt;option value="0"&gt;0&lt;/option&gt;&lt;option
value="1"&gt;1&lt;/option&gt;&lt;option
value="2"&gt;2&lt;/option&gt;&lt;option
value="3"&gt;3&lt;/option&gt;&lt;option
value="4"&gt;4&lt;/option&gt;&lt;option value="5"&gt;5&lt;/
&lt;/select&gt;
}}}

Its escaped again and much more so this time, it is escaped so heavily
that you have the "&lt;" even in the view.

The tests results in 22 errors and 3 failures, refer to

http://trac.exilante.de:9000/trac/attachment/wiki/GenshiQuickStartLog/error.log

for the output.
I really wonder how this can happen, am I missing some installation
step?

Alberto Valverde

unread,
Dec 20, 2006, 8:07:41 AM12/20/06
to turbo...@googlegroups.com

This is because the display rules are broken. There are two tests
failing from test_genericfunctions.py.

>
> The tests results in 22 errors and 3 failures, refer to
>
> http://trac.exilante.de:9000/trac/attachment/wiki/
> GenshiQuickStartLog/error.log
>
> for the output.
> I really wonder how this can happen, am I missing some installation
> step?

This is something that has bugged others too but I'm not sure yet why
it happens... :( It seems to be related with outdated packages more
precisely RuleDispatch and TurboKid.

TurboKid needs to be at least 0.9.9. You can upgrade it by:

easy_install -U TurboKid>=0.9.9

TW also needs latest RuleDispatch. There are pre-compiled eggs for
windows at http://toscawidgets.org/download. You can upgrade it by:

easy_install -f http://toscawidgets.org/download -U
RuleDispatch>=0.5a0.dev_r2247

Tell me how it goes... :)

Thanks,
Alberto

TG-Martin Peschke

unread,
Dec 21, 2006, 5:33:21 AM12/21/06
to TurboGears
are you sure you mean TurboKid?

Since im using Genshi and TurboKid sounds so Kid dy...

TG-Martin Peschke

unread,
Dec 21, 2006, 5:39:10 AM12/21/06
to TurboGears
I updated both without any change in results. I still think that
TurboKid should not be necessary when I use Genshi, but since time is
running, I will have to abandon the idea of widgets for today and will
have to come back to it later again.

Alberto Valverde

unread,
Dec 21, 2006, 6:47:27 AM12/21/06
to turbo...@googlegroups.com

TurbKid is neccesary for those tests to pass only. I've updated the
requirement so they won't run unless 0.9.9 is present. You dont need
if if using genshi-only widgets.

Can you try upgrading ToscaWidgets and ToscaWidgetsForms again? I've
inluded an explitict pkg_resources.require
("RuleDispatch>=0.5a0.dev_r2247") in genericfunctions.py which should
make sure no older version is used by mistake. At least 3 persons I'm
aware of (counting you) had this problem before and was related to
old requirements being installed.... I'm trying to track why those
are not being upgraded and make the "require" checks more strict to
see if setuptools can handle this automatically... no luck yet... :(

BTW:
I'll be releasing nightly snapshots of TW and related packages (those
that are not available at the cheeseshop) from http://
toscawidgets.org/download so if you're not running from SVN I'd
recommend to update regularily as this is moving fast ATM.

Alberto

Alberto

unread,
Dec 21, 2006, 1:04:19 PM12/21/06
to TurboGears

Gee, I've missed this message and just reading it now... sorry.

tw_samples is in a separate egg I made to factor out the samples to use
in different framework apps. You can install them by:

easy_install -f http://toscawidgets.org/download TWSampleWidgets

Alberto

Reply all
Reply to author
Forward
0 new messages