[web2py:32655] Re: why doesn't this ajax call work? [RESOLVED -- updated web2py_ajax.html]
On Oct11, 12:24pm, weheh wrote: > > So caveat emptor: if you're working on ajax, make sure your views > folder has an updated version of web2py_ajax.html. > > In general, this may be an issue about releasing newer versions of > web2py because the apps aren't updated automatically. Perhaps the ajax > include should be one level up from apps? Perhaps not. An old app works with old web2py_ajax.html (and its corresponding style.css etc.), but not necessarily with the latest web2py_ajax.html (and its corresponding base.css etc). In other word, web2py_ajax.html and those css and js files are within app level, which means a good thing - they can evolute without affecting old apps, and a bad thing - you need to migrate to latest web2py_ajax.html manually. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32656] Re: SELECT - UTF-8 errors
Your default setting does NOT mean the data you put into db IS utf8. Try digging out what content you inserted chokes. Are they really in utf8? Note that unicode is NOT utf8. Hope this info can give a right direction. On Oct11, 2:39pm, leone wrote: > Yes, I have added .encode('utf8') to my default > > Field('subject','text', default=u''.encode('utf8')), > > On 11 Ott, 01:53, Iceberg wrote: > > > > > On Oct11, 3:42am, leone wrote: > > > > I have same string inserted in a table. > > > When I select them, I debug this error: > > > > File "/xx/xx/web2py/web2py/gluon/sql.py", line 2235, in > > > response > > > return self._db._cursor.fetchall() > > > OperationalError: Could not decode to UTF-8 column 'subject' with text > > > 'x i xxx' > > > > This is a problem of sql.py module. What can I do? > > > Thanks > > > Did you ever try searching "utf8" in this group or in google? That is > > very likely a common utf8 issue. See this. > > >http://groups.google.com/group/web2py/browse_frm/thread/e9bc715d7d10458a --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32657] Re: A simple patch to provide upload progress
Would you post a web2pyslice on this? Massimo On Oct 10, 5:14 pm, AndCycle wrote: > @Massiom > > http://pastebin.com/f69e7b008 > > here is the patch include a working sample, > by the way you got another indent error in copystream_progress :p > > On Oct 11, 3:43 am, mdipierro wrote: > > > @AndCycle > > > I rearranged the code in trunk a bit. Could you check it still works? > > Thanks again. > > > Massimo > > > On Oct 8, 5:14 am, AndCycle wrote: > > > > thanks :) > > > > I will take some free time to write a example base on trunk :p > > > > On Oct 7, 10:24 pm, mdipierro wrote: > > > > > Check again. I added it now. > > > > > On Oct 7, 6:42 am, AndCycle wrote: > > > > > > oops, the patch been cut by width restriction on mailing list lol > > > > > > here is pastebinhttp://pastebin.com/f219d603b --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32658] Re: New slice on Setting up Paypal
I posted a reddit link to the article. I hope it is ok. If you want to have your company listed under the web2py support page, just send me a personal email with some info about it. Massimo On Oct 10, 2:04 am, Benigno wrote: > Hello, > > I have posted a slice on Setting up Paypal with Web2py. You can > find it here: > > http://www.web2pyslices.com/main/slices/take_slice/9 > > I will be posting a better formated document with some images to > better understand it shortly. > > One thing though, this was tested and programmed about 4 months > ago, since then, Paypal has changed some of its APIs it seems, and > some of the message names may have changed or no longer be available. > This should be pretty basic to detect though. > > Best regards, > Benigno. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32659] using a calculation in a requires validator
Hi, I need to do this ( db.field % .25 == 0 ) calculation on a field entered into a form. Do I need to create a function that checks (what?) or can it be entered directly in the db definition? Thanks Michael --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32660] Re: using a calculation in a requires validator
On Oct11, 7:23pm, "Michael - afewtips.com" wrote: > Hi, > I need to do this > > ( db.field % .25 == 0 ) > > calculation on a field entered into a form. > > Do I need to create a function that checks (what?) or can it be > entered directly in the > db definition? > > Thanks > Michael Yes, you can define a function as the onvalidation callback for SQLFORM or for Crud. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32661] Need help with an ajax call
I'm doing an ajax call that returns back a bunch of stuff including html and multiple javascripts. I want the html presented as is and the javascripts evaluated. All of it gets sent to a single target. The call looks like this: DIV(...page-within-a-page with many subdivs and javascripts ...,_id='target') DIV( A(link_text, _href='#', _id=id, _onclick="ajax('get_selection,['%s'],':eval');" % id ), ), The getselection controller looks like this: def get_selection(): selection = db(...).select(...) text = ... open and read a file of text or html ... form = FORM(...) return "jQuery('#target').html(%s);" % get_page(selection,text,form) where get_page builds a complex page-within-a-page with javascript rollover buttons and a javascript-driven control. Problem is, everything is getting evaluated. So any single quotes in the text screw things up. How can this be done so that the text comes out as text and the javascript as an evaluated javascript? Originally, I tried just returning everything as html and stuffing it into the target div, but my javascripts didn't work any more, even though they were declared outside the target div. Can anyone explain why those javascripts wouldn't work after an ajax call and return? I'm a novice ajax user, so any insights into what is going on with the DOM during the ajax calling process would be helpful. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32662] Re: using a calculation in a requires validator
Thanks - I checked the manual more and used: requires=IS_EXPR('float(value) % .25 == 0',error_message=T('Error in value')) But on a similar note, where would I put global functions? add a module with the custom functions? Thanks Michael On Oct 11, 9:44 am, Iceberg wrote: > On Oct11, 7:23pm, "Michael - afewtips.com" wrote: > > > Hi, > > I need to do this > > > ( db.field % .25 == 0 ) > > > calculation on a field entered into a form. > > > Do I need to create a function that checks (what?) or can it be > > entered directly in the > > db definition? > > > Thanks > > Michael > > Yes, you can define a function as the onvalidation callback for > SQLFORM or for Crud. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32663] Re: Need help with an ajax call
It depends on what get_page(selection,text,form) does try one of the following: import gluon.contrib.simplejson as sj return "jQuery('#target').html(%s);" % sj.dumps(str(get_page (selection,text,form))) return "jQuery('#target').html(%s);" % sj.dumps(repr(get_page (selection,text,form))) return "jQuery('#target').html('%s');" % sj.dumps(str(get_page (selection,text,form))) return "jQuery('#target').html('%s');" % sj.dumps(repr(get_page (selection,text,form))) return 'jQuery("#target").html("%s");' % sj.dumps(str(get_page (selection,text,form))) return 'jQuery("#target").html("%s");' % sj.dumps(repr(get_page (selection,text,form))) On Oct 11, 9:08 am, weheh wrote: > I'm doing an ajax call that returns back a bunch of stuff including > html and multiple javascripts. I want the html presented as is and the > javascripts evaluated. All of it gets sent to a single target. > > The call looks like this: > DIV(...page-within-a-page with many subdivs and > javascripts ...,_id='target') > DIV( > A(link_text, > _href='#', > _id=id, > _onclick="ajax('get_selection,['%s'],':eval');" % id > ), > ), > > The getselection controller looks like this: > > def get_selection(): > selection = db(...).select(...) > text = ... open and read a file of text or html ... > form = FORM(...) > return "jQuery('#target').html(%s);" % get_page(selection,text,form) > > where get_page builds a complex page-within-a-page with javascript > rollover buttons and a javascript-driven control. > > Problem is, everything is getting evaluated. So any single quotes in > the text screw things up. How can this be done so that the text comes > out as text and the javascript as an evaluated javascript? > > Originally, I tried just returning everything as html and stuffing it > into the target div, but my javascripts didn't work any more, even > though they were declared outside the target div. Can anyone explain > why those javascripts wouldn't work after an ajax call and return? > > I'm a novice ajax user, so any insights into what is going on with the > DOM during the ajax calling process would be helpful. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32664] Re: How to Change the css style color and text of submit button on a crud.create form in controller
I really like that suggestion, would be much cleaner code and easier to configure different styles that have meaning by variable name On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > I wonder if we could encapsulate, simplify this with a decorator, something > like: > > @button( color='white', background='blue', font='bold' ) > form = crud.create(...) > > Something like this could be useful for something like > > @button( my_admin_style ) > form = crud.create() > > @button( my_warning_style ) > form = ... > > just thinking out loud > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan wrote: > > > > > > > took me a while to dig up the answer/solution, maybe can save someone > > else some time > > > form = crud.create(...) > > form=DIV( > > form, > > SCRIPT('''$(document).ready(function() { > > $("input[type=submit]").val("Share"); > > });'''), > > SCRIPT('''$(document).ready(function() { > > $("input[type=submit]").css({ > > color:'white', > > background:'blue', > > font: 'bold'}); > > });'''), > > ) > > > return dict(form=form)- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32665] Re: How to Change the css style color and text of submit button on a crud.create form in controller
I do not think you cannot use decorators this way. But I remind you crud.create is a function that returns SQLFORM which is a FORM which is a heper as any other helper. Therefore you can do: form = crud.create(...) form['_style']="color:white; background-color:blue; font-weight:bold" On Oct 11, 10:47 am, Web2py-SuperFan wrote: > I really like that suggestion, would be much cleaner code and easier > to configure different styles that have meaning by variable name > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > I wonder if we could encapsulate, simplify this with a decorator, something > > like: > > > @button( color='white', background='blue', font='bold' ) > > form = crud.create(...) > > > Something like this could be useful for something like > > > @button( my_admin_style ) > > form = crud.create() > > > @button( my_warning_style ) > > form = ... > > > just thinking out loud > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan wrote: > > > > took me a while to dig up the answer/solution, maybe can save someone > > > else some time > > > > form = crud.create(...) > > > form=DIV( > > > form, > > > SCRIPT('''$(document).ready(function() { > > > $("input[type=submit]").val("Share"); > > > });'''), > > > SCRIPT('''$(document).ready(function() { > > > $("input[type=submit]").css({ > > > color:'white', > > > background:'blue', > > > font: 'bold'}); > > > });'''), > > > ) > > > > return dict(form=form)- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32666] Re: Need help with an ajax call
Massimo, I tried all your callbacks and none of them can render get_page. I should have noted that get_page is the exact same function that I use to successfully render the sub-page initially when the user clicks on the link that takes them to this particular page. That said, the text portion of get_page is rendered correctly by the following callbacks: return "jQuery('#target').html(%s);" % repr(text) return "jQuery('#target').html(%s);" % sj.dumps(str(text)) and this works, too, but ' is quoted \' return "jQuery('#target').html('%s');" % sj.dumps(repr(text)) I would never have thought to invoke sj.dumps to do the job of rendering the text. I'm curious why this should even work? get_page calls a function show_buttons() that generates the buttons on the page. These are rollover-type buttons with a sharethis button, which is javascript. Taking, the divide and conquer approach to debugging the problem, I also tried the following callbacks, with the results shown as comments below. None of the javascripts worked to render the buttons. return "jQuery('#target').html(%s);" % show_buttons() #fails: error missing } in sharethis javascript return "jQuery('#target').html(%s);" % repr(show_buttons()) #fails: nothing renders, error "missing = in XML attribute" return "jQuery('#target').html(%s);" % sj.dumps(str(show_buttons())) #fails: only sharethis button renders, but sharethis function not defined when you click on the button. None of the css rollover buttons render. And rest of webpage is mysteriously cleared. return "jQuery('#target').html(%s);" % sj.dumps(repr(show_buttons ())) #fails: Nothing renders, but target is cleared. return "jQuery('#target').html('%s');" % sj.dumps(str(show_buttons ())) #fails: nothing renders, error: "missing ) after argument list" return "jQuery('#target').html('%s');" % sj.dumps(repr(show_buttons ())) #fails: renders pair of double quotes "" in target div return 'jQuery("#target").html("%s");' % sj.dumps(str(show_buttons ())) #fails: nothing renders, error: "missing ) after argument list" return 'jQuery("#target").html("%s");' % sj.dumps(repr(show_buttons ())) #fails: nothing renders, error: "missing ) after argument list" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32667] Re: A simple patch to provide upload progress
just to complete the link (I didn't immediately find web2pyslice searching the group): http://www.web2pyslices.com/main/default/index On Sun, Oct 11, 2009 at 2:42 AM, mdipierro wrote: > > Would you post a web2pyslice on this? > > Massimo > > On Oct 10, 5:14 pm, AndCycle wrote: > > @Massiom > > > > http://pastebin.com/f69e7b008 > > > > here is the patch include a working sample, > > by the way you got another indent error in copystream_progress :p > > > > On Oct 11, 3:43 am, mdipierro wrote: > > > > > @AndCycle > > > > > I rearranged the code in trunk a bit. Could you check it still works? > > > Thanks again. > > > > > Massimo > > > > > On Oct 8, 5:14 am, AndCycle wrote: > > > > > > thanks :) > > > > > > I will take some free time to write a example base on trunk :p > > > > > > On Oct 7, 10:24 pm, mdipierro wrote: > > > > > > > Check again. I added it now. > > > > > > > On Oct 7, 6:42 am, AndCycle > wrote: > > > > > > > > oops, the patch been cut by width restriction on mailing list lol > > > > > > > > here is pastebinhttp://pastebin.com/f219d603b > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32668] Re: Need help with an ajax call
I would think that your function, is returning a qoute of some sort, which is canceling out the qoute around .html, which is throwing off the javascript errors. this 'jQuery("#target").html("%s");' % (' this is a strong sentence that breaks the javascript wrote: > > Massimo, I tried all your callbacks and none of them can render > get_page. I should have noted that get_page is the exact same function > that I use to successfully render the sub-page initially when the user > clicks on the link that takes them to this particular page. > > That said, the text portion of get_page is rendered correctly by the > following callbacks: > > return "jQuery('#target').html(%s);" % repr(text) > return "jQuery('#target').html(%s);" % sj.dumps(str(text)) > and this works, too, but ' is quoted \' > return "jQuery('#target').html('%s');" % sj.dumps(repr(text)) > > I would never have thought to invoke sj.dumps to do the job of > rendering the text. I'm curious why this should even work? > > get_page calls a function show_buttons() that generates the buttons on > the page. These are rollover-type buttons with a sharethis button, > which is javascript. Taking, the divide and conquer approach to > debugging the problem, I also tried the following callbacks, with the > results shown as comments below. None of the javascripts worked to > render the buttons. > > return "jQuery('#target').html(%s);" % show_buttons() #fails: error > missing } in sharethis javascript > return "jQuery('#target').html(%s);" % repr(show_buttons()) #fails: > nothing renders, error "missing = in XML attribute" > return "jQuery('#target').html(%s);" % sj.dumps(str(show_buttons())) > #fails: only sharethis button renders, but sharethis function not > defined when you click on the button. None of the css rollover buttons > render. And rest of webpage is mysteriously cleared. > return "jQuery('#target').html(%s);" % sj.dumps(repr(show_buttons > ())) #fails: Nothing renders, but target is cleared. > return "jQuery('#target').html('%s');" % sj.dumps(str(show_buttons > ())) #fails: nothing renders, error: "missing ) after argument list" > return "jQuery('#target').html('%s');" % sj.dumps(repr(show_buttons > ())) #fails: renders pair of double quotes "" in target div > return 'jQuery("#target").html("%s");' % sj.dumps(str(show_buttons > ())) #fails: nothing renders, error: "missing ) after argument list" > return 'jQuery("#target").html("%s");' % sj.dumps(repr(show_buttons > ())) #fails: nothing renders, error: "missing ) after argument list" > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32669] Re: How to Change the css style color and text of submit button on a crud.create form in controller
On Sun, Oct 11, 2009 at 11:04 AM, mdipierro wrote: > > I do not think you cannot use decorators this way. > double negatives not sure what you intended to say (but logical analysis says "... think you can use decorators this way..."); > But I remind you crud.create is a function that returns SQLFORM which > is a FORM which is a heper as any other helper. Therefore you can do: > > form = crud.create(...) > form['_style']="color:white; background-color:blue; font-weight:bold" > Good point - and addresses the original post (as it could have been more simply done this way); Regardless, then @style( color='white', background-color='blue', font-weight='bold') form = crud.create(...) would still be a readable thing (and just trivial to implement); Alternatively, form.style( ...same kinds of parameters) could be used; Anyway, this is about readability, and ease of infding this stuff (as this post shows); If there were a member function to FORM to set style, people who not have to stumble upon it. Thoughts? > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > I really like that suggestion, would be much cleaner code and easier > > to configure different styles that have meaning by variable name > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > I wonder if we could encapsulate, simplify this with a decorator, > something > > > like: > > > > > @button( color='white', background='blue', font='bold' ) > > > form = crud.create(...) > > > > > Something like this could be useful for something like > > > > > @button( my_admin_style ) > > > form = crud.create() > > > > > @button( my_warning_style ) > > > form = ... > > > > > just thinking out loud > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan >wrote: > > > > > > took me a while to dig up the answer/solution, maybe can save someone > > > > else some time > > > > > >form = crud.create(...) > > > >form=DIV( > > > > form, > > > > SCRIPT('''$(document).ready(function() { > > > > $("input[type=submit]").val("Share"); > > > > });'''), > > > > SCRIPT('''$(document).ready(function() { > > > > $("input[type=submit]").css({ > > > > color:'white', > > > > background:'blue', > > > > font: 'bold'}); > > > > });'''), > > > > ) > > > > > > return dict(form=form)- Hide quoted text - > > > > > - Show quoted text - > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32670] Re: Need help with an ajax call
assuming s is valid html you can also try 'jQuery("#target").html("%s");' % s.replace('"','\\"') On Oct 11, 12:04 pm, Thadeus Burgess wrote: > I would think that your function, is returning a qoute of some sort, which > is canceling out the qoute around .html, which is throwing off the > javascript errors. > > this > > 'jQuery("#target").html("%s");' % (' this is a strong > sentence that breaks the javascript > Notice the qoutes where it defines class=. Try changing all double qoutes > to single qoutes, see if that fixes your problem. > > I ran into this as well, and single qoutes in the html fixed my problem. > > -Thadeus > > On Sun, Oct 11, 2009 at 11:33 AM, weheh wrote: > > > Massimo, I tried all your callbacks and none of them can render > > get_page. I should have noted that get_page is the exact same function > > that I use to successfully render the sub-page initially when the user > > clicks on the link that takes them to this particular page. > > > That said, the text portion of get_page is rendered correctly by the > > following callbacks: > > > return "jQuery('#target').html(%s);" % repr(text) > > return "jQuery('#target').html(%s);" % sj.dumps(str(text)) > > and this works, too, but ' is quoted \' > > return "jQuery('#target').html('%s');" % sj.dumps(repr(text)) > > > I would never have thought to invoke sj.dumps to do the job of > > rendering the text. I'm curious why this should even work? > > > get_page calls a function show_buttons() that generates the buttons on > > the page. These are rollover-type buttons with a sharethis button, > > which is javascript. Taking, the divide and conquer approach to > > debugging the problem, I also tried the following callbacks, with the > > results shown as comments below. None of the javascripts worked to > > render the buttons. > > > return "jQuery('#target').html(%s);" % show_buttons() #fails: error > > missing } in sharethis javascript > > return "jQuery('#target').html(%s);" % repr(show_buttons()) #fails: > > nothing renders, error "missing = in XML attribute" > > return "jQuery('#target').html(%s);" % sj.dumps(str(show_buttons())) > > #fails: only sharethis button renders, but sharethis function not > > defined when you click on the button. None of the css rollover buttons > > render. And rest of webpage is mysteriously cleared. > > return "jQuery('#target').html(%s);" % sj.dumps(repr(show_buttons > > ())) #fails: Nothing renders, but target is cleared. > > return "jQuery('#target').html('%s');" % sj.dumps(str(show_buttons > > ())) #fails: nothing renders, error: "missing ) after argument list" > > return "jQuery('#target').html('%s');" % sj.dumps(repr(show_buttons > > ())) #fails: renders pair of double quotes "" in target div > > return 'jQuery("#target").html("%s");' % sj.dumps(str(show_buttons > > ())) #fails: nothing renders, error: "missing ) after argument list" > > return 'jQuery("#target").html("%s");' % sj.dumps(repr(show_buttons > > ())) #fails: nothing renders, error: "missing ) after argument list" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32671] Re: How to Change the css style color and text of submit button on a crud.create form in controller
Sorry the double negative was a mistake. I know you can decorate a function call. I do not think you can define a decorator for an assignment. Massimo On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro wrote: > > > I do not think you cannot use decorators this way. > > double negatives not sure what you intended to say (but logical analysis > says "... think you can use decorators this way..."); > > > But I remind you crud.create is a function that returns SQLFORM which > > is a FORM which is a heper as any other helper. Therefore you can do: > > > form = crud.create(...) > > form['_style']="color:white; background-color:blue; font-weight:bold" > > Good point - and addresses the original post (as it could have been more > simply done this way); > > Regardless, then > > @style( color='white', background-color='blue', font-weight='bold') > form = crud.create(...) > > would still be a readable thing (and just trivial to implement); > > Alternatively, form.style( ...same kinds of parameters) could be used; > > Anyway, this is about readability, and ease of infding this stuff (as this > post shows); > > If there were a member function to FORM to set style, people who not have to > stumble upon it. > > Thoughts? > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > I really like that suggestion, would be much cleaner code and easier > > > to configure different styles that have meaning by variable name > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > I wonder if we could encapsulate, simplify this with a decorator, > > something > > > > like: > > > > > @button( color='white', background='blue', font='bold' ) > > > > form = crud.create(...) > > > > > Something like this could be useful for something like > > > > > @button( my_admin_style ) > > > > form = crud.create() > > > > > @button( my_warning_style ) > > > > form = ... > > > > > just thinking out loud > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan > >wrote: > > > > > > took me a while to dig up the answer/solution, maybe can save someone > > > > > else some time > > > > > > form = crud.create(...) > > > > > form=DIV( > > > > > form, > > > > > SCRIPT('''$(document).ready(function() { > > > > > $("input[type=submit]").val("Share"); > > > > > });'''), > > > > > SCRIPT('''$(document).ready(function() { > > > > > $("input[type=submit]").css({ > > > > > color:'white', > > > > > background:'blue', > > > > > font: 'bold'}); > > > > > });'''), > > > > > ) > > > > > > return dict(form=form)- Hide quoted text - > > > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32672] Re: How to Change the css style color and text of submit button on a crud.create form in controller
>Good point - and addresses the original post (as it could have been more >simply done this way); Not technically since this would affect everything inside the form and not just the submit button. What about a member function 'find' added to XmlComponent or DIV (which I think most helpers inherit from) that allows you to traverse the inner components and return the matching components for given criteria. The pseudo-code might look like this: submit = form.components.find(XML.attribute("type")=="submit")[0] submit['_style'] = "color:white; background-color:blue; font- weight:bold" On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro wrote: > > > I do not think you cannot use decorators this way. > > double negatives not sure what you intended to say (but logical analysis > says "... think you can use decorators this way..."); > > > But I remind you crud.create is a function that returns SQLFORM which > > is a FORM which is a heper as any other helper. Therefore you can do: > > > form = crud.create(...) > > form['_style']="color:white; background-color:blue; font-weight:bold" > > Good point - and addresses the original post (as it could have been more > simply done this way); > > Regardless, then > > @style( color='white', background-color='blue', font-weight='bold') > form = crud.create(...) > > would still be a readable thing (and just trivial to implement); > > Alternatively, form.style( ...same kinds of parameters) could be used; > > Anyway, this is about readability, and ease of infding this stuff (as this > post shows); > > If there were a member function to FORM to set style, people who not have to > stumble upon it. > > Thoughts? > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > I really like that suggestion, would be much cleaner code and easier > > > to configure different styles that have meaning by variable name > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > I wonder if we could encapsulate, simplify this with a decorator, > > something > > > > like: > > > > > @button( color='white', background='blue', font='bold' ) > > > > form = crud.create(...) > > > > > Something like this could be useful for something like > > > > > @button( my_admin_style ) > > > > form = crud.create() > > > > > @button( my_warning_style ) > > > > form = ... > > > > > just thinking out loud > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan > >wrote: > > > > > > took me a while to dig up the answer/solution, maybe can save someone > > > > > else some time > > > > > > form = crud.create(...) > > > > > form=DIV( > > > > > form, > > > > > SCRIPT('''$(document).ready(function() { > > > > > $("input[type=submit]").val("Share"); > > > > > });'''), > > > > > SCRIPT('''$(document).ready(function() { > > > > > $("input[type=submit]").css({ > > > > > color:'white', > > > > > background:'blue', > > > > > font: 'bold'}); > > > > > });'''), > > > > > ) > > > > > > return dict(form=form)- Hide quoted text - > > > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32673] Re: Need help with an ajax call
I will try these suggestions but I doubt they will work as the javascript portions of get_page have both single and double quoted sections that probably can't be replaced without breaking the javascript. What's frustrating about jQuery and javascripted actions in context of web development in general, and in this case, my web2py app, is that they break the DRYness of my code. It seems like I always have to write one set of page-rendering code for the initial page generation, and then another set of html to generate the sub-sections of the page that will be created in response to a javascript event. I really want to render the different sections of the page from the same code at all times. Does anyone have any insights into how to structure your code to be DRY while still being able to pull off a page that can be generated in its entirety by a straight URL call or in pieces by ajax calls that target specific subsections of the page? It assumes a page that has all sorts of different kinds of things, including css widgets, straight html, and javascripts. On Oct 11, 2:02 pm, mdipierro wrote: > assuming s is valid html you can also try > 'jQuery("#target").html("%s");' % s.replace('"','\\"') > > On Oct 11, 12:04 pm, Thadeus Burgess wrote: > > > > > I would think that your function, is returning a qoute of some sort, which > > is canceling out the qoute around .html, which is throwing off the > > javascript errors. > > > this > > > 'jQuery("#target").html("%s");' % (' this is a strong > > sentence that breaks the javascript > > Notice the qoutes where it defines class=. Try changing all double qoutes > > to single qoutes, see if that fixes your problem. > > > I ran into this as well, and single qoutes in the html fixed my problem. > > > -Thadeus > > > On Sun, Oct 11, 2009 at 11:33 AM, weheh wrote: > > > > Massimo, I tried all your callbacks and none of them can render > > > get_page. I should have noted that get_page is the exact same function > > > that I use to successfully render the sub-page initially when the user > > > clicks on the link that takes them to this particular page. > > > > That said, the text portion of get_page is rendered correctly by the > > > following callbacks: > > > > return "jQuery('#target').html(%s);" % repr(text) > > > return "jQuery('#target').html(%s);" % sj.dumps(str(text)) > > > and this works, too, but ' is quoted \' > > > return "jQuery('#target').html('%s');" % sj.dumps(repr(text)) > > > > I would never have thought to invoke sj.dumps to do the job of > > > rendering the text. I'm curious why this should even work? > > > > get_page calls a function show_buttons() that generates the buttons on > > > the page. These are rollover-type buttons with a sharethis button, > > > which is javascript. Taking, the divide and conquer approach to > > > debugging the problem, I also tried the following callbacks, with the > > > results shown as comments below. None of the javascripts worked to > > > render the buttons. > > > > return "jQuery('#target').html(%s);" % show_buttons() #fails: error > > > missing } in sharethis javascript > > > return "jQuery('#target').html(%s);" % repr(show_buttons()) #fails: > > > nothing renders, error "missing = in XML attribute" > > > return "jQuery('#target').html(%s);" % sj.dumps(str(show_buttons())) > > > #fails: only sharethis button renders, but sharethis function not > > > defined when you click on the button. None of the css rollover buttons > > > render. And rest of webpage is mysteriously cleared. > > > return "jQuery('#target').html(%s);" % sj.dumps(repr(show_buttons > > > ())) #fails: Nothing renders, but target is cleared. > > > return "jQuery('#target').html('%s');" % sj.dumps(str(show_buttons > > > ())) #fails: nothing renders, error: "missing ) after argument list" > > > return "jQuery('#target').html('%s');" % sj.dumps(repr(show_buttons > > > ())) #fails: renders pair of double quotes "" in target div > > > return 'jQuery("#target").html("%s");' % sj.dumps(str(show_buttons > > > ())) #fails: nothing renders, error: "missing ) after argument list" > > > return 'jQuery("#target").html("%s");' % sj.dumps(repr(show_buttons > > > ())) #fails: nothing renders, error: "missing ) after argument list"- > > > Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32674] Re: Need help with an ajax call
Massimo's last suggestion should work as it will escape quotes in the output. Have you considered using jQuery.load to populate the subsections? http://docs.jquery.com/Ajax/load#urldatacallback On Oct 11, 1:31 pm, weheh wrote: > I will try these suggestions but I doubt they will work as the > javascript portions of get_page have both single and double quoted > sections that probably can't be replaced without breaking the > javascript. > > What's frustrating about jQuery and javascripted actions in context of > web development in general, and in this case, my web2py app, is that > they break the DRYness of my code. It seems like I always have to > write one set of page-rendering code for the initial page generation, > and then another set of html to generate the sub-sections of the page > that will be created in response to a javascript event. I really want > to render the different sections of the page from the same code at all > times. Does anyone have any insights into how to structure your code > to be DRY while still being able to pull off a page that can be > generated in its entirety by a straight URL call or in pieces by ajax > calls that target specific subsections of the page? It assumes a page > that has all sorts of different kinds of things, including css > widgets, straight html, and javascripts. > > On Oct 11, 2:02 pm, mdipierro wrote: > > > assuming s is valid html you can also try > > 'jQuery("#target").html("%s");' % s.replace('"','\\"') > > > On Oct 11, 12:04 pm, Thadeus Burgess wrote: > > > > I would think that your function, is returning a qoute of some sort, which > > > is canceling out the qoute around .html, which is throwing off the > > > javascript errors. > > > > this > > > > 'jQuery("#target").html("%s");' % (' this is a strong > > > sentence that breaks the javascript > > > Notice the qoutes where it defines class=. Try changing all double qoutes > > > to single qoutes, see if that fixes your problem. > > > > I ran into this as well, and single qoutes in the html fixed my problem. > > > > -Thadeus > > > > On Sun, Oct 11, 2009 at 11:33 AM, weheh > > > wrote: > > > > > Massimo, I tried all your callbacks and none of them can render > > > > get_page. I should have noted that get_page is the exact same function > > > > that I use to successfully render the sub-page initially when the user > > > > clicks on the link that takes them to this particular page. > > > > > That said, the text portion of get_page is rendered correctly by the > > > > following callbacks: > > > > > return "jQuery('#target').html(%s);" % repr(text) > > > > return "jQuery('#target').html(%s);" % sj.dumps(str(text)) > > > > and this works, too, but ' is quoted \' > > > > return "jQuery('#target').html('%s');" % sj.dumps(repr(text)) > > > > > I would never have thought to invoke sj.dumps to do the job of > > > > rendering the text. I'm curious why this should even work? > > > > > get_page calls a function show_buttons() that generates the buttons on > > > > the page. These are rollover-type buttons with a sharethis button, > > > > which is javascript. Taking, the divide and conquer approach to > > > > debugging the problem, I also tried the following callbacks, with the > > > > results shown as comments below. None of the javascripts worked to > > > > render the buttons. > > > > > return "jQuery('#target').html(%s);" % show_buttons() #fails: error > > > > missing } in sharethis javascript > > > > return "jQuery('#target').html(%s);" % repr(show_buttons()) #fails: > > > > nothing renders, error "missing = in XML attribute" > > > > return "jQuery('#target').html(%s);" % sj.dumps(str(show_buttons())) > > > > #fails: only sharethis button renders, but sharethis function not > > > > defined when you click on the button. None of the css rollover buttons > > > > render. And rest of webpage is mysteriously cleared. > > > > return "jQuery('#target').html(%s);" % sj.dumps(repr(show_buttons > > > > ())) #fails: Nothing renders, but target is cleared. > > > > return "jQuery('#target').html('%s');" % sj.dumps(str(show_buttons > > > > ())) #fails: nothing renders, error: "missing ) after argument list" > > > > return "jQuery('#target').html('%s');" % sj.dumps(repr(show_buttons > > > > ())) #fails: renders pair of double quotes "" in target div > > > > return 'jQuery("#target").html("%s");' % sj.dumps(str(show_buttons > > > > ())) #fails: nothing renders, error: "missing ) after argument list" > > > > return 'jQuery("#target").html("%s");' % sj.dumps(repr(show_buttons > > > > ())) #fails: nothing renders, error: "missing ) after argument list"- > > > > Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, vi
[web2py:32675] Re: How to Change the css style color and text of submit button on a crud.create form in controller
It is there already form.element(_type='submit')['_style']="color:white; background- color:blue; font-weight:bold" It only finds the first matching element. On Oct 11, 1:16 pm, "mr.freeze" wrote: > >Good point - and addresses the original post (as it could have been more > >simply done this way); > > Not technically since this would affect everything inside the form and > not just the submit button. What about a member function 'find' added > to XmlComponent or DIV (which I think most helpers inherit from) that > allows you to traverse the inner components and return the matching > components for given criteria. The pseudo-code might look like this: > > submit = form.components.find(XML.attribute("type")=="submit")[0] > submit['_style'] = "color:white; background-color:blue; font- > weight:bold" > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro wrote: > > > > I do not think you cannot use decorators this way. > > > double negatives not sure what you intended to say (but logical analysis > > says "... think you can use decorators this way..."); > > > > But I remind you crud.create is a function that returns SQLFORM which > > > is a FORM which is a heper as any other helper. Therefore you can do: > > > > form = crud.create(...) > > > form['_style']="color:white; background-color:blue; font-weight:bold" > > > Good point - and addresses the original post (as it could have been more > > simply done this way); > > > Regardless, then > > > @style( color='white', background-color='blue', font-weight='bold') > > form = crud.create(...) > > > would still be a readable thing (and just trivial to implement); > > > Alternatively, form.style( ...same kinds of parameters) could be used; > > > Anyway, this is about readability, and ease of infding this stuff (as this > > post shows); > > > If there were a member function to FORM to set style, people who not have to > > stumble upon it. > > > Thoughts? > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > I really like that suggestion, would be much cleaner code and easier > > > > to configure different styles that have meaning by variable name > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > I wonder if we could encapsulate, simplify this with a decorator, > > > something > > > > > like: > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > form = crud.create(...) > > > > > > Something like this could be useful for something like > > > > > > @button( my_admin_style ) > > > > > form = crud.create() > > > > > > @button( my_warning_style ) > > > > > form = ... > > > > > > just thinking out loud > > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan > > >wrote: > > > > > > > took me a while to dig up the answer/solution, maybe can save > > > > > > someone > > > > > > else some time > > > > > > > form = crud.create(...) > > > > > > form=DIV( > > > > > > form, > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > $("input[type=submit]").val("Share"); > > > > > > });'''), > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > $("input[type=submit]").css({ > > > > > > color:'white', > > > > > > background:'blue', > > > > > > font: 'bold'}); > > > > > > });'''), > > > > > > ) > > > > > > > return dict(form=form)- Hide quoted text - > > > > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32676] Re: Need help with an ajax call
I was hoping to not have to get into the details of jQuery but I'm coming to the conclusion that I'm going to have to do so. So, no, I haven't considered using jQuery.load. But thanks for the pointer and thanks, all, for the responses so far. On Oct 11, 2:38 pm, "mr.freeze" wrote: > Massimo's last suggestion should work as it will escape quotes in the > output. Have you considered using jQuery.load to populate the > subsections?http://docs.jquery.com/Ajax/load#urldatacallback > > On Oct 11, 1:31 pm, weheh wrote: > > > > > I will try these suggestions but I doubt they will work as the > > javascript portions of get_page have both single and double quoted > > sections that probably can't be replaced without breaking the > > javascript. > > > What's frustrating about jQuery and javascripted actions in context of > > web development in general, and in this case, my web2py app, is that > > they break the DRYness of my code. It seems like I always have to > > write one set of page-rendering code for the initial page generation, > > and then another set of html to generate the sub-sections of the page > > that will be created in response to a javascript event. I really want > > to render the different sections of the page from the same code at all > > times. Does anyone have any insights into how to structure your code > > to be DRY while still being able to pull off a page that can be > > generated in its entirety by a straight URL call or in pieces by ajax > > calls that target specific subsections of the page? It assumes a page > > that has all sorts of different kinds of things, including css > > widgets, straight html, and javascripts. > > > On Oct 11, 2:02 pm, mdipierro wrote: > > > > assuming s is valid html you can also try > > > 'jQuery("#target").html("%s");' % s.replace('"','\\"') > > > > On Oct 11, 12:04 pm, Thadeus Burgess wrote: > > > > > I would think that your function, is returning a qoute of some sort, > > > > which > > > > is canceling out the qoute around .html, which is throwing off the > > > > javascript errors. > > > > > this > > > > > 'jQuery("#target").html("%s");' % (' this is a strong > > > > sentence that breaks the javascript > > > > Notice the qoutes where it defines class=. Try changing all double > > > > qoutes > > > > to single qoutes, see if that fixes your problem. > > > > > I ran into this as well, and single qoutes in the html fixed my problem. > > > > > -Thadeus > > > > > On Sun, Oct 11, 2009 at 11:33 AM, weheh > > > > wrote: > > > > > > Massimo, I tried all your callbacks and none of them can render > > > > > get_page. I should have noted that get_page is the exact same function > > > > > that I use to successfully render the sub-page initially when the user > > > > > clicks on the link that takes them to this particular page. > > > > > > That said, the text portion of get_page is rendered correctly by the > > > > > following callbacks: > > > > > > return "jQuery('#target').html(%s);" % repr(text) > > > > > return "jQuery('#target').html(%s);" % sj.dumps(str(text)) > > > > > and this works, too, but ' is quoted \' > > > > > return "jQuery('#target').html('%s');" % sj.dumps(repr(text)) > > > > > > I would never have thought to invoke sj.dumps to do the job of > > > > > rendering the text. I'm curious why this should even work? > > > > > > get_page calls a function show_buttons() that generates the buttons on > > > > > the page. These are rollover-type buttons with a sharethis button, > > > > > which is javascript. Taking, the divide and conquer approach to > > > > > debugging the problem, I also tried the following callbacks, with the > > > > > results shown as comments below. None of the javascripts worked to > > > > > render the buttons. > > > > > > return "jQuery('#target').html(%s);" % show_buttons() #fails: error > > > > > missing } in sharethis javascript > > > > > return "jQuery('#target').html(%s);" % repr(show_buttons()) #fails: > > > > > nothing renders, error "missing = in XML attribute" > > > > > return "jQuery('#target').html(%s);" % sj.dumps(str(show_buttons())) > > > > > #fails: only sharethis button renders, but sharethis function not > > > > > defined when you click on the button. None of the css rollover buttons > > > > > render. And rest of webpage is mysteriously cleared. > > > > > return "jQuery('#target').html(%s);" % sj.dumps(repr(show_buttons > > > > > ())) #fails: Nothing renders, but target is cleared. > > > > > return "jQuery('#target').html('%s');" % sj.dumps(str(show_buttons > > > > > ())) #fails: nothing renders, error: "missing ) after argument list" > > > > > return "jQuery('#target').html('%s');" % sj.dumps(repr(show_buttons > > > > > ())) #fails: renders pair of double quotes "" in target div > > > > > return 'jQuery("#target").html("%s");' % sj.dumps(str(show_buttons > > > > > ())) #fails: nothing renders, error: "missing ) after argument list" > > > > > return 'jQuery("#target").html("%s");' % sj.dumps(repr(show_butto
[web2py:32677] Re: Need help with an ajax call
What about using response.render() to create the html? This way you just have to write your html in your views? return """ jQuery("#target").html("%s"); """ % (response.render(form=form).replace('"','\\"')) -Thadeus On Sun, Oct 11, 2009 at 1:38 PM, mr.freeze wrote: > > Massimo's last suggestion should work as it will escape quotes in the > output. Have you considered using jQuery.load to populate the > subsections? http://docs.jquery.com/Ajax/load#urldatacallback > > > On Oct 11, 1:31 pm, weheh wrote: > > I will try these suggestions but I doubt they will work as the > > javascript portions of get_page have both single and double quoted > > sections that probably can't be replaced without breaking the > > javascript. > > > > What's frustrating about jQuery and javascripted actions in context of > > web development in general, and in this case, my web2py app, is that > > they break the DRYness of my code. It seems like I always have to > > write one set of page-rendering code for the initial page generation, > > and then another set of html to generate the sub-sections of the page > > that will be created in response to a javascript event. I really want > > to render the different sections of the page from the same code at all > > times. Does anyone have any insights into how to structure your code > > to be DRY while still being able to pull off a page that can be > > generated in its entirety by a straight URL call or in pieces by ajax > > calls that target specific subsections of the page? It assumes a page > > that has all sorts of different kinds of things, including css > > widgets, straight html, and javascripts. > > > > On Oct 11, 2:02 pm, mdipierro wrote: > > > > > assuming s is valid html you can also try > > > 'jQuery("#target").html("%s");' % s.replace('"','\\"') > > > > > On Oct 11, 12:04 pm, Thadeus Burgess wrote: > > > > > > I would think that your function, is returning a qoute of some sort, > which > > > > is canceling out the qoute around .html, which is throwing off the > > > > javascript errors. > > > > > > this > > > > > > 'jQuery("#target").html("%s");' % (' this is a > strong > > > > sentence that breaks the javascript > > > > > Notice the qoutes where it defines class=. Try changing all double > qoutes > > > > to single qoutes, see if that fixes your problem. > > > > > > I ran into this as well, and single qoutes in the html fixed my > problem. > > > > > > -Thadeus > > > > > > On Sun, Oct 11, 2009 at 11:33 AM, weheh > wrote: > > > > > > > Massimo, I tried all your callbacks and none of them can render > > > > > get_page. I should have noted that get_page is the exact same > function > > > > > that I use to successfully render the sub-page initially when the > user > > > > > clicks on the link that takes them to this particular page. > > > > > > > That said, the text portion of get_page is rendered correctly by > the > > > > > following callbacks: > > > > > > > return "jQuery('#target').html(%s);" % repr(text) > > > > > return "jQuery('#target').html(%s);" % sj.dumps(str(text)) > > > > > and this works, too, but ' is quoted \' > > > > > return "jQuery('#target').html('%s');" % sj.dumps(repr(text)) > > > > > > > I would never have thought to invoke sj.dumps to do the job of > > > > > rendering the text. I'm curious why this should even work? > > > > > > > get_page calls a function show_buttons() that generates the buttons > on > > > > > the page. These are rollover-type buttons with a sharethis button, > > > > > which is javascript. Taking, the divide and conquer approach to > > > > > debugging the problem, I also tried the following callbacks, with > the > > > > > results shown as comments below. None of the javascripts worked to > > > > > render the buttons. > > > > > > > return "jQuery('#target').html(%s);" % show_buttons() #fails: > error > > > > > missing } in sharethis javascript > > > > > return "jQuery('#target').html(%s);" % repr(show_buttons()) > #fails: > > > > > nothing renders, error "missing = in XML attribute" > > > > > return "jQuery('#target').html(%s);" % > sj.dumps(str(show_buttons())) > > > > > #fails: only sharethis button renders, but sharethis function not > > > > > defined when you click on the button. None of the css rollover > buttons > > > > > render. And rest of webpage is mysteriously cleared. > > > > > return "jQuery('#target').html(%s);" % sj.dumps(repr(show_buttons > > > > > ())) #fails: Nothing renders, but target is cleared. > > > > > return "jQuery('#target').html('%s');" % sj.dumps(str(show_buttons > > > > > ())) #fails: nothing renders, error: "missing ) after argument > list" > > > > > return "jQuery('#target').html('%s');" % > sj.dumps(repr(show_buttons > > > > > ())) #fails: renders pair of double quotes "" in target div > > > > > return 'jQuery("#target").html("%s");' % sj.dumps(str(show_buttons > > > > > ())) #fails: nothing renders, error: "missing ) after argument > list" > > > > > return 'jQuery("#target").html("%s"
[web2py:32678] Re: How to Change the css style color and text of submit button on a crud.create form in controller
Nice! This would be doubly handy if it returned all matching components (jQuery style). What about adding a first=True arg to make return all matches optional ? (or some other more graceful solution that I'm sure you've already thought of before finishing this sentence :) def element(self, first=True, **kargs): components = copy.copy(self.components) matches = [] for c in components: try: components += copy.copy(c.components) check = True for (key, value) in kargs.items(): if c[key] != value: check = False if check: if first: return c else: matches.append(c) except: pass if len(matches): return matches return None On Oct 11, 2:04 pm, mdipierro wrote: > It is there already > > form.element(_type='submit')['_style']="color:white; background- > color:blue; font-weight:bold" > > It only finds the first matching element. > > On Oct 11, 1:16 pm, "mr.freeze" wrote: > > > >Good point - and addresses the original post (as it could have been more > > >simply done this way); > > > Not technically since this would affect everything inside the form and > > not just the submit button. What about a member function 'find' added > > to XmlComponent or DIV (which I think most helpers inherit from) that > > allows you to traverse the inner components and return the matching > > components for given criteria. The pseudo-code might look like this: > > > submit = form.components.find(XML.attribute("type")=="submit")[0] > > submit['_style'] = "color:white; background-color:blue; font- > > weight:bold" > > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro > > > wrote: > > > > > I do not think you cannot use decorators this way. > > > > double negatives not sure what you intended to say (but logical > > > analysis > > > says "... think you can use decorators this way..."); > > > > > But I remind you crud.create is a function that returns SQLFORM which > > > > is a FORM which is a heper as any other helper. Therefore you can do: > > > > > form = crud.create(...) > > > > form['_style']="color:white; background-color:blue; font-weight:bold" > > > > Good point - and addresses the original post (as it could have been more > > > simply done this way); > > > > Regardless, then > > > > @style( color='white', background-color='blue', font-weight='bold') > > > form = crud.create(...) > > > > would still be a readable thing (and just trivial to implement); > > > > Alternatively, form.style( ...same kinds of parameters) could be > > > used; > > > > Anyway, this is about readability, and ease of infding this stuff (as this > > > post shows); > > > > If there were a member function to FORM to set style, people who not have > > > to > > > stumble upon it. > > > > Thoughts? > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > > I really like that suggestion, would be much cleaner code and easier > > > > > to configure different styles that have meaning by variable name > > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > > I wonder if we could encapsulate, simplify this with a decorator, > > > > something > > > > > > like: > > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > > form = crud.create(...) > > > > > > > Something like this could be useful for something like > > > > > > > @button( my_admin_style ) > > > > > > form = crud.create() > > > > > > > @button( my_warning_style ) > > > > > > form = ... > > > > > > > just thinking out loud > > > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan > > > > > > > > > >wrote: > > > > > > > > took me a while to dig up the answer/solution, maybe can save > > > > > > > someone > > > > > > > else some time > > > > > > > > form = crud.create(...) > > > > > > > form=DIV( > > > > > > > form, > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > $("input[type=submit]").val("Share"); > > > > > > > });'''), > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > $("input[type=submit]").css({ > > > > > > > color:'white', > > > > > > > background:'blue', > > > > > > > font: 'bold'}); > > > > > > > });'''), > > > > > > > ) > > > > > > > > return dict(form=form)- Hide quoted text - > > > > > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~
[web2py:32679] Re: How to Change the css style color and text of submit button on a crud.create form in controller
What is wrong with using a .css file? -Thadeus On Sun, Oct 11, 2009 at 2:04 PM, mdipierro wrote: > > It is there already > > form.element(_type='submit')['_style']="color:white; background- > color:blue; font-weight:bold" > > It only finds the first matching element. > > On Oct 11, 1:16 pm, "mr.freeze" wrote: > > >Good point - and addresses the original post (as it could have been more > > >simply done this way); > > > > Not technically since this would affect everything inside the form and > > not just the submit button. What about a member function 'find' added > > to XmlComponent or DIV (which I think most helpers inherit from) that > > allows you to traverse the inner components and return the matching > > components for given criteria. The pseudo-code might look like this: > > > > submit = form.components.find(XML.attribute("type")=="submit")[0] > > submit['_style'] = "color:white; background-color:blue; font- > > weight:bold" > > > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro > wrote: > > > > > > I do not think you cannot use decorators this way. > > > > > double negatives not sure what you intended to say (but logical > analysis > > > says "... think you can use decorators this way..."); > > > > > > But I remind you crud.create is a function that returns SQLFORM > which > > > > is a FORM which is a heper as any other helper. Therefore you can do: > > > > > > form = crud.create(...) > > > > form['_style']="color:white; background-color:blue; font-weight:bold" > > > > > Good point - and addresses the original post (as it could have been > more > > > simply done this way); > > > > > Regardless, then > > > > > @style( color='white', background-color='blue', font-weight='bold') > > > form = crud.create(...) > > > > > would still be a readable thing (and just trivial to implement); > > > > > Alternatively, form.style( ...same kinds of parameters) could be > used; > > > > > Anyway, this is about readability, and ease of infding this stuff (as > this > > > post shows); > > > > > If there were a member function to FORM to set style, people who not > have to > > > stumble upon it. > > > > > Thoughts? > > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > > I really like that suggestion, would be much cleaner code and > easier > > > > > to configure different styles that have meaning by variable name > > > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > > > I wonder if we could encapsulate, simplify this with a decorator, > > > > something > > > > > > like: > > > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > > form = crud.create(...) > > > > > > > > Something like this could be useful for something like > > > > > > > > @button( my_admin_style ) > > > > > > form = crud.create() > > > > > > > > @button( my_warning_style ) > > > > > > form = ... > > > > > > > > just thinking out loud > > > > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan < > mwkan...@gmail.com > > > > >wrote: > > > > > > > > > took me a while to dig up the answer/solution, maybe can save > someone > > > > > > > else some time > > > > > > > > >form = crud.create(...) > > > > > > >form=DIV( > > > > > > > form, > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > $("input[type=submit]").val("Share"); > > > > > > > });'''), > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > $("input[type=submit]").css({ > > > > > > > color:'white', > > > > > > > background:'blue', > > > > > > > font: 'bold'}); > > > > > > > });'''), > > > > > > > ) > > > > > > > > > return dict(form=form)- Hide quoted text - > > > > > > > > - Show quoted text - > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32680] Re: How to Change the css style color and text of submit button on a crud.create form in controller
I think CSS is definitely the best way if you don't need this level of dynamism and know all of the necessary selectors ahead of time. But if you wanted to style a form based on a runtime variable (auth membership for example), or manipulate the form in any other way for that matter, I think this is useful. On Oct 11, 2:39 pm, Thadeus Burgess wrote: > What is wrong with using a .css file? > > -Thadeus > > On Sun, Oct 11, 2009 at 2:04 PM, mdipierro wrote: > > > It is there already > > > form.element(_type='submit')['_style']="color:white; background- > > color:blue; font-weight:bold" > > > It only finds the first matching element. > > > On Oct 11, 1:16 pm, "mr.freeze" wrote: > > > >Good point - and addresses the original post (as it could have been more > > > >simply done this way); > > > > Not technically since this would affect everything inside the form and > > > not just the submit button. What about a member function 'find' added > > > to XmlComponent or DIV (which I think most helpers inherit from) that > > > allows you to traverse the inner components and return the matching > > > components for given criteria. The pseudo-code might look like this: > > > > submit = form.components.find(XML.attribute("type")=="submit")[0] > > > submit['_style'] = "color:white; background-color:blue; font- > > > weight:bold" > > > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro > > wrote: > > > > > > I do not think you cannot use decorators this way. > > > > > double negatives not sure what you intended to say (but logical > > analysis > > > > says "... think you can use decorators this way..."); > > > > > > But I remind you crud.create is a function that returns SQLFORM > > which > > > > > is a FORM which is a heper as any other helper. Therefore you can do: > > > > > > form = crud.create(...) > > > > > form['_style']="color:white; background-color:blue; font-weight:bold" > > > > > Good point - and addresses the original post (as it could have been > > more > > > > simply done this way); > > > > > Regardless, then > > > > > @style( color='white', background-color='blue', font-weight='bold') > > > > form = crud.create(...) > > > > > would still be a readable thing (and just trivial to implement); > > > > > Alternatively, form.style( ...same kinds of parameters) could be > > used; > > > > > Anyway, this is about readability, and ease of infding this stuff (as > > this > > > > post shows); > > > > > If there were a member function to FORM to set style, people who not > > have to > > > > stumble upon it. > > > > > Thoughts? > > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > > > I really like that suggestion, would be much cleaner code and > > easier > > > > > > to configure different styles that have meaning by variable name > > > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > > > I wonder if we could encapsulate, simplify this with a decorator, > > > > > something > > > > > > > like: > > > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > > > form = crud.create(...) > > > > > > > > Something like this could be useful for something like > > > > > > > > @button( my_admin_style ) > > > > > > > form = crud.create() > > > > > > > > @button( my_warning_style ) > > > > > > > form = ... > > > > > > > > just thinking out loud > > > > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan < > > mwkan...@gmail.com > > > > > >wrote: > > > > > > > > > took me a while to dig up the answer/solution, maybe can save > > someone > > > > > > > > else some time > > > > > > > > > form = crud.create(...) > > > > > > > > form=DIV( > > > > > > > > form, > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > $("input[type=submit]").val("Share"); > > > > > > > > });'''), > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > $("input[type=submit]").css({ > > > > > > > > color:'white', > > > > > > > > background:'blue', > > > > > > > > font: 'bold'}); > > > > > > > > });'''), > > > > > > > > ) > > > > > > > > > return dict(form=form)- Hide quoted text - > > > > > > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32681] .with_alias(..) not working (even in the dog.father, dog.mother example form slides)
Hi Everyone, I'm using web2py Version 1.67.2 (2009-09-28 16:29:33) with MySQL and when I execute a following example I get an error. in db.py: db.define_table("dog", SQLField("name"), SQLField("father_id", "reference dog"), SQLField("mother_id", "reference dog")) in index(): father=db.dog.with_alias("father") mother=db.dog.with_alias("mother") rows = db().select(db.dog.name, db.father.name, db.mother.name, left=(db.father.on (db.father.id==db.dog.father_id), db.mother.on(db.mother.id==db.dog.mother_id))) I get an error: ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN dog ON dog.id=dog.father_id LEFT JOIN dog ON dog.id=dog.mother_id' at line 1") In fact the _select(...) on the query returns the following sql: 'SELECT dog.name, dog.name, dog.name FROM LEFT JOIN dog ON dog.id=dog.father_id LEFT JOIN dog ON dog.id=dog.mother_id;' which does not have aliases inside?!? I found this problem in my installation after trying to write my own query using with_alias, and failed (I was getting queries without aliases, that is: all aliases were the same original table in SQL) Does anybody have a clue what might be going on here? Is it only me, or the latest version of web2py? (I had the same with 1.66, upgraded and still same problem) Thanks, m --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32682] Re: How to Change the css style color and text of submit button on a crud.create form in controller
I would take a patch that defines elements (notice the -s) that returns all matching elements. On Oct 11, 2:36 pm, "mr.freeze" wrote: > Nice! This would be doubly handy if it returned all matching > components (jQuery style). What about adding a first=True arg to make > return all matches optional ? (or some other more graceful solution > that I'm sure you've already thought of before finishing this > sentence :) > > def element(self, first=True, **kargs): > components = copy.copy(self.components) > matches = [] > for c in components: > try: > components += copy.copy(c.components) > check = True > for (key, value) in kargs.items(): > if c[key] != value: > check = False > if check: > if first: > return c > else: > matches.append(c) > except: > pass > > if len(matches): return matches > return None > > On Oct 11, 2:04 pm, mdipierro wrote: > > > It is there already > > > form.element(_type='submit')['_style']="color:white; background- > > color:blue; font-weight:bold" > > > It only finds the first matching element. > > > On Oct 11, 1:16 pm, "mr.freeze" wrote: > > > > >Good point - and addresses the original post (as it could have been more > > > >simply done this way); > > > > Not technically since this would affect everything inside the form and > > > not just the submit button. What about a member function 'find' added > > > to XmlComponent or DIV (which I think most helpers inherit from) that > > > allows you to traverse the inner components and return the matching > > > components for given criteria. The pseudo-code might look like this: > > > > submit = form.components.find(XML.attribute("type")=="submit")[0] > > > submit['_style'] = "color:white; background-color:blue; font- > > > weight:bold" > > > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro > > > > wrote: > > > > > > I do not think you cannot use decorators this way. > > > > > double negatives not sure what you intended to say (but logical > > > > analysis > > > > says "... think you can use decorators this way..."); > > > > > > But I remind you crud.create is a function that returns SQLFORM which > > > > > is a FORM which is a heper as any other helper. Therefore you can do: > > > > > > form = crud.create(...) > > > > > form['_style']="color:white; background-color:blue; font-weight:bold" > > > > > Good point - and addresses the original post (as it could have been more > > > > simply done this way); > > > > > Regardless, then > > > > > @style( color='white', background-color='blue', font-weight='bold') > > > > form = crud.create(...) > > > > > would still be a readable thing (and just trivial to implement); > > > > > Alternatively, form.style( ...same kinds of parameters) could be > > > > used; > > > > > Anyway, this is about readability, and ease of infding this stuff (as > > > > this > > > > post shows); > > > > > If there were a member function to FORM to set style, people who not > > > > have to > > > > stumble upon it. > > > > > Thoughts? > > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > > > I really like that suggestion, would be much cleaner code and easier > > > > > > to configure different styles that have meaning by variable name > > > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > > > I wonder if we could encapsulate, simplify this with a decorator, > > > > > something > > > > > > > like: > > > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > > > form = crud.create(...) > > > > > > > > Something like this could be useful for something like > > > > > > > > @button( my_admin_style ) > > > > > > > form = crud.create() > > > > > > > > @button( my_warning_style ) > > > > > > > form = ... > > > > > > > > just thinking out loud > > > > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan > > > > > > > > > > > >wrote: > > > > > > > > > took me a while to dig up the answer/solution, maybe can save > > > > > > > > someone > > > > > > > > else some time > > > > > > > > > form = crud.create(...) > > > > > > > > form=DIV( > > > > > > > > form, > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > $("input[type=submit]").val("Share"); > > > > > > > > });'''), > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > $("input[type=submit]").css({ > > > > > > > > color:'white', > > > > > > > > background:'blue', > > > > > > > > font: 'bold'}); > > > > > > > > });'''), > > > > > > > > ) > > > > > > > > > return dict(form=form)- Hide quoted text - > > > > > > > > - Show quoted text - --~--~-~--~~~---
[web2py:32683] Re: How to Change the css style color and text of submit button on a crud.create form in controller
I agree On Oct 11, 2:58 pm, "mr.freeze" wrote: > I think CSS is definitely the best way if you don't need this level of > dynamism and know all of the necessary selectors ahead of time. But > if you wanted to style a form based on a runtime variable (auth > membership for example), or manipulate the form in any other way for > that matter, I think this is useful. > > On Oct 11, 2:39 pm, Thadeus Burgess wrote: > > > What is wrong with using a .css file? > > > -Thadeus > > > On Sun, Oct 11, 2009 at 2:04 PM, mdipierro wrote: > > > > It is there already > > > > form.element(_type='submit')['_style']="color:white; background- > > > color:blue; font-weight:bold" > > > > It only finds the first matching element. > > > > On Oct 11, 1:16 pm, "mr.freeze" wrote: > > > > >Good point - and addresses the original post (as it could have been > > > > >more > > > > >simply done this way); > > > > > Not technically since this would affect everything inside the form and > > > > not just the submit button. What about a member function 'find' added > > > > to XmlComponent or DIV (which I think most helpers inherit from) that > > > > allows you to traverse the inner components and return the matching > > > > components for given criteria. The pseudo-code might look like this: > > > > > submit = form.components.find(XML.attribute("type")=="submit")[0] > > > > submit['_style'] = "color:white; background-color:blue; font- > > > > weight:bold" > > > > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro > > > wrote: > > > > > > > I do not think you cannot use decorators this way. > > > > > > double negatives not sure what you intended to say (but logical > > > analysis > > > > > says "... think you can use decorators this way..."); > > > > > > > But I remind you crud.create is a function that returns SQLFORM > > > which > > > > > > is a FORM which is a heper as any other helper. Therefore you can > > > > > > do: > > > > > > > form = crud.create(...) > > > > > > form['_style']="color:white; background-color:blue; > > > > > > font-weight:bold" > > > > > > Good point - and addresses the original post (as it could have been > > > more > > > > > simply done this way); > > > > > > Regardless, then > > > > > > @style( color='white', background-color='blue', font-weight='bold') > > > > > form = crud.create(...) > > > > > > would still be a readable thing (and just trivial to implement); > > > > > > Alternatively, form.style( ...same kinds of parameters) could be > > > used; > > > > > > Anyway, this is about readability, and ease of infding this stuff (as > > > this > > > > > post shows); > > > > > > If there were a member function to FORM to set style, people who not > > > have to > > > > > stumble upon it. > > > > > > Thoughts? > > > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > > > > I really like that suggestion, would be much cleaner code and > > > easier > > > > > > > to configure different styles that have meaning by variable name > > > > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > > > > I wonder if we could encapsulate, simplify this with a > > > > > > > > decorator, > > > > > > something > > > > > > > > like: > > > > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > > > > form = crud.create(...) > > > > > > > > > Something like this could be useful for something like > > > > > > > > > @button( my_admin_style ) > > > > > > > > form = crud.create() > > > > > > > > > @button( my_warning_style ) > > > > > > > > form = ... > > > > > > > > > just thinking out loud > > > > > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan < > > > mwkan...@gmail.com > > > > > > >wrote: > > > > > > > > > > took me a while to dig up the answer/solution, maybe can save > > > someone > > > > > > > > > else some time > > > > > > > > > > form = crud.create(...) > > > > > > > > > form=DIV( > > > > > > > > > form, > > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > > $("input[type=submit]").val("Share"); > > > > > > > > > });'''), > > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > > $("input[type=submit]").css({ > > > > > > > > > color:'white', > > > > > > > > > background:'blue', > > > > > > > > > font: 'bold'}); > > > > > > > > > });'''), > > > > > > > > > ) > > > > > > > > > > return dict(form=form)- Hide quoted text - > > > > > > > > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32684] Re: A simple patch to provide upload progress
I am going to link it soon. I will take suggestions on the best way to link it form the main page. On Oct 11, 12:00 pm, Yarko Tymciurak wrote: > just to complete the link (I didn't immediately find web2pyslice searching > the group):http://www.web2pyslices.com/main/default/index > > On Sun, Oct 11, 2009 at 2:42 AM, mdipierro wrote: > > > Would you post a web2pyslice on this? > > > Massimo > > > On Oct 10, 5:14 pm, AndCycle wrote: > > > @Massiom > > > >http://pastebin.com/f69e7b008 > > > > here is the patch include a working sample, > > > by the way you got another indent error in copystream_progress :p > > > > On Oct 11, 3:43 am, mdipierro wrote: > > > > > @AndCycle > > > > > I rearranged the code in trunk a bit. Could you check it still works? > > > > Thanks again. > > > > > Massimo > > > > > On Oct 8, 5:14 am, AndCycle wrote: > > > > > > thanks :) > > > > > > I will take some free time to write a example base on trunk :p > > > > > > On Oct 7, 10:24 pm, mdipierro wrote: > > > > > > > Check again. I added it now. > > > > > > > On Oct 7, 6:42 am, AndCycle > > wrote: > > > > > > > > oops, the patch been cut by width restriction on mailing list lol > > > > > > > > here is pastebinhttp://pastebin.com/f219d603b --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32685] Re: Need help with an ajax call
No, I'm afraid neither s=get_buttons() return 'jQuery("#target").html("%s");' % s.replace('"','\\"') nor return """jQuery("#target").html("%s");""" % (response.render (s).replace('"','\\"')) do anything. Nothing is rendered. On Oct 11, 3:31 pm, Thadeus Burgess wrote: > What about using response.render() to create the html? > > This way you just have to write your html in your views? > > return """ > jQuery("#target").html("%s"); > """ % (response.render(form=form).replace('"','\\"')) > > -Thadeus > > > > On Sun, Oct 11, 2009 at 1:38 PM, mr.freeze wrote: > > > Massimo's last suggestion should work as it will escape quotes in the > > output. Have you considered using jQuery.load to populate the > > subsections?http://docs.jquery.com/Ajax/load#urldatacallback > > > On Oct 11, 1:31 pm, weheh wrote: > > > I will try these suggestions but I doubt they will work as the > > > javascript portions of get_page have both single and double quoted > > > sections that probably can't be replaced without breaking the > > > javascript. > > > > What's frustrating about jQuery and javascripted actions in context of > > > web development in general, and in this case, my web2py app, is that > > > they break the DRYness of my code. It seems like I always have to > > > write one set of page-rendering code for the initial page generation, > > > and then another set of html to generate the sub-sections of the page > > > that will be created in response to a javascript event. I really want > > > to render the different sections of the page from the same code at all > > > times. Does anyone have any insights into how to structure your code > > > to be DRY while still being able to pull off a page that can be > > > generated in its entirety by a straight URL call or in pieces by ajax > > > calls that target specific subsections of the page? It assumes a page > > > that has all sorts of different kinds of things, including css > > > widgets, straight html, and javascripts. > > > > On Oct 11, 2:02 pm, mdipierro wrote: > > > > > assuming s is valid html you can also try > > > > 'jQuery("#target").html("%s");' % s.replace('"','\\"') > > > > > On Oct 11, 12:04 pm, Thadeus Burgess wrote: > > > > > > I would think that your function, is returning a qoute of some sort, > > which > > > > > is canceling out the qoute around .html, which is throwing off the > > > > > javascript errors. > > > > > > this > > > > > > 'jQuery("#target").html("%s");' % (' this is a > > strong > > > > > sentence that breaks the javascript > > > > > Notice the qoutes where it defines class=. Try changing all double > > qoutes > > > > > to single qoutes, see if that fixes your problem. > > > > > > I ran into this as well, and single qoutes in the html fixed my > > problem. > > > > > > -Thadeus > > > > > > On Sun, Oct 11, 2009 at 11:33 AM, weheh > > wrote: > > > > > > > Massimo, I tried all your callbacks and none of them can render > > > > > > get_page. I should have noted that get_page is the exact same > > function > > > > > > that I use to successfully render the sub-page initially when the > > user > > > > > > clicks on the link that takes them to this particular page. > > > > > > > That said, the text portion of get_page is rendered correctly by > > the > > > > > > following callbacks: > > > > > > > return "jQuery('#target').html(%s);" % repr(text) > > > > > > return "jQuery('#target').html(%s);" % sj.dumps(str(text)) > > > > > > and this works, too, but ' is quoted \' > > > > > > return "jQuery('#target').html('%s');" % sj.dumps(repr(text)) > > > > > > > I would never have thought to invoke sj.dumps to do the job of > > > > > > rendering the text. I'm curious why this should even work? > > > > > > > get_page calls a function show_buttons() that generates the buttons > > on > > > > > > the page. These are rollover-type buttons with a sharethis button, > > > > > > which is javascript. Taking, the divide and conquer approach to > > > > > > debugging the problem, I also tried the following callbacks, with > > the > > > > > > results shown as comments below. None of the javascripts worked to > > > > > > render the buttons. > > > > > > > return "jQuery('#target').html(%s);" % show_buttons() #fails: > > error > > > > > > missing } in sharethis javascript > > > > > > return "jQuery('#target').html(%s);" % repr(show_buttons()) > > #fails: > > > > > > nothing renders, error "missing = in XML attribute" > > > > > > return "jQuery('#target').html(%s);" % > > sj.dumps(str(show_buttons())) > > > > > > #fails: only sharethis button renders, but sharethis function not > > > > > > defined when you click on the button. None of the css rollover > > buttons > > > > > > render. And rest of webpage is mysteriously cleared. > > > > > > return "jQuery('#target').html(%s);" % sj.dumps(repr(show_buttons > > > > > > ())) #fails: Nothing renders, but target is cleared. > > > > > > return "jQuery('#target').html('%s');" % sj.dumps(str(show_buttons > > > > > > ())) #fai
[web2py:32686] Re: How to Change the css style color and text of submit button on a crud.create form in controller
Then dynamically include different stylesheets? {{if auth.is_logged_in():}} @import "auth_form.css" {{else:}} @import "reg_form.css" {{pass}} -Thadeus On Sun, Oct 11, 2009 at 2:58 PM, mr.freeze wrote: > > I think CSS is definitely the best way if you don't need this level of > dynamism and know all of the necessary selectors ahead of time. But > if you wanted to style a form based on a runtime variable (auth > membership for example), or manipulate the form in any other way for > that matter, I think this is useful. > > On Oct 11, 2:39 pm, Thadeus Burgess wrote: > > What is wrong with using a .css file? > > > > -Thadeus > > > > On Sun, Oct 11, 2009 at 2:04 PM, mdipierro > wrote: > > > > > It is there already > > > > > form.element(_type='submit')['_style']="color:white; background- > > > color:blue; font-weight:bold" > > > > > It only finds the first matching element. > > > > > On Oct 11, 1:16 pm, "mr.freeze" wrote: > > > > >Good point - and addresses the original post (as it could have been > more > > > > >simply done this way); > > > > > > Not technically since this would affect everything inside the form > and > > > > not just the submit button. What about a member function 'find' > added > > > > to XmlComponent or DIV (which I think most helpers inherit from) that > > > > allows you to traverse the inner components and return the matching > > > > components for given criteria. The pseudo-code might look like this: > > > > > > submit = form.components.find(XML.attribute("type")=="submit")[0] > > > > submit['_style'] = "color:white; background-color:blue; font- > > > > weight:bold" > > > > > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro < > mdipie...@cs.depaul.edu> > > > wrote: > > > > > > > > I do not think you cannot use decorators this way. > > > > > > > double negatives not sure what you intended to say (but logical > > > analysis > > > > > says "... think you can use decorators this way..."); > > > > > > > > But I remind you crud.create is a function that returns SQLFORM > > > which > > > > > > is a FORM which is a heper as any other helper. Therefore you can > do: > > > > > > > > form = crud.create(...) > > > > > > form['_style']="color:white; background-color:blue; > font-weight:bold" > > > > > > > Good point - and addresses the original post (as it could have been > > > more > > > > > simply done this way); > > > > > > > Regardless, then > > > > > > > @style( color='white', background-color='blue', font-weight='bold') > > > > > form = crud.create(...) > > > > > > > would still be a readable thing (and just trivial to implement); > > > > > > > Alternatively, form.style( ...same kinds of parameters) could > be > > > used; > > > > > > > Anyway, this is about readability, and ease of infding this stuff > (as > > > this > > > > > post shows); > > > > > > > If there were a member function to FORM to set style, people who > not > > > have to > > > > > stumble upon it. > > > > > > > Thoughts? > > > > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > > > > I really like that suggestion, would be much cleaner code and > > > easier > > > > > > > to configure different styles that have meaning by variable > name > > > > > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > > > > > I wonder if we could encapsulate, simplify this with a > decorator, > > > > > > something > > > > > > > > like: > > > > > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > > > > form = crud.create(...) > > > > > > > > > > Something like this could be useful for something like > > > > > > > > > > @button( my_admin_style ) > > > > > > > > form = crud.create() > > > > > > > > > > @button( my_warning_style ) > > > > > > > > form = ... > > > > > > > > > > just thinking out loud > > > > > > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan < > > > mwkan...@gmail.com > > > > > > >wrote: > > > > > > > > > > > took me a while to dig up the answer/solution, maybe can > save > > > someone > > > > > > > > > else some time > > > > > > > > > > >form = crud.create(...) > > > > > > > > >form=DIV( > > > > > > > > > form, > > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > > $("input[type=submit]").val("Share"); > > > > > > > > > });'''), > > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > > $("input[type=submit]").css({ > > > > > > > > > color:'white', > > > > > > > > > background:'blue', > > > > > > > > > font: 'bold'}); > > > > > > > > > });'''), > > > > > > > > > ) > > > > > > > > > > > return dict(form=form)- Hide quoted text - > > > > > > > > > > - Show quoted text - > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.
[web2py:32687] Re: Need help with an ajax call
This may take forever. Can you show us what get_buttons() does and a sample of its output that gives the problem? Massimo On Oct 11, 3:11 pm, weheh wrote: > No, I'm afraid neither > s=get_buttons() > return 'jQuery("#target").html("%s");' % s.replace('"','\\"') > nor > return """jQuery("#target").html("%s");""" % (response.render > (s).replace('"','\\"')) > do anything. Nothing is rendered. > > On Oct 11, 3:31 pm, Thadeus Burgess wrote: > > > What about using response.render() to create the html? > > > This way you just have to write your html in your views? > > > return """ > > jQuery("#target").html("%s"); > > """ % (response.render(form=form).replace('"','\\"')) > > > -Thadeus > > > On Sun, Oct 11, 2009 at 1:38 PM, mr.freeze wrote: > > > > Massimo's last suggestion should work as it will escape quotes in the > > > output. Have you considered using jQuery.load to populate the > > > subsections?http://docs.jquery.com/Ajax/load#urldatacallback > > > > On Oct 11, 1:31 pm, weheh wrote: > > > > I will try these suggestions but I doubt they will work as the > > > > javascript portions of get_page have both single and double quoted > > > > sections that probably can't be replaced without breaking the > > > > javascript. > > > > > What's frustrating about jQuery and javascripted actions in context of > > > > web development in general, and in this case, my web2py app, is that > > > > they break the DRYness of my code. It seems like I always have to > > > > write one set of page-rendering code for the initial page generation, > > > > and then another set of html to generate the sub-sections of the page > > > > that will be created in response to a javascript event. I really want > > > > to render the different sections of the page from the same code at all > > > > times. Does anyone have any insights into how to structure your code > > > > to be DRY while still being able to pull off a page that can be > > > > generated in its entirety by a straight URL call or in pieces by ajax > > > > calls that target specific subsections of the page? It assumes a page > > > > that has all sorts of different kinds of things, including css > > > > widgets, straight html, and javascripts. > > > > > On Oct 11, 2:02 pm, mdipierro wrote: > > > > > > assuming s is valid html you can also try > > > > > 'jQuery("#target").html("%s");' % s.replace('"','\\"') > > > > > > On Oct 11, 12:04 pm, Thadeus Burgess wrote: > > > > > > > I would think that your function, is returning a qoute of some sort, > > > which > > > > > > is canceling out the qoute around .html, which is throwing off the > > > > > > javascript errors. > > > > > > > this > > > > > > > 'jQuery("#target").html("%s");' % (' this is a > > > strong > > > > > > sentence that breaks the javascript > > > > > > Notice the qoutes where it defines class=. Try changing all double > > > qoutes > > > > > > to single qoutes, see if that fixes your problem. > > > > > > > I ran into this as well, and single qoutes in the html fixed my > > > problem. > > > > > > > -Thadeus > > > > > > > On Sun, Oct 11, 2009 at 11:33 AM, weheh > > > wrote: > > > > > > > > Massimo, I tried all your callbacks and none of them can render > > > > > > > get_page. I should have noted that get_page is the exact same > > > function > > > > > > > that I use to successfully render the sub-page initially when the > > > user > > > > > > > clicks on the link that takes them to this particular page. > > > > > > > > That said, the text portion of get_page is rendered correctly by > > > the > > > > > > > following callbacks: > > > > > > > > return "jQuery('#target').html(%s);" % repr(text) > > > > > > > return "jQuery('#target').html(%s);" % sj.dumps(str(text)) > > > > > > > and this works, too, but ' is quoted \' > > > > > > > return "jQuery('#target').html('%s');" % sj.dumps(repr(text)) > > > > > > > > I would never have thought to invoke sj.dumps to do the job of > > > > > > > rendering the text. I'm curious why this should even work? > > > > > > > > get_page calls a function show_buttons() that generates the > > > > > > > buttons > > > on > > > > > > > the page. These are rollover-type buttons with a sharethis button, > > > > > > > which is javascript. Taking, the divide and conquer approach to > > > > > > > debugging the problem, I also tried the following callbacks, with > > > the > > > > > > > results shown as comments below. None of the javascripts worked to > > > > > > > render the buttons. > > > > > > > > return "jQuery('#target').html(%s);" % show_buttons() #fails: > > > error > > > > > > > missing } in sharethis javascript > > > > > > > return "jQuery('#target').html(%s);" % repr(show_buttons()) > > > #fails: > > > > > > > nothing renders, error "missing = in XML attribute" > > > > > > > return "jQuery('#target').html(%s);" % > > > sj.dumps(str(show_buttons())) > > > > > > > #fails: only sharethis button renders, but sharethis function not > > > > > > > defined when you click on the butto
[web2py:32688] Re: How to Change the css style color and text of submit button on a crud.create form in controller
I sent you a patch. Same as 'element' but returns a list or None. On Oct 11, 3:01 pm, mdipierro wrote: > I would take a patch that defines elements (notice the -s) that > returns all matching elements. > > On Oct 11, 2:36 pm, "mr.freeze" wrote: > > > Nice! This would be doubly handy if it returned all matching > > components (jQuery style). What about adding a first=True arg to make > > return all matches optional ? (or some other more graceful solution > > that I'm sure you've already thought of before finishing this > > sentence :) > > > def element(self, first=True, **kargs): > > components = copy.copy(self.components) > > matches = [] > > for c in components: > > try: > > components += copy.copy(c.components) > > check = True > > for (key, value) in kargs.items(): > > if c[key] != value: > > check = False > > if check: > > if first: > > return c > > else: > > matches.append(c) > > except: > > pass > > > if len(matches): return matches > > return None > > > On Oct 11, 2:04 pm, mdipierro wrote: > > > > It is there already > > > > form.element(_type='submit')['_style']="color:white; background- > > > color:blue; font-weight:bold" > > > > It only finds the first matching element. > > > > On Oct 11, 1:16 pm, "mr.freeze" wrote: > > > > > >Good point - and addresses the original post (as it could have been > > > > >more > > > > >simply done this way); > > > > > Not technically since this would affect everything inside the form and > > > > not just the submit button. What about a member function 'find' added > > > > to XmlComponent or DIV (which I think most helpers inherit from) that > > > > allows you to traverse the inner components and return the matching > > > > components for given criteria. The pseudo-code might look like this: > > > > > submit = form.components.find(XML.attribute("type")=="submit")[0] > > > > submit['_style'] = "color:white; background-color:blue; font- > > > > weight:bold" > > > > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro > > > > > wrote: > > > > > > > I do not think you cannot use decorators this way. > > > > > > double negatives not sure what you intended to say (but logical > > > > > analysis > > > > > says "... think you can use decorators this way..."); > > > > > > > But I remind you crud.create is a function that returns SQLFORM > > > > > > which > > > > > > is a FORM which is a heper as any other helper. Therefore you can > > > > > > do: > > > > > > > form = crud.create(...) > > > > > > form['_style']="color:white; background-color:blue; > > > > > > font-weight:bold" > > > > > > Good point - and addresses the original post (as it could have been > > > > > more > > > > > simply done this way); > > > > > > Regardless, then > > > > > > @style( color='white', background-color='blue', font-weight='bold') > > > > > form = crud.create(...) > > > > > > would still be a readable thing (and just trivial to implement); > > > > > > Alternatively, form.style( ...same kinds of parameters) could > > > > > be used; > > > > > > Anyway, this is about readability, and ease of infding this stuff (as > > > > > this > > > > > post shows); > > > > > > If there were a member function to FORM to set style, people who not > > > > > have to > > > > > stumble upon it. > > > > > > Thoughts? > > > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > > > > I really like that suggestion, would be much cleaner code and > > > > > > > easier > > > > > > > to configure different styles that have meaning by variable name > > > > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > > > > I wonder if we could encapsulate, simplify this with a > > > > > > > > decorator, > > > > > > something > > > > > > > > like: > > > > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > > > > form = crud.create(...) > > > > > > > > > Something like this could be useful for something like > > > > > > > > > @button( my_admin_style ) > > > > > > > > form = crud.create() > > > > > > > > > @button( my_warning_style ) > > > > > > > > form = ... > > > > > > > > > just thinking out loud > > > > > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan > > > > > > > > > > > > > >wrote: > > > > > > > > > > took me a while to dig up the answer/solution, maybe can save > > > > > > > > > someone > > > > > > > > > else some time > > > > > > > > > > form = crud.create(...) > > > > > > > > > form=DIV( > > > > > > > > > form, > > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > > $("input[type=submit]").val("Share"); > > > > > > > > > });'''), > > > > > > > > > SCRIPT(
[web2py:32689] Re: How to Change the css style color and text of submit button on a crud.create form in controller
The example I gave was for auth membership. Say you wanted to style the form based on which group they were a member of. You would need a style sheet for each group. Also, what would happen when a new group was created? On Oct 11, 3:24 pm, Thadeus Burgess wrote: > Then dynamically include different stylesheets? > > > {{if auth.is_logged_in():}} > @import "auth_form.css" > {{else:}} > @import "reg_form.css" > {{pass}} > > -Thadeus > > On Sun, Oct 11, 2009 at 2:58 PM, mr.freeze wrote: > > > I think CSS is definitely the best way if you don't need this level of > > dynamism and know all of the necessary selectors ahead of time. But > > if you wanted to style a form based on a runtime variable (auth > > membership for example), or manipulate the form in any other way for > > that matter, I think this is useful. > > > On Oct 11, 2:39 pm, Thadeus Burgess wrote: > > > What is wrong with using a .css file? > > > > -Thadeus > > > > On Sun, Oct 11, 2009 at 2:04 PM, mdipierro > > wrote: > > > > > It is there already > > > > > form.element(_type='submit')['_style']="color:white; background- > > > > color:blue; font-weight:bold" > > > > > It only finds the first matching element. > > > > > On Oct 11, 1:16 pm, "mr.freeze" wrote: > > > > > >Good point - and addresses the original post (as it could have been > > more > > > > > >simply done this way); > > > > > > Not technically since this would affect everything inside the form > > and > > > > > not just the submit button. What about a member function 'find' > > added > > > > > to XmlComponent or DIV (which I think most helpers inherit from) that > > > > > allows you to traverse the inner components and return the matching > > > > > components for given criteria. The pseudo-code might look like this: > > > > > > submit = form.components.find(XML.attribute("type")=="submit")[0] > > > > > submit['_style'] = "color:white; background-color:blue; font- > > > > > weight:bold" > > > > > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro < > > mdipie...@cs.depaul.edu> > > > > wrote: > > > > > > > > I do not think you cannot use decorators this way. > > > > > > > double negatives not sure what you intended to say (but logical > > > > analysis > > > > > > says "... think you can use decorators this way..."); > > > > > > > > But I remind you crud.create is a function that returns SQLFORM > > > > which > > > > > > > is a FORM which is a heper as any other helper. Therefore you can > > do: > > > > > > > > form = crud.create(...) > > > > > > > form['_style']="color:white; background-color:blue; > > font-weight:bold" > > > > > > > Good point - and addresses the original post (as it could have been > > > > more > > > > > > simply done this way); > > > > > > > Regardless, then > > > > > > > @style( color='white', background-color='blue', font-weight='bold') > > > > > > form = crud.create(...) > > > > > > > would still be a readable thing (and just trivial to implement); > > > > > > > Alternatively, form.style( ...same kinds of parameters) could > > be > > > > used; > > > > > > > Anyway, this is about readability, and ease of infding this stuff > > (as > > > > this > > > > > > post shows); > > > > > > > If there were a member function to FORM to set style, people who > > not > > > > have to > > > > > > stumble upon it. > > > > > > > Thoughts? > > > > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > > > > > I really like that suggestion, would be much cleaner code and > > > > easier > > > > > > > > to configure different styles that have meaning by variable > > name > > > > > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > > > > > I wonder if we could encapsulate, simplify this with a > > decorator, > > > > > > > something > > > > > > > > > like: > > > > > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > > > > > form = crud.create(...) > > > > > > > > > > Something like this could be useful for something like > > > > > > > > > > @button( my_admin_style ) > > > > > > > > > form = crud.create() > > > > > > > > > > @button( my_warning_style ) > > > > > > > > > form = ... > > > > > > > > > > just thinking out loud > > > > > > > > > > On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan < > > > > mwkan...@gmail.com > > > > > > > >wrote: > > > > > > > > > > > took me a while to dig up the answer/solution, maybe can > > save > > > > someone > > > > > > > > > > else some time > > > > > > > > > > > form = crud.create(...) > > > > > > > > > > form=DIV( > > > > > > > > > > form, > > > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > > > $("input[type=submit]").val("Share"); > > > > > > > > > > });'''), > > > > > > > > > > SCRIPT('''$(document).ready(function() { > > > > > > > > > > $("input[type=submit]").css({ > > > > > > > > > > color:'white', > > > > > > > > > > background:'blue', > > > >
[web2py:32690] Re: How to Change the css style color and text of submit button on a crud.create form in controller
On Oct 11, 2009, at 2:04 PM, mr.freeze wrote: > > The example I gave was for auth membership. Say you wanted to style > the form based on which group they were a member of. You would need a > style sheet for each group. Also, what would happen when a new group > was created? You could generate the CSS file dynamically (new feature!), though it'd probably be overkill here. Alternatively you could generate the class definition in , which would override the CSS file's default. That would be a little cleaner that a local style=, I think. > > On Oct 11, 3:24 pm, Thadeus Burgess wrote: >> Then dynamically include different stylesheets? >> >> >> {{if auth.is_logged_in():}} >> @import "auth_form.css" >> {{else:}} >> @import "reg_form.css" >> {{pass}} >> >> -Thadeus >> >> On Sun, Oct 11, 2009 at 2:58 PM, mr.freeze >> wrote: >> >>> I think CSS is definitely the best way if you don't need this >>> level of >>> dynamism and know all of the necessary selectors ahead of time. But >>> if you wanted to style a form based on a runtime variable (auth >>> membership for example), or manipulate the form in any other way for >>> that matter, I think this is useful. >> >>> On Oct 11, 2:39 pm, Thadeus Burgess wrote: What is wrong with using a .css file? >> -Thadeus >> On Sun, Oct 11, 2009 at 2:04 PM, mdipierro >>> wrote: >> > It is there already >> > form.element(_type='submit')['_style']="color:white; background- > color:blue; font-weight:bold" >> > It only finds the first matching element. >> > On Oct 11, 1:16 pm, "mr.freeze" wrote: >>> Good point - and addresses the original post (as it could have >>> been >>> more >>> simply done this way); >> >> Not technically since this would affect everything inside the >> form >>> and >> not just the submit button. What about a member function 'find' >>> added >> to XmlComponent or DIV (which I think most helpers inherit >> from) that >> allows you to traverse the inner components and return the >> matching >> components for given criteria. The pseudo-code might look like >> this: >> >> submit = form.components.find(XML.attribute("type")=="submit")[0] >> submit['_style'] = "color:white; background-color:blue; font- >> weight:bold" >> >> On Oct 11, 12:29 pm, Yarko Tymciurak wrote: >> >>> On Sun, Oct 11, 2009 at 11:04 AM, mdipierro < >>> mdipie...@cs.depaul.edu> > wrote: >> I do not think you cannot use decorators this way. >> >>> double negatives not sure what you intended to say (but >>> logical > analysis >>> says "... think you can use decorators this way..."); >> But I remind you crud.create is a function that returns SQLFORM > which is a FORM which is a heper as any other helper. Therefore you can >>> do: >> form = crud.create(...) form['_style']="color:white; background-color:blue; >>> font-weight:bold" >> >>> Good point - and addresses the original post (as it could have >>> been > more >>> simply done this way); >> >>> Regardless, then >> >>> @style( color='white', background-color='blue', font- >>> weight='bold') >>> form = crud.create(...) >> >>> would still be a readable thing (and just trivial to implement); >> >>> Alternatively, form.style( ...same kinds of parameters) >>> could >>> be > used; >> >>> Anyway, this is about readability, and ease of infding this >>> stuff >>> (as > this >>> post shows); >> >>> If there were a member function to FORM to set style, people who >>> not > have to >>> stumble upon it. >> >>> Thoughts? >> On Oct 11, 10:47 am, Web2py-SuperFan wrote: > I really like that suggestion, would be much cleaner code and > easier > to configure different styles that have meaning by variable >>> name >> > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: >> >> I wonder if we could encapsulate, simplify this with a >>> decorator, something >> like: >> >> @button( color='white', background='blue', font='bold' ) >> form = crud.create(...) >> >> Something like this could be useful for something like >> >> @button( my_admin_style ) >> form = crud.create() >> >> @button( my_warning_style ) >> form = ... >> >> just thinking out loud >> >> On Sat, Oct 10, 2009 at 11:10 PM, Web2py-SuperFan < > mwkan...@gmail.com > wrote: >> >>> took me a while to dig up the answer/solution, maybe can >>> save > someone >>> else some time >> >>>form = crud.create(...) >>>form=DIV( >>> form, >>> SCRIPT('''$(document).ready(function() { >>> $("input[type=submit]").val("Share"); >>> });'''), >>
[web2py:32691] Re: How to Change the css style color and text of submit button on a crud.create form in controller
The patch is in trunk. I changed three things: 1) both elements and element include the current element in the search, not just components of the current element. 2) elements returns an empty list if not matching. element still returns None because it is not intended to return a list anyaway. 3) following your original suggestion I introduced first_only=False argument so that now element calls elements. Massimo On Oct 11, 4:00 pm, "mr.freeze" wrote: > I sent you a patch. Same as 'element' but returns a list or None. > > On Oct 11, 3:01 pm, mdipierro wrote: > > > I would take a patch that defines elements (notice the -s) that > > returns all matching elements. > > > On Oct 11, 2:36 pm, "mr.freeze" wrote: > > > > Nice! This would be doubly handy if it returned all matching > > > components (jQuery style). What about adding a first=True arg to make > > > return all matches optional ? (or some other more graceful solution > > > that I'm sure you've already thought of before finishing this > > > sentence :) > > > > def element(self, first=True, **kargs): > > > components = copy.copy(self.components) > > > matches = [] > > > for c in components: > > > try: > > > components += copy.copy(c.components) > > > check = True > > > for (key, value) in kargs.items(): > > > if c[key] != value: > > > check = False > > > if check: > > > if first: > > > return c > > > else: > > > matches.append(c) > > > except: > > > pass > > > > if len(matches): return matches > > > return None > > > > On Oct 11, 2:04 pm, mdipierro wrote: > > > > > It is there already > > > > > form.element(_type='submit')['_style']="color:white; background- > > > > color:blue; font-weight:bold" > > > > > It only finds the first matching element. > > > > > On Oct 11, 1:16 pm, "mr.freeze" wrote: > > > > > > >Good point - and addresses the original post (as it could have been > > > > > >more > > > > > >simply done this way); > > > > > > Not technically since this would affect everything inside the form and > > > > > not just the submit button. What about a member function 'find' added > > > > > to XmlComponent or DIV (which I think most helpers inherit from) that > > > > > allows you to traverse the inner components and return the matching > > > > > components for given criteria. The pseudo-code might look like this: > > > > > > submit = form.components.find(XML.attribute("type")=="submit")[0] > > > > > submit['_style'] = "color:white; background-color:blue; font- > > > > > weight:bold" > > > > > > On Oct 11, 12:29 pm, Yarko Tymciurak wrote: > > > > > > > On Sun, Oct 11, 2009 at 11:04 AM, mdipierro > > > > > > wrote: > > > > > > > > I do not think you cannot use decorators this way. > > > > > > > double negatives not sure what you intended to say (but logical > > > > > > analysis > > > > > > says "... think you can use decorators this way..."); > > > > > > > > But I remind you crud.create is a function that returns SQLFORM > > > > > > > which > > > > > > > is a FORM which is a heper as any other helper. Therefore you can > > > > > > > do: > > > > > > > > form = crud.create(...) > > > > > > > form['_style']="color:white; background-color:blue; > > > > > > > font-weight:bold" > > > > > > > Good point - and addresses the original post (as it could have been > > > > > > more > > > > > > simply done this way); > > > > > > > Regardless, then > > > > > > > @style( color='white', background-color='blue', font-weight='bold') > > > > > > form = crud.create(...) > > > > > > > would still be a readable thing (and just trivial to implement); > > > > > > > Alternatively, form.style( ...same kinds of parameters) could > > > > > > be used; > > > > > > > Anyway, this is about readability, and ease of infding this stuff > > > > > > (as this > > > > > > post shows); > > > > > > > If there were a member function to FORM to set style, people who > > > > > > not have to > > > > > > stumble upon it. > > > > > > > Thoughts? > > > > > > > > On Oct 11, 10:47 am, Web2py-SuperFan wrote: > > > > > > > > I really like that suggestion, would be much cleaner code and > > > > > > > > easier > > > > > > > > to configure different styles that have meaning by variable name > > > > > > > > > On Oct 10, 9:47 pm, Yarko Tymciurak wrote: > > > > > > > > > > I wonder if we could encapsulate, simplify this with a > > > > > > > > > decorator, > > > > > > > something > > > > > > > > > like: > > > > > > > > > > @button( color='white', background='blue', font='bold' ) > > > > > > > > > form = crud.create(...) > > > > > > > > > > Something like this could be useful for something like > > > > > > > > > > @button( my_admin_style ) > > > > > > > > > form = crud.create() > > > > > > > > > > @bu
[web2py:32692] Re: please check trunks
You are forgetting plugin support (even its not completed at all), I tried with Ajax=true and it worked Massimo. Alex F El 10/10/2009 22:27, mdipierro escribió: > there a lot of new things in trunk. Please check it. > > In particular: > 1) cached uploads allow for progress bars (thanks AndCycle) > 2) ingres support (thanks Chris) > 3) legacy database support for db2, mssql (thanks Denes) > 4) default setting of content-type (this may cause strange behavior in > old apps when downloading images. please check it!) > 5) new cron > > Please let me know if you tried and was ok with you or not. I would > like to post a new version of web2py next week. > > Massimo > > > > > > -- Alejandro Fanjul Fdez. alex.fan...@gmail.com www.mhproject.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:32693] Re: Need help with an ajax call
def show_buttons(): return DIV(podcast_button(),share_button(),delete_button (),_class='buttons') def podcast_button(): return DIV( A( IMG( _src=URL( r=request,c='static',f='images',args= ['buttons','podcast_0.gif']), _alt='Podcast audio', _border='0' ), SPAN('Podcast',_class='button-label'), _href=URL(r=request,c='info',f='podcast'), ), _class='rollover-podcast' ) def share_button(): return DIV( XML(""" var object = SHARETHIS.addEntry({ title:"domain.com", url: "http://www.domain.com/12345";, summary: "This is really good stuff and you need some of it."}, {button:false}); //write customized button document.write('