Re: Using twForms with Pylons. Part 1
On 10/30/07, Mike Orr [EMAIL PROTECTED] wrote: If he objects to python functions in templates like webhelpers' then I don't think he'd like twForms at all either since fields are rendered this way: ${display_child('name')}. In this scenario twForms might not be a good solution. This is an important point. There's a tradeoff between generated forms vs modifying a static form in $GRAPHICAL_HTML_EDITOR. In my office we also have another person who tweaks the HTML and CSS, so I have not decided whether WebHelpers and/or ToscaWidgets will be worth it. It partly depends on which forms the client is willing to accept a standard form look for, vs which forms they'll insist on moving individual controls anywhere, changing the label position, adding text in various spots, etc. I have similar doubts. In theory, you could get full control by copying every TW template to the project's codebase and make sure widgets use our copy. Though it still not as simple as plain templates, since to grok how to tweak some form designer need to look through Python code to find out where the corresponding piece of mako template is stored. -- Max Ischenko http://www.developers.org.ua/ -- Ukrainian software developers community http://maxischenko.in.ua/ -- my blog (Russian) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Using twForms with Pylons. Part 1
On 10/30/07, Ben Bangert [EMAIL PROTECTED] wrote: On Oct 30, 2007, at 6:38 AM, Alberto Valverde wrote: I do believe that this is because FE's UnicodeString.from_python returns a str instead of unicode. I'm not too sure of the rationale behind this but, given that most template languages now expect unicode to be used internally (only encoding when finally rendered), I think FE's from_python should also return unicode. This came up some time ago in FE's list, if you google for toscawidgets and unicodestring in it's archives I'm sure the thread will pop up. Might be my fault, I think I put the first version of the Unicode validator in FE, based on the TG one. I think it was me who submitted UnicodeString validator to TG codebase so I can only blame myself. ;) -- Max Ischenko http://www.developers.org.ua/ -- Ukrainian software developers community http://maxischenko.in.ua/ -- my blog (Russian) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Using twForms with Pylons. Part 1
Ben Bangert wrote: On Oct 30, 2007, at 6:38 AM, Alberto Valverde wrote: I do believe that this is because FE's UnicodeString.from_python returns a str instead of unicode. I'm not too sure of the rationale behind this but, given that most template languages now expect unicode to be used internally (only encoding when finally rendered), I think FE's from_python should also return unicode. This came up some time ago in FE's list, if you google for toscawidgets and unicodestring in it's archives I'm sure the thread will pop up. Might be my fault, I think I put the first version of the Unicode validator in FE, based on the TG one. If he objects to python functions in templates like webhelpers' then I don't think he'd like twForms at all either since fields are rendered this way: ${display_child('name')}. In this scenario twForms might not be a good solution. twForms is a higher-level layer on top of plain html. As with all abstractions, some flexibility is lost in exchange for simplicity. I thought widgets could have their templates overridden? Wasn't that one of the main uses for the Widget browser? Ie, to browse available widgets, their options, and see the templates they come with so you can customize them if needed. Yes, they can be customized but in the case of compound widgets (ie: widgets which display other widgets, like forms) how the rendered children look like is not immediately obvious by seeing the template. For example a template could look like this: form action=$action ... p${display_child('name')}br / {error_for('name'}}/p p${display_child('age')}br //p p${display_child('address')}/p /form In this example address is a fieldset with its address fields but you cannot see it there. Another problem is that the way html attributes for a field are modified is not obvious to a designer well versed in html either: ${display_child('name', size=23, maxlength=100) Keep in mind that tg widgets (twForms' grandma) were originally created to be used by fastdata which tries to be, or will try to be (really hope that someday it becomes!) an alternative to django's admin interface. So, twForms is more geared towards programatically generating forms (introspecting models, etc...) to quickly generate an interface for lots of classes than to creating to-the-pixel forms where design is crucal (ie: a signup form). Mike has articulated this point much better than I did previously in this thread. Not only programatically... for dull forms, I find more pleasant to edit and maintain a form definition twForms' style than by editing html. Alberto --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Using twForms with Pylons. Part 1
Hello Alberto and others, My feedback on trying out twForms following part 1 tutorial. 0. It all worked! 1. middleware configuration step could be optional, since I believe you could do the same with some magic tweaking of .ini file. 2. API docs kind of useless. I have tried pydoc hint, mentioned in the article. pydoc toscawidgets.api gives nothing useful, just like pydoc toscawidgets.widgets and others. I knew for sure that besides ListForm forms there should be other variant but how I am supposed to find it out? pydoc toscawidgets.widgets.forms doesn't mention either ListForm or anything else in particular but gives a useless list of confusing names. Alice down the rabbit hole. ;) 3. FormEncode's UnicodeString validator didn't work, producing ascii error when redisplaying the form. Using TW version did work fine. 4. Is it possible to specify error_handler as a full request path, e.g. /pages/contacts/ instead of attrname of the current obj? The default approach is too inflexible (as is Pylons default, btw) 5. I think fancy fields part could be safely moved to part X document 6. I'd really like to see docs that tell how to control layout of the HTML code produced. You see, I have a great HTML/CSS guy in my team and he is responsible for all HTML/CSS produced by our app. Hence he wants to be in control and b able to easily tweak it. As it is, Python code essentially obscures what's going on underneath. He even objects to web_helpers and so I think twForms magic may be too much to ask. ;) All in all, it seems good. The only thing it needs is IMO better exposure (more users, more use cases, more bugs gets fixed). It may be a good idea to browse excellent docs for Django's newforms - TW competitor. You can steal ideas how to organize/present twForms concepts and may be some design ideas as well. I also contemplate idea to try to port newforms to Pylons, just to see whether it is technically feasible. Max. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Using twForms with Pylons. Part 1
On 10/30/07, Max Ischenko [EMAIL PROTECTED] wrote: It may be a good idea to browse excellent docs for Django's newforms - TW competitor. You can steal ideas how to organize/present twForms concepts and may be some design ideas as well. I also contemplate idea to try to port newforms to Pylons, just to see whether it is technically feasible. On a first look, twForms/newforms roughly equal in size: 1655 lines in django.newforms vs 1262 lines in toscawidgets. Good sign. ;) -- Max Ischenko http://www.developers.org.ua/ -- Ukrainian software developers community http://maxischenko.in.ua/ -- my blog (Russian) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Using twForms with Pylons. Part 1
On Oct 30, 2007, at 6:38 AM, Alberto Valverde wrote: I do believe that this is because FE's UnicodeString.from_python returns a str instead of unicode. I'm not too sure of the rationale behind this but, given that most template languages now expect unicode to be used internally (only encoding when finally rendered), I think FE's from_python should also return unicode. This came up some time ago in FE's list, if you google for toscawidgets and unicodestring in it's archives I'm sure the thread will pop up. Might be my fault, I think I put the first version of the Unicode validator in FE, based on the TG one. If he objects to python functions in templates like webhelpers' then I don't think he'd like twForms at all either since fields are rendered this way: ${display_child('name')}. In this scenario twForms might not be a good solution. twForms is a higher-level layer on top of plain html. As with all abstractions, some flexibility is lost in exchange for simplicity. I thought widgets could have their templates overridden? Wasn't that one of the main uses for the Widget browser? Ie, to browse available widgets, their options, and see the templates they come with so you can customize them if needed. Cheers, Ben smime.p7s Description: S/MIME cryptographic signature
Re: Using twForms with Pylons. Part 1
On 10/30/07, Alberto Valverde [EMAIL PROTECTED] wrote: 1. middleware configuration step could be optional, since I believe you could do the same with some magic tweaking of .ini file. This could be done, TW even exposes a paste.app_filter entrypoint but I don't think it is a good idea to configure TW this way since it's not a configuration option users should be able to modify, let alone disable. It's more or less the same reason why you shouldn't configure Routes' middleware using the .ini file. Settings that must be a certain way in order for the app to function belong in the app. Settings that can be changed by the user to reflect different deployment scenarios belong in the configuration file. Also, in the application you have more flexibility to set non-string values, put middleware in precise locations, etc. I assume Alberto is talking about the configuration's filter-with key, which can wrap a middleware around an application-with-other-middlewares. But (1) outermost is not necessarily the best location for this middleware, (2) the config file is not the easiest way to configure this, and (3) the user should not be able to disable TW or the application will crash. So TW does not belong in the config file. 6. I'd really like to see docs that tell how to control layout of the HTML code produced. You see, I have a great HTML/CSS guy in my team and he is responsible for all HTML/CSS produced by our app. Hence he wants to be in control and b able to easily tweak it. As it is, Python code essentially obscures what's going on underneath. He even objects to web_helpers and so I think twForms magic may be too much to ask. ;) If he objects to python functions in templates like webhelpers' then I don't think he'd like twForms at all either since fields are rendered this way: ${display_child('name')}. In this scenario twForms might not be a good solution. This is an important point. There's a tradeoff between generated forms vs modifying a static form in $GRAPHICAL_HTML_EDITOR. In my office we also have another person who tweaks the HTML and CSS, so I have not decided whether WebHelpers and/or ToscaWidgets will be worth it. It partly depends on which forms the client is willing to accept a standard form look for, vs which forms they'll insist on moving individual controls anywhere, changing the label position, adding text in various spots, etc. -- Mike Orr [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Using twForms with Pylons. Part 1
Thanks for the help Alberto. For the meantime, I've built those troublesome eggs without the C speedups and uploaded them at toscawidgets.org. Can you try installing RuleDispatch before installing twForms/ToscaWidgets like this: easy_install -f http://toscawidgets.org/download/wo_speedups RuleDispatch If it works please report back so I can mention it in the tutorial :) works! Note: easy_install twforms reports its installed, so did not reinstall. On with the tutorial paster serve... gives these deprecation warnings: ../pylons/TWTutorial/twtutorial/controllers/tutorial.py Restarting ../lib/python2.5/site-packages/ToscaWidgets-0.1a2dev_r3534-py2.5.egg/tos cawidgets/genericfunctions.py:171: DeprecationWarning: protocols.advice.add_assignment_advisor is deprecated, please use return add_assignment_advisor(registerMethod,frame=frame) ../lib/python2.5/site-packages/ToscaWidgets-0.1a2dev_r3534-py2.5.egg/tos cawidgets/genericfunctions.py:145: DeprecationWarning: protocols.advice.getFrameInfo is deprecated, please use kind,module,locals_,globals_ = getFrameInfo(frm) ../lib/python2.5/site-packages/ToscaWidgets-0.1a2dev_r3534-py2.5.egg/tos cawidgets/genericfunctions.py:162: DeprecationWarning: protocols.advice.addClassAdvisor is deprecated, please use addClassAdvisor(registerClassSpecificMethod,frame=frm) Starting server in PID 17512. serving on 0.0.0.0:5000 view at http://127.0.0.1:5000 Should not be a problem for now, if I understand correctly. So I continue on. At http://wiki.pylonshq.com/display/toscawidgets/Using+twForms+with+Pylons. +Part+1#id13 I get this error: File '../lib/python2.5/site-packages/Myghty-1.1-py2.5.egg/myghty/importer.py' , line 54 in import_module return builtin_importer(name, globals, locals, fromlist) File '../pylons/TWTutorial/twtutorial/controllers/tutorial.py', line 7 in module class TutorialController(BaseController): File '../pylons/TWTutorial/twtutorial/controllers/tutorial.py', line 16 in TutorialController @validate(form=post_form, error_handler=index) NameError: name 'post_form' is not defined Not sure if this line: @validate(form=post_form, error_handler=index) should have post_form in quotes, or if tutorial.py should have the line from: twtutorial.widgets import post_form either works but then whenever I try and save I always get the 'You must POST to this method, dummy!' msg. :( Note that I'm running this behind a proxy, using 'proxy-prefix' in development.ini. Can't do it on my windows box until I get the sslerror problem figured out. Feedback from a dumb user. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
RE: Using twForms with Pylons. Part 1
I've patched up my windows box and am trying the tutorial but run into the same problem as mentioned in the previous msg, i.e. I reach this stage in the tutorial: http://wiki.pylonshq.com/display/toscawidgets/Using+twForms+with+Pylons. +Part+1#try-it-out and I can't make validation fail, no matter what I do I get a respons of: 'You must POST to this method, dummy!' Is it trying to tell me something? :\ Could complete files for the tutorial be posted so I can compare and see where I'm being a dummy? Or put the complete source in the code 'windows' each time. = Here are a few other misc. notes: - I upgraded python to 2.5 and had to copy a few 2.4 dependencies over: ./ruledispatch-0.5a0.dev_r2247-py2.4-win32.egg ./pyprotocols-1.0a0dev_r2082-py2.4-win32.egg I think this has been mentioned already but myghty is still a dependency, when I didn't have it installed, I got: Starting subprocess with file monitor 14:14:35,075 WARNI [toscawidgets.view] Failed to load 'pylonsmyghty' template engine: Myghty=1.1 Installing myghty removed that msg. - the line post_form = PostForm(post_form) is missing from the 2nd code window of widgets.py - in FireFox the line ${post_form(action=h.url_for(controller='tutorial', action='save'))} below http://wiki.pylonshq.com/display/toscawidgets/Using+twForms+with+Pylons. +Part+1#edit-the-template doesn't display for me. Displays o.k. in I.E. Weird. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Using twForms with Pylons. Part 1
John_Nowlan wrote: I've patched up my windows box and am trying the tutorial but run into the same problem as mentioned in the previous msg, i.e. I reach this stage in the tutorial: http://wiki.pylonshq.com/display/toscawidgets/Using+twForms+with+Pylons. +Part+1#try-it-out and I can't make validation fail, no matter what I do I get a respons of: 'You must POST to this method, dummy!' This is strange... by looking at the rendered HTML, is the action /tutorial/save and the method POST? Are you sure you decorated the save method with validate()? Are you sure that you're importing the validate() decorator from toscawidgets? At the top for your controller module you should have: from toscawidgets.mods.pylonshf import validate *after* from twtutorial.lib.base import * (actually, I'm pretty sure now that this is the problem...) Is it trying to tell me something? :\ I don't think so :) Could complete files for the tutorial be posted so I can compare and see where I'm being a dummy? Good idea, after all... I did write the tutorial myself before writing it :) I've attached it at the howto in Pylons' wiki (too fast I believe since I was planning to move the JS stuff to part2... anyway) Or put the complete source in the code 'windows' each time. I'll take note of this = Here are a few other misc. notes: - I upgraded python to 2.5 and had to copy a few 2.4 dependencies over: ./ruledispatch-0.5a0.dev_r2247-py2.4-win32.egg ./pyprotocols-1.0a0dev_r2082-py2.4-win32.egg Hmm, these shouldn't be neded in 2.5. They're compiled eggs (the win32 at the path) for 2.4 and I don't think they would even link properly in 2.5. I think this has been mentioned already but myghty is still a dependency, when I didn't have it installed, I got: Starting subprocess with file monitor 14:14:35,075 WARNI [toscawidgets.view] Failed to load 'pylonsmyghty' template engine: Myghty=1.1 Installing myghty removed that msg. This is a warning, ignore it for now. I need to make some changes to make it go away (I explain in another recent thread the reason for this) - the line post_form = PostForm(post_form) is missing from the 2nd code window of widgets.py - in FireFox the line ${post_form(action=h.url_for(controller='tutorial', action='save'))} below http://wiki.pylonshq.com/display/toscawidgets/Using+twForms+with+Pylons. +Part+1#edit-the-template BTW, I think we should now move this conversation to the comments in Pylons wiki so others can benefit from it in the future. Thanks for the feedback! Alberto --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
Re: Using twForms with Pylons. Part 1
John_Nowlan wrote: Thanks for the help Alberto. For the meantime, I've built those troublesome eggs without the C speedups and uploaded them at toscawidgets.org. Can you try installing RuleDispatch before installing twForms/ToscaWidgets like this: easy_install -f _http://toscawidgets.org/download/wo_speedups_ RuleDispatch If it works please report back so I can mention it in the tutorial :) works! Great! Note: easy_install twforms reports its installed, so did not reinstall. On with the tutorial paster serve... gives these deprecation warnings: (...) Should not be a problem for now, if I understand correctly. Not a problem, just me lazy :) I should update TW to DecoratorTools' new API... err, well, I'm actually planing to drop that dependecy so that will surely solve it. Nevermind those warnings for now. So I continue on. At _http://wiki.pylonshq.com/display/toscawidgets/Using+twForms+with+Pylons.+Part+1#id13_ I get this error: File '../lib/python2.5/site-packages/Myghty-1.1-py2.5.egg/myghty/importer.py', line 54 in import_module return builtin_importer(name, globals, locals, fromlist) File '../pylons/TWTutorial/twtutorial/controllers/tutorial.py', line 7 in module class TutorialController(BaseController): File '../pylons/TWTutorial/twtutorial/controllers/tutorial.py', line 16 in TutorialController @validate(form=post_form, error_handler=index) NameError: name 'post_form' is not defined Not sure if this line: @validate(form=post_form, error_handler=index) should have post_form in quotes, or if tutorial.py should have the line from: twtutorial.widgets import post_form You should import post_form from twturial.widgets. Maybe I should reword that part so it is clearer... either works but then whenever I try and save I always get the 'You must POST to this method, dummy!' msg. Hmmm, you did decorate the save method, didn't you? :( Note that I'm running this behind a proxy, using 'proxy-prefix' in development.ini. That shouldn't make a difference. I've deployed apps using TW and ProxyPrefix with no problems. Can't do it on my windows box until I get the sslerror problem figured out. I'm pretty sure that has something to do with Paste's http server. You could try narrowing down the problem by trying it with cherrypy's server, in development.ini change your server config so it looks like: [server:main] use = egg:PasteScript#cherrypy port = 5000 ... If this works then you know it has something to do with Paste's server and your system. Though it's weird since I'm pretty sure many people here must be using it in windows... Alberto --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~---
RE: Using twForms with Pylons. Part 1
Just to close out this thread: Success! from toscawidgets.mods.pylonshf import validate *after* from twtutorial.lib.base import * (actually, I'm pretty sure now that this is the problem...) This was the problem. Now works like a charm. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups pylons-discuss group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~--~~~~--~~--~--~--- inline: winmail.dat