[web2py] Call def with arguments from html view
How to call a def with request.vars arguments from an onclick-event in a view file? What is wrong with the code? Thanks in advance for help! Controller: def insnext(): nodename=request.vars['nodename'] nrowid=request.vars['nrowid'] db.next_list.update_or_insert(**db.next_list._filter_fields({ "node" : nodename , "next_node":nrowid })) def delnext(): nextrowid=request.vars['value'] db(db.next_list.id==nextrowid).delete() View: delete insert {{=nrow['name']}} {{=nrowid}} -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/aaed257d-7d4b-45b7-bcc7-7a21628a0a70n%40googlegroups.com.
Re: [web2py] How to insert rows in a database from a html page in web2py?
Thank you for pointing out that there was an issue with the database. After deleting the content of the database folder everything works. Tanks for the help! On Friday, 7 July 2023 at 16:16:06 UTC+2 Rick wrote: > Thanks Massimiliano for the answering quickly. The suggested code produces > this error: > IntegrityError(FOREIGN KEY constraint failed) > > If I change the model file lines to > db.define_table('next_list', Field('node'), Field('next_node', text)) > then the error changes to: > NameError(name 'text' is not defined) > > > On Thursday, 6 July 2023 at 16:12:59 UTC+2 Massimiliano wrote: > >> Maybe on your model there is more than you showed : >> >> db.define_table('next_list', Field('node'), Field('next_node')) >> >> db.next_list.insert(**db.next_list._filter_fields({ "node" : "test1" , >> "next_node":"test2" })) >> >> print(db(db.next_list).select()) >> >> next_list.id,next_list.node,next_list.next_node >> >> 1,test1,test2 >> >> >> db.next_list.insert(**db.next_list._filter_fields({ "node" : "test1" , >> "next_node":"test2" })) >> >> print(db(db.next_list).select()) >> >> next_list.id,next_list.node,next_list.next_node >> >> 1,test1,test2 >> >> 2,test1,test2 >> >> >> >> Il giorno gio 6 lug 2023 alle ore 16:07 Rick ha >> scritto: >> >>> That unfortunately gives a ticket with this information: >>> sqlite3.IntegrityError: FOREIGN KEY constraint failed >>> On Thursday, 6 July 2023 at 15:02:05 UTC+2 Massimiliano wrote: >>> >>>> try this: >>>> >>>> {{db.next_list.insert(**db.next_list._filter_fields({ "node" : "test1" >>>> , "next_node":"test2" }))}} >>>> >>>> Il giorno gio 6 lug 2023 alle ore 13:47 Rick ha >>>> scritto: >>>> >>>>> How to insert rows from a view-file? The site doesn't produce any >>>>> error, but an empty row is added to the database.: >>>>> >>>>> From the model file >>>>> db.define_table('next_list', Field('node'), Field('next_node')) >>>>> >>>>> >>>>> From the view file: >>>>> {{nextrows = db(db.next_list)}} >>>>> {{db.next_list.insert(**db.next_list._filter_fields({ >>>>> "db.next_list.node" : "test1" , "db.next_list.next_node":"test2" }))}} >>>>> >>>>> >>>>> >>>>> What's wrong? Thanks in advance for help and ideas! >>>>> -- >>>>> >>>>> >>>>> -- >>>>> Resources: >>>>> - http://web2py.com >>>>> - http://web2py.com/book (Documentation) >>>>> - http://github.com/web2py/web2py (Source code) >>>>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "web2py-users" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to web2py+un...@googlegroups.com. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/web2py/ac174d5a-8245-44e5-b708-08258a60f70fn%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/web2py/ac174d5a-8245-44e5-b708-08258a60f70fn%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> >>>> >>>> -- >>>> Massimiliano >>>> >>> -- >>> Resources: >>> - http://web2py.com >>> - http://web2py.com/book (Documentation) >>> - http://github.com/web2py/web2py (Source code) >>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "web2py-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to web2py+un...@googlegroups.com. >>> >> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/web2py/4e07ad77-4727-44a8-8710-bda5909cb287n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/web2py/4e07ad77-4727-44a8-8710-bda5909cb287n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> Massimiliano >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/3b7dcd0f-275f-415e-bd2c-2d7d40e2f3e8n%40googlegroups.com.
Re: [web2py] How to insert rows in a database from a html page in web2py?
Thanks Massimiliano for the answering quickly. The suggested code produces this error: IntegrityError(FOREIGN KEY constraint failed) If I change the model file lines to db.define_table('next_list', Field('node'), Field('next_node', text)) then the error changes to: NameError(name 'text' is not defined) On Thursday, 6 July 2023 at 16:12:59 UTC+2 Massimiliano wrote: > Maybe on your model there is more than you showed : > > db.define_table('next_list', Field('node'), Field('next_node')) > > db.next_list.insert(**db.next_list._filter_fields({ "node" : "test1" , > "next_node":"test2" })) > > print(db(db.next_list).select()) > > next_list.id,next_list.node,next_list.next_node > > 1,test1,test2 > > > db.next_list.insert(**db.next_list._filter_fields({ "node" : "test1" , > "next_node":"test2" })) > > print(db(db.next_list).select()) > > next_list.id,next_list.node,next_list.next_node > > 1,test1,test2 > > 2,test1,test2 > > > > Il giorno gio 6 lug 2023 alle ore 16:07 Rick ha > scritto: > >> That unfortunately gives a ticket with this information: >> sqlite3.IntegrityError: FOREIGN KEY constraint failed >> On Thursday, 6 July 2023 at 15:02:05 UTC+2 Massimiliano wrote: >> >>> try this: >>> >>> {{db.next_list.insert(**db.next_list._filter_fields({ "node" : "test1" >>> , "next_node":"test2" }))}} >>> >>> Il giorno gio 6 lug 2023 alle ore 13:47 Rick ha >>> scritto: >>> >>>> How to insert rows from a view-file? The site doesn't produce any >>>> error, but an empty row is added to the database.: >>>> >>>> From the model file >>>> db.define_table('next_list', Field('node'), Field('next_node')) >>>> >>>> >>>> From the view file: >>>> {{nextrows = db(db.next_list)}} >>>> {{db.next_list.insert(**db.next_list._filter_fields({ >>>> "db.next_list.node" : "test1" , "db.next_list.next_node":"test2" }))}} >>>> >>>> >>>> >>>> What's wrong? Thanks in advance for help and ideas! >>>> -- >>>> >>>> >>>> -- >>>> Resources: >>>> - http://web2py.com >>>> - http://web2py.com/book (Documentation) >>>> - http://github.com/web2py/web2py (Source code) >>>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "web2py-users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to web2py+un...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/web2py/ac174d5a-8245-44e5-b708-08258a60f70fn%40googlegroups.com >>>> >>>> <https://groups.google.com/d/msgid/web2py/ac174d5a-8245-44e5-b708-08258a60f70fn%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> >>> -- >>> Massimiliano >>> >> -- >> Resources: >> - http://web2py.com >> - http://web2py.com/book (Documentation) >> - http://github.com/web2py/web2py (Source code) >> - https://code.google.com/p/web2py/issues/list (Report Issues) >> --- >> You received this message because you are subscribed to the Google Groups >> "web2py-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to web2py+un...@googlegroups.com. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/web2py/4e07ad77-4727-44a8-8710-bda5909cb287n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/web2py/4e07ad77-4727-44a8-8710-bda5909cb287n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Massimiliano > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/b59e89fc-3492-41cc-ae15-8c8d7cfae4ccn%40googlegroups.com.
Re: [web2py] How to insert rows in a database from a html page in web2py?
That unfortunately gives a ticket with this information: sqlite3.IntegrityError: FOREIGN KEY constraint failed On Thursday, 6 July 2023 at 15:02:05 UTC+2 Massimiliano wrote: > try this: > > {{db.next_list.insert(**db.next_list._filter_fields({ "node" : "test1" , > "next_node":"test2" }))}} > > Il giorno gio 6 lug 2023 alle ore 13:47 Rick ha > scritto: > >> How to insert rows from a view-file? The site doesn't produce any error, >> but an empty row is added to the database.: >> >> From the model file >> db.define_table('next_list', Field('node'), Field('next_node')) >> >> >> From the view file: >> {{nextrows = db(db.next_list)}} >> {{db.next_list.insert(**db.next_list._filter_fields({ "db.next_list.node" >> : "test1" , "db.next_list.next_node":"test2" }))}} >> >> >> >> What's wrong? Thanks in advance for help and ideas! >> -- >> >> >> -- >> Resources: >> - http://web2py.com >> - http://web2py.com/book (Documentation) >> - http://github.com/web2py/web2py (Source code) >> - https://code.google.com/p/web2py/issues/list (Report Issues) >> --- >> You received this message because you are subscribed to the Google Groups >> "web2py-users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to web2py+un...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/web2py/ac174d5a-8245-44e5-b708-08258a60f70fn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/web2py/ac174d5a-8245-44e5-b708-08258a60f70fn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Massimiliano > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/4e07ad77-4727-44a8-8710-bda5909cb287n%40googlegroups.com.
[web2py] How to insert rows in a database from a html page in web2py?
How to insert rows from a view-file? The site doesn't produce any error, but an empty row is added to the database.: >From the model file db.define_table('next_list', Field('node'), Field('next_node')) >From the view file: {{nextrows = db(db.next_list)}} {{db.next_list.insert(**db.next_list._filter_fields({ "db.next_list.node" : "test1" , "db.next_list.next_node":"test2" }))}} What's wrong? Thanks in advance for help and ideas! -- -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/ac174d5a-8245-44e5-b708-08258a60f70fn%40googlegroups.com.
[web2py] Part 3 of a previous conversation on empty field display after update
(The following appends 2 previous posts that are still under review:) So here's additional info on the empty-field issue I'm having after updating my web2py apps to version 2.22.3. The problem first noticed was that records containing empty fields,* in NEW or UPDATED records only*, display "None" in the empty fields, when displayed in my views or in appadmin.html. Previously empty fields appeared blank, as is preferred. Existing records still display empty fields as blank. After examining the data in an SQLite DB browser, I now see that new or edited records have inserted "NULL" in the empty fields, while old records still have blanks. I think I read somewhere that this may be related to Python behavior; my apps are still running on Python 2.7.12. Another strange behavior I've discovered is that a field containing "NULL" (and displaying as "None") does not evaluate properly in an expression such as: sppa = db(db.specimen.type_status<>('Test')).select(orderby=db.specimen.id) return dict(sppa=sppa) In the above example, since a type_status field containing "NULL" is not equal to "Test", the row should appear in the displayed table---but it does not appear. Unfortunately, I am stuck and cannot add or edit any records in my apps until I get this sorted. Any help would be greatly appreciated. For context, see the default app at https://specimens.mantodearesearch.com/ Thanks, Rick -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/e4f46a19-fffa-4680-8562-e3a676a1a69cn%40googlegroups.com.
[web2py] Change in empty field display after upgrade
After finally upgrading my web2py apps to version 2.22.3 (from a very old 2016 version) I've discovered a change in how the DAL is dealing with empty data fields. Previously empty fields displayed as blank in table views. Now, they still appear blank, EXCEPT in NEW or UPDATED records, in which all blank fields now display "None" in table views. This is true of my views as well as appadmin.html. When viewing the record in forms, the empty fields are still blank, so I assume this is just an issue of how DAL retrieves data. I have scoured the forum and the book, but have not found a specific reference to what needs to be fixed, and where--in the db definition, default.py defs, or in views? For further clarification, my db is SQLITE and my fields are defined with only name and type (string) attributes, so all other attributes have default settings. I have tried messing with adding attributes such as "required=False" or "default=''' ", both in db.define_table and in db.table. field.extra = {}, to no avail. I am definitely over my head here. This is an expanded version of a post I made yesterday that never appeared, so if there is post-vetting purgatory or something I apologize for the repost. Thanks in advance for any suggestions. Rick -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/2e37428f-2010-4141-8866-7be70d087a8en%40googlegroups.com.
[web2py] Display of empty data fields in views
I have a couple of old web2py apps that I finally updated to the current 2.22.3 version (from a 2016 version!) and it went amazingly smoothly. Now that I've got the minor aesthetic issues cleaned up, I've discovered an issue on how data in empty fields displays, both in my own views as well as in appadmin.html. Previously, if a field in a table had no data, it displayed as blank, which is both expected and preferred, so I'll call this "normal." Now, if I display an existing record in a view, it still appears "normal." But if I create a new record, or if I update an existing record, any field that is empty now displays "None". However, if I return to an editing form view, the empty fields are still blank. My knowledge of how web2py decides to display data is so shallow that I don't have any idea where to begin to sort this out, so I can return to "normal" views. Can anyone point me in the right direction? Thanks! Rick -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/42005459-38e7-454e-811e-a053edbfbce6n%40googlegroups.com.
[web2py] Re: web2py Rocket support for python 3.6+
Hi Massimo, I appreciate the response. I agree, I've found web2py with rocket to be very stable for us. I want to continue to use it because it provides a nice, simple setup for our internal apps. The problems I see are related to scans our security team runs. Those scans try to check for known issues and such and sometimes will act in a way that is antagonistic. I suspect the error handling somewhere in the stack is not robust enough and results in a hang. I encountered this some time ago with an older python 2.7 but since our system has been patched ( normal monthly RHEL patches by admin team) over time the problem stopped. I've found that running with rh-python35 our apps can also endure through the scans. There will be some SSL and rocket error messages but the web2py app continues to function. However, with rh-python36 (it's 3.6.9, right now) the hang condition will persist. Do you think this sort of problem warrants some kind of investigation or problem submission against web2py? Or is it something where I should wait on the next rh-python36 or newer and try again? One last thing, is there a way to configure Rocket to limit the TLS support for SSL to TLS1.2? Regards, Rick -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/fa03f2d7-f834-4536-9ecf-35dda9812ac1%40googlegroups.com.
[web2py] web2py Rocket support for python 3.6+
Can anyone comment on the ongoing support for Rocket web server (with SSL/Https) with Web2py? My environment is RHEL Linux 7. I've been running on python 2.7.x for long time. I recently moved an app to python 3.6.3 ( I use Red Hat SCL rh-python35 and rh-python36) and ran into some times when web2py would hang and require restart to begin serving users again. I then switched to python 3.5.1 and have had much better reliability. But I do want to move forward with 3.6. Since then, I've tried a little searching around and it seems Rocket may not be getting a lot of support from maintainers. ( i.e. https://github.com/explorigin/Rocket/issues/10 ). Would anyone like to comment about the future of Rocket, please ? Regards, Rick. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/224261a9-b2f8-4469-8656-948f227fde89%40googlegroups.com.
[web2py] Re: Internal only functions in controllers
Thanks, Stifan. I verified double underscore returns invalid function. This will work for me. On Friday, May 18, 2018 at 11:25:34 AM UTC-4, 黄祥 wrote: > > think there are 2 solution for this: > 1. use double underscore as a function name in controller e.g. def > __validate_function() > 2. use modules (e.g. modules/somemodule.py) and import it on the > controller or function that need that module > > best regards, > stifan > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Internal only functions in controllers
Hi All, Somehow I got the impression that functions in controllers that started with the "_" would not be exposed to be called when a user goes to that url. Like "https://myserver/myapp/mycontroller/_something";. But I've since realized this was a wrong impression. Is there a means to define functions such that they are not exposed and can only be called within the controller by other functions? Thanks for any help. Regards, Rick -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Version in admin lists "(Running on %s)" instead of providing server info
Hi, I see this rather old thread... But I'm running web2py from a virtualenv on rhel 7. My systemd starts web2py with: [Service] WorkingDirectory=/opt/apps/ncemon/ncemoncc4/web2py Environment=VIRTUAL_ENV="/opt/apps/ncemon/ncemoncc4/ENV" Environment=PATH="$VIRTUAL_ENV/bin:$PATH" ExecStart=/opt/apps/ncemon/ncemoncc4/ENV/bin/python web2py.py -a "" -i x.x.x.x -p -c /home/ncemoncc4/server.crt -k /home/nc" I'm sure my python is 2.7.8, but the admin page shows: Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 (Running on Rocket 1.2.6, Python 2.7.5) Is there a way to get the admin page to show the correct python version? I didn't understand some of the other comments in the thread. Thanks for the help in advance. Regards, Rick On Tuesday, August 20, 2013 at 2:26:08 AM UTC-4, Massimo Di Pierro wrote: > > Good point. Please open a ticket about this. > > On Tuesday, 20 August 2013 01:00:02 UTC-5, HittingSmoke wrote: >> >> Long ago web2py used to provide which python version it was running on in >> the admin interface. >> >> Now all I see is (Running on %s) in the admin console under the web2py >> version. >> >> How can I fix this to see which python version web2py is using? >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: memory leak?
So, I'm pretty sure I was mistaken about this being a memory leak. My app had a bug in which a SELECT form field (options widget) was being populated by hundreds of thousands of items from the db. This caused memory use to exceed server limits when the view was rendered multiple times in rapid succession. In the absence of this, garbage collection does seem to proceed normally. Sorry for the confusion. On Wednesday, April 2, 2014 4:59:43 AM UTC-5, Rick Ree wrote: > > Yes, the leak seems to be associated with rendering data in a view. > On Apr 2, 2014 3:57 AM, "Paolo Valleri" wrote: > >> I run nearly the same example: >> def f(): >> a=list(range(10)) >> return 'ok' >> After about 200 downloads the web2py process grew up to 100M. Tested on a >> system with 8Gb ram, ubuntu 12.04 >> >> paolo >> >> On Wednesday, April 2, 2014 5:57:51 AM UTC+2, Rick Ree wrote: >>> >>> Ubuntu 12.04 and 13.10. I'm running web2py from the git repo, but >>> observed this in 2.8.2 as well. >>> >>> On Tuesday, April 1, 2014 10:40:55 PM UTC-5, Massimo Di Pierro wrote: >>>> >>>> This should not be happening. What OS? What wev2py version? >>>> >>>> On Tuesday, 1 April 2014 10:00:08 UTC-5, Rick Ree wrote: >>>>> >>>>> Hi, >>>>> >>>>> If I create a new app and put a single function in default.py: >>>>> >>>>> def f(): >>>>> return dict(a=list(range(10))) >>>>> >>>>> and then repeatedly call this using wget, e.g. wget >>>>> http://localhost:8000/default/f.html, then memory usage of web2py >>>>> will creep higher with each call. Is this a memory leak, or will the >>>>> memory >>>>> eventually be reclaimed? Is there something I can do in f() to avoid this? >>>>> >>>>> thanks, >>>>> -Rick >>>>> >>>> -- >> Resources: >> - http://web2py.com >> - http://web2py.com/book (Documentation) >> - http://github.com/web2py/web2py (Source code) >> - https://code.google.com/p/web2py/issues/list (Report Issues) >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "web2py-users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/web2py/_cB4Ibm5ilc/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> web2py+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: memory leak?
Ubuntu 12.04 and 13.10. I'm running web2py from the git repo, but observed this in 2.8.2 as well. On Tuesday, April 1, 2014 10:40:55 PM UTC-5, Massimo Di Pierro wrote: > > This should not be happening. What OS? What wev2py version? > > On Tuesday, 1 April 2014 10:00:08 UTC-5, Rick Ree wrote: >> >> Hi, >> >> If I create a new app and put a single function in default.py: >> >> def f(): >> return dict(a=list(range(10))) >> >> and then repeatedly call this using wget, e.g. wget >> http://localhost:8000/default/f.html, then memory usage of web2py will >> creep higher with each call. Is this a memory leak, or will the memory >> eventually be reclaimed? Is there something I can do in f() to avoid this? >> >> thanks, >> -Rick >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: memory leak?
On Tuesday, April 1, 2014 3:55:43 PM UTC-5, Derek wrote: > > question 1 - sure, the memory should be reclaimed eventually. You could > tell the gc to collect immediately, but it operates on it's own time. Even > the .NET VM will hold on to memory for longer than it should if there's > nothing that needs that memory. You just call gc.collect() to have it > collect immediately. > The problem is that in the real app, gc never occurs before memory usage gets so huge that the os (Ubuntu 12.04 server) kills web2py. > question 2 - yea, don't do that :) try 'xrange(10)' which is more > memory efficient. > I don't see how that will help if the full list needs to be rendered in a view. Basically my problem is that I have a controller function that constructs a dictionary from some db queries that gets serialized in a json view. Repeated calls to this function leak memory, and I'm trying to figure out if this is a bug in web2py. The example I gave is the simplest case that shows the problem. > > On Tuesday, April 1, 2014 8:00:08 AM UTC-7, Rick Ree wrote: >> >> Hi, >> >> If I create a new app and put a single function in default.py: >> >> def f(): >> return dict(a=list(range(10))) >> >> and then repeatedly call this using wget, e.g. wget >> http://localhost:8000/default/f.html, then memory usage of web2py will >> creep higher with each call. Is this a memory leak, or will the memory >> eventually be reclaimed? Is there something I can do in f() to avoid this? >> >> thanks, >> -Rick >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] memory leak?
Hi, If I create a new app and put a single function in default.py: def f(): return dict(a=list(range(10))) and then repeatedly call this using wget, e.g. wget http://localhost:8000/default/f.html, then memory usage of web2py will creep higher with each call. Is this a memory leak, or will the memory eventually be reclaimed? Is there something I can do in f() to avoid this? thanks, -Rick -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: "settings site" membership_panel and AJAX
Thanks a lot! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: "settings site" membership_panel and AJAX
Sorry for the thread. I read this link and thought that *membership_panel*was a part of web2py: http://www.web2pyslices.com/slice/show/1542/manage-users-and-memebership-in-the-same-form but now I've fixed the problem by studying *virtual fields*. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] "settings site" membership_panel and AJAX
Hi, I'm trying to make a setting-site for the logged in user, but it doesn't work. I try to use the membership_panel, but desipte of searching, I haven't found any tutorial or similar about the panel. Thanks in advance for help! Here is the code: @auth.requires_login() def user_settings(): membership_panel = LOAD(request.controller, 'manage_membership.html', #current user id: args=auth.user.id, ajax=True) return dict(membership_panel=membership_panel) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: record versioning: what if tables are manually changed with migrate=False?
Thanks Massimo. For this app we use migrate=False for all tables because of issues that arose in the context of distributed development using git. Basically, developers are using different MySQL servers, not all on localhost. So the *.table files were different, and so we did not put them in version control. With automatic migrations enabled, this seemed to cause problems when the database structure changed. Not sure if I am explaining this very clearly. In any case, we found it easier to manage table models manually, and distribute sql files for altering tables. I guess what this means is that using web2py's record versioning is not a good idea if we want to continue to avoid automatic migrations of the archive tables. If that is not the case, please enlighten me - thanks! -Rick On Wednesday, January 16, 2013 9:22:03 AM UTC-6, Massimo Di Pierro wrote: > > If you do > > db=DAL(, migrate_enabled=True) # default behavior > > auth.enable_record_versioning(db) > db.define_table('something',, migrate=False) > ... > > The migrate=False only affect the "something" table. If you change its > model that table will not migrate but associated archive table will. > > If instead migrate_enabled=False, none of the tables will migrate. > > > > On Tuesday, 15 January 2013 22:09:28 UTC-6, Rick Ree wrote: >> >> Hi, >> >> I would like to enable record versioning on an existing MySQL database in >> which all tables are managed manually (migrate=False). I am concerned about >> what happens if the structure of a table changes in db.define_table( ... ). >> Is the associated archive table changed to match accordingly? >> >> thanks, >> -Rick >> > --
[web2py] record versioning: what if tables are manually changed with migrate=False?
Hi, I would like to enable record versioning on an existing MySQL database in which all tables are managed manually (migrate=False). I am concerned about what happens if the structure of a table changes in db.define_table( ... ). Is the associated archive table changed to match accordingly? thanks, -Rick --
[web2py] dropping Janrain and migrating users to new login system?
Hi, I'm developing an application that currently uses Janrain for authentication. I'm running an instance of the app that has a dozen users or so. I would like to redesign the app so that it can be installed by end users without requiring signing up with Janrain. So, I'm thinking of switching to SMTP authentication using Gmail. If I switch to SMTP logins for the instance I'm running, how do I migrate existing users, who now log in using Janrain? Is it possible? thanks, -Rick --
Re: [web2py] Overlapping periods
Thanks for the replies. Pbreit, you pointed the real issue -- what should I call the arguments (addperiodform.vars.id), that are passed from the goal function to the addingperiod function? from the controller file: def goal(): ...some code... addperiodform = SQLFORM(db.period, fields=['begindate','enddate', 'planned'], labels={'begindate':'First day','enddate':'Last day','planned':'Goal'},submit_button='Submit',formstyle='table2cols') if addperiodform.accepts(request.post_vars, session): redirect(URL('default', 'addingperiod', args=addperiodform.vars.id)) ...some code... def addingperiod(): if request.args and request.args[0]: item_id=request.args[0] prerecords = db().select(db.period.ALL, orderby=db.period.begindate) for prerecord in prerecords: if prerecord.theauth==auth.user_id: accepted1="true" accepted2="true" ...some if-statements... if accepted1=="true": if accepted2=="true": db.period.insert(item_id) #this line creates an error redirect(URL(f='goal')) On Saturday, April 14, 2012 10:44:28 AM UTC+2, backseat wrote: > > On Fri, 13 Apr 2012 11:38:25 -0700 (PDT), sababa.sab...@gmail.com said: > > > The > > function should only add periods that doesn't overlap any of the > > already registered ones. > > Let me try to help (I owe this group a lot of help). I've ignored your > code, and I don't know what schema you're using, but here's the pseudo > and untested code: > > def should_this_period_be_inserted(start,end): > # Check that all periods that started before this one > # also finished before this one started > q = ((db.period.begindatestart)) > if db(query).count(): > return False > # Check that no periods started while this one was in progress > q = ((db.period.begindate>=start)&(db.period.begindate<=end)) > if db(query).count(): > return False > # If we got this far, the period didn't overlap > return True > > Have I understood what you're trying to do? > -- > "You can have everything in life you want if you help enough other people > get what they want" - Zig Ziglar. > > Who did you help today? > >
[web2py] Overlapping periods
Hi, I try to make a function that puts periods of time into a database. The function should only add periods that doesn't overlap any of the already registered ones. But the function does not work, and I can't see what's wrong. Any idea? Thanks in advance for help! code from the controller file: def addingperiod(): if request.args and request.args[0]: item_id=request.args[0] prerecords = db().select(db.period.ALL, orderby=db.period.begindate) if not session.timedelta2==timedelta(days=0): for prerecord in prerecords: if prerecord.theauth==auth.user_id: accepted1="true" accepted2="true" if previous.enddate: if item_id.vars.begindate < previousenddate: accepted1="false" if item_id.vars.enddate < prerecord.begindate: accepted2="false" if item_id.vars.enddate < prerecord.enddate: accepted2="false" previousenddate = prerecord.enddate if accepted1=="true": if accepted2=="true": period.append(item_id) redirect(URL(c=request.controller,f='goal'))
[web2py] Re: Database auditing - comments please
In case anyone else is using this, I found that 1.99.7 requires a change at line 78: #rows = self.select(query, ['id'], {}) rows = self.select(query, [table['id']], {}) On Monday, July 25, 2011 2:57:05 PM UTC-5, nick name wrote: > > Newer version attached, has been tested in one specific app which brought > up some issues with tables that have references to them (these have been > fixed). > > Now patches instance instead of class (so web2py's normal reloading works > equally well) > > Massimo / Jonathan - could you comment on the probability that something > like this would be added to the main web2py distribution? At the very > least, hooks that one could use to implement such > audit/authorization/logging functionality without having to patch adapters? > > I'd be happy to contribute a patch for this, if you give me an indication > of how you'd like to see it implemented, if at all. > > On Monday, July 25, 2011 2:57:05 PM UTC-5, nick name wrote: > > Newer version attached, has been tested in one specific app which brought > up some issues with tables that have references to them (these have been > fixed). > > Now patches instance instead of class (so web2py's normal reloading works > equally well) > > Massimo / Jonathan - could you comment on the probability that something > like this would be added to the main web2py distribution? At the very > least, hooks that one could use to implement such > audit/authorization/logging functionality without having to patch adapters? > > I'd be happy to contribute a patch for this, if you give me an indication > of how you'd like to see it implemented, if at all. > > On Monday, July 25, 2011 2:57:05 PM UTC-5, nick name wrote: > > Newer version attached, has been tested in one specific app which brought > up some issues with tables that have references to them (these have been > fixed). > > Now patches instance instead of class (so web2py's normal reloading works > equally well) > > Massimo / Jonathan - could you comment on the probability that something > like this would be added to the main web2py distribution? At the very > least, hooks that one could use to implement such > audit/authorization/logging functionality without having to patch adapters? > > I'd be happy to contribute a patch for this, if you give me an indication > of how you'd like to see it implemented, if at all. > > On Monday, July 25, 2011 2:57:05 PM UTC-5, nick name wrote: > > Newer version attached, has been tested in one specific app which brought > up some issues with tables that have references to them (these have been > fixed). > > Now patches instance instead of class (so web2py's normal reloading works > equally well) > > Massimo / Jonathan - could you comment on the probability that something > like this would be added to the main web2py distribution? At the very > least, hooks that one could use to implement such > audit/authorization/logging functionality without having to patch adapters? > > I'd be happy to contribute a patch for this, if you give me an indication > of how you'd like to see it implemented, if at all. > >
[web2py] Re: allow reference field to be empty?
Ah, stupid me. Thanks. On Jan 31, 8:42 am, Anthony wrote: > Not sure if this is the problem, but it should be: > > IS_IN_DB(db, ...) > > not > > IS_IN_DB(db.A, ...) > > Anthony > > > > > > > > On Tuesday, January 31, 2012 9:11:48 AM UTC-5, Rick Ree wrote: > > > I've run into a basic problem that I can't seem to figure out: > > > db.define_table('A', Field('name'), format='%(name)s') > > db.define_table( > > 'B', > > Field('number'), > > Field('name', db.A, > > requires=IS_EMPTY_OR(IS_IN_DB(db.A,'A.id','%(name)s'))) > > ) > > > All I want to do is allow db.B.name to be empty. As far as I can tell > > the requires= for db.B.name is the accepted way to do this - if I > > leave it out, SQLFORM validation will throw an error. But trying to > > insert a record into db.B using SQLFORM raises this ticket: > > > Traceback (most recent call last): > > File "/home/rree/web2py-1.99.4/gluon/restricted.py", line 204, in > > restricted > > exec ccode in environment > > File "/home/rree/web2py-1.99.4/applications/welcome/controllers/ > > appadmin.py", line 433, in > > File "/home/rree/web2py-1.99.4/gluon/globals.py", line 172, in > > > > self._caller = lambda f: f() > > File "/home/rree/web2py-1.99.4/applications/welcome/controllers/ > > appadmin.py", line 127, in insert > > form = SQLFORM(db[table], ignore_rw=ignore_rw) > > File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 862, in > > __init__ > > inp = self.widgets.options.widget(field, default) > > File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 215, in > > widget > > options = requires[0].options() > > File "/home/rree/web2py-1.99.4/gluon/validators.py", line 2453, in > > _options > > options = self.other.options() > > File "/home/rree/web2py-1.99.4/gluon/validators.py", line 460, in > > options > > self.build_set() > > File "/home/rree/web2py-1.99.4/gluon/validators.py", line 443, in > > build_set > > fields = [self.dbset.db[self.ktable][k] for k in self.fields] > > File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5542, in > > __getattr__ > > return self[key] > > File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5482, in > > __getitem__ > > return dict.__getitem__(self, str(key)) > > KeyError: 'db' > > > Am I missing something? > > > Thanks > > -Rick
[web2py] allow reference field to be empty?
I've run into a basic problem that I can't seem to figure out: db.define_table('A', Field('name'), format='%(name)s') db.define_table( 'B', Field('number'), Field('name', db.A, requires=IS_EMPTY_OR(IS_IN_DB(db.A,'A.id','%(name)s'))) ) All I want to do is allow db.B.name to be empty. As far as I can tell the requires= for db.B.name is the accepted way to do this - if I leave it out, SQLFORM validation will throw an error. But trying to insert a record into db.B using SQLFORM raises this ticket: Traceback (most recent call last): File "/home/rree/web2py-1.99.4/gluon/restricted.py", line 204, in restricted exec ccode in environment File "/home/rree/web2py-1.99.4/applications/welcome/controllers/ appadmin.py", line 433, in File "/home/rree/web2py-1.99.4/gluon/globals.py", line 172, in self._caller = lambda f: f() File "/home/rree/web2py-1.99.4/applications/welcome/controllers/ appadmin.py", line 127, in insert form = SQLFORM(db[table], ignore_rw=ignore_rw) File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 862, in __init__ inp = self.widgets.options.widget(field, default) File "/home/rree/web2py-1.99.4/gluon/sqlhtml.py", line 215, in widget options = requires[0].options() File "/home/rree/web2py-1.99.4/gluon/validators.py", line 2453, in _options options = self.other.options() File "/home/rree/web2py-1.99.4/gluon/validators.py", line 460, in options self.build_set() File "/home/rree/web2py-1.99.4/gluon/validators.py", line 443, in build_set fields = [self.dbset.db[self.ktable][k] for k in self.fields] File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5542, in __getattr__ return self[key] File "/home/rree/web2py-1.99.4/gluon/dal.py", line 5482, in __getitem__ return dict.__getitem__(self, str(key)) KeyError: 'db' Am I missing something? Thanks -Rick
[web2py] avoid logging-in-site
Hi, >From my controller file: @auth.requires_login() def create(): ... def somethingelse(): ... When the user isn't logged in but tries to open the site "create.html", then he's redirected to the logging-in-site. My problem is that I'd like the user to be redirected to "somethingelse.html" instead of the logging-in-site. How to code that? Thanks in advance for help
[web2py] Re: date and sum
Perhaps I should explain my problem once again. I'd like to summarize the values for each day in the record list. With other words, so that this: record.thedate[0] = 2011-12-01 record.value[0] = 10 record.thedate[1] = 2011-12-01 record.value[1] = 20 record.thedate[3] = 2011-12-02 record.value[3] = 10 ...becomes this: sumlist.thedate[0] = 2011-12-01 sumlist.value[0] = 30 sumlist.thedate[1] = 2011-12-02 sumlist.value[1] = 10 Here is the code: from the model file: db.define_table('day', Field('thedate','date', default=request.now), Field('value', 'integer'), Field('theauth', db.auth_user, default=auth.user_id), Field('uuid', length=64, default=uuid.uuid4())) from the controller file: prerecords = db().select(db.day.ALL, orderby=db.day.thedate) for prerecord in prerecords: if prerecord.theauth==auth.user_id: if session.adate==prerecord.thedate: records.append(prerecord) On Dec 5, 3:49 pm, Anthony wrote: > It doesn't look like you applied Massimo's solution. You're calling > select() all by itself (not as a method of a Set object) -- doesn't that > raise an error (there's no function called 'select' in web2py)? The sum > should be applied in the initial query, not on the returned rows after the > query. > > Anthony > > > > > > > > On Sunday, December 4, 2011 9:33:42 PM UTC-5, Rick wrote: > > > I tried to apply the solution to my code, but it still doesn't work. > > Here is the code: > > > prerecords = db().select(db.day.ALL, orderby=db.day.thedate) for > > prerecord in prerecords: if prerecord.theauth==auth.user_id: if > > session.adate==prerecord.thedate: records.append(prerecord) rows = > > select(records.thedate,records.value.sum(),orderby=records.thedate) > > for row in rows: print row.records.thedate, row(records.value.sum()) > > On Dec 5, 3:04 am, Massimo Di Pierro > > wrote: > > > rows = > > > db(...).select(db.table.date,db.table.value.sum(),groupby=db.table.date) > > > for row in rows: print row.table.date, row(db.table.value.sum()) > > > > mind that 'date' and 'value' are not good field names. Will work with > > > sqlite but will break with other engines. > > > > On Dec 4, 8:00 pm, Rick wrote: > > > > > Hi, > > > > I've a stack of records where records with the same date has different > > > > values, eg: > > > > record.date[0] = 2011-12-01 > > > > record.value[0] = 10 > > > > record.date[1] = 2011-12-01 > > > > record.value[1] = 20 > > > > record.date[3] = 2011-12-02 > > > > record.value[3] = 10 > > > > And now I want to summarize the values that are recorded for > > > > respective date: > > > > sumlist.date[0] = 2011-12-01 > > > > sumlist.value[0] = 30 > > > > sumlist.date[1] = 2011-12-02 > > > > sumlist.value[1] = 10 > > > > > I suppose I should use "filter" and "sum", but I don't know how. Any > > > > ideas? > > > > > Thanks in advance for help!
[web2py] Re: date and sum
I tried to apply the solution to my code, but it still doesn't work. Here is the code: prerecords = db().select(db.day.ALL, orderby=db.day.thedate)for prerecord in prerecords:if prerecord.theauth==auth.user_id: if session.adate==prerecord.thedate: records.append(prerecord) rows = select(records.thedate,records.value.sum(),orderby=records.thedate) for row in rows:print row.records.thedate, row(records.value.sum()) On Dec 5, 3:04 am, Massimo Di Pierro wrote: > rows = > db(...).select(db.table.date,db.table.value.sum(),groupby=db.table.date) > for row in rows: print row.table.date, row(db.table.value.sum()) > > mind that 'date' and 'value' are not good field names. Will work with > sqlite but will break with other engines. > > On Dec 4, 8:00 pm, Rick wrote: > > > > > > > > > Hi, > > I've a stack of records where records with the same date has different > > values, eg: > > record.date[0] = 2011-12-01 > > record.value[0] = 10 > > record.date[1] = 2011-12-01 > > record.value[1] = 20 > > record.date[3] = 2011-12-02 > > record.value[3] = 10 > > And now I want to summarize the values that are recorded for > > respective date: > > sumlist.date[0] = 2011-12-01 > > sumlist.value[0] = 30 > > sumlist.date[1] = 2011-12-02 > > sumlist.value[1] = 10 > > > I suppose I should use "filter" and "sum", but I don't know how. Any > > ideas? > > > Thanks in advance for help!
[web2py] date and sum
Hi, I've a stack of records where records with the same date has different values, eg: record.date[0] = 2011-12-01 record.value[0] = 10 record.date[1] = 2011-12-01 record.value[1] = 20 record.date[3] = 2011-12-02 record.value[3] = 10 And now I want to summarize the values that are recorded for respective date: sumlist.date[0] = 2011-12-01 sumlist.value[0] = 30 sumlist.date[1] = 2011-12-02 sumlist.value[1] = 10 I suppose I should use "filter" and "sum", but I don't know how. Any ideas? Thanks in advance for help!
[web2py] ttf and fonts
Hi, How to use a local font? I put a library with ttf-files inte the static/css directory and write this code in the css file: @font-face { font-style: normal; font-weight: normal font-family: "myfont"; src: url(ttf/DejaVuSans.ttf); } html, body { font:myfont} But it doesn't work. What is the corrcet way of doing this in web2py? Thanks in advance
[web2py] Re: Submit gutton in fields
Now I've a similar problem. How to make a button that shows a calendar when you click on it? The reason why I want to do that kind of button is that each time I try to write a date in the field the calendar pops up, even though I don't need it. Here is my code again: dayform = SQLFORM.factory( Field('thedate', 'date', label=T(''), widget=SQLFORM.widgets.date.widget), submit_button='Some text') Thanks in advance for help On Dec 1, 10:37 pm, Rick wrote: > Thanks! This is the final code: > dayform = SQLFORM.factory( > Field('thedate', 'date', label=T(''), > widget=SQLFORM.widgets.date.widget), > submit_button='Some text') > > On Dec 1, 10:12 pm, Anthony wrote: > > > > > > > > > Submit buttons are not in fields, they are added as an input element to an > > entire form. Where is that Field definition -- in a table definition or > > SQLFORM.factory? Anyway, SQLFORM takes a 'submit_button' argument, which is > > the text for the submit button. > > > Anthony > > > On Thursday, December 1, 2011 3:57:30 PM UTC-5, Rick wrote: > > > > Hi, > > > How to change the text on the submit button in fields? Here'sthe code: > > > > Field('thedate', 'date', label=T(''), > > > widget=SQLFORM.widgets.date.widget)) > > > > I tried with this, but i didn't work: > > > Field('thedate', 'date', label=T(''), > > > submit=INPUT(_type='submit'('Some text')), > > > widget=SQLFORM.widgets.date.widget)) > > > > Thanks in advance for help!
[web2py] Re: Submit gutton in fields
Thanks! This is the final code: dayform = SQLFORM.factory( Field('thedate', 'date', label=T(''), widget=SQLFORM.widgets.date.widget), submit_button='Some text') On Dec 1, 10:12 pm, Anthony wrote: > Submit buttons are not in fields, they are added as an input element to an > entire form. Where is that Field definition -- in a table definition or > SQLFORM.factory? Anyway, SQLFORM takes a 'submit_button' argument, which is > the text for the submit button. > > Anthony > > > > > > > > On Thursday, December 1, 2011 3:57:30 PM UTC-5, Rick wrote: > > > Hi, > > How to change the text on the submit button in fields? Here'sthe code: > > > Field('thedate', 'date', label=T(''), > > widget=SQLFORM.widgets.date.widget)) > > > I tried with this, but i didn't work: > > Field('thedate', 'date', label=T(''), > > submit=INPUT(_type='submit'('Some text')), > > widget=SQLFORM.widgets.date.widget)) > > > Thanks in advance for help!
[web2py] Submit gutton in fields
Hi, How to change the text on the submit button in fields? Here'sthe code: Field('thedate', 'date', label=T(''), widget=SQLFORM.widgets.date.widget)) I tried with this, but i didn't work: Field('thedate', 'date', label=T(''), submit=INPUT(_type='submit'('Some text')), widget=SQLFORM.widgets.date.widget)) Thanks in advance for help!
[web2py] Re: date variables, json and jqplot
Thanks, your answer inspired me. The solution that works is this: >From the controller file: points=[[point.thedate.strftime('%Y-%m-%d'), point.value] for point in pointlist] >From the view file: <!-- jQuery(document).ready(function() { var p = {{=XML(response.json(points))}} $.jqplot('chart1', [p], { title:'Default Date Axis', axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}}, series:[{lineWidth:4, markerOptions:{style:'square'}}] }); }); --> On Oct 8, 7:09 pm, DenesL wrote: > try > > points=[[point.thedate.strftime('%Y%m%d'), point.value] for point in > pointlist] > > or some other format that suits your needs. > > On Oct 8, 10:29 am, Rick wrote: > > > > > > > > > Hi, > > I want to draw a graph with jqplot, where the x-axis is a date- > > timeline, but I get this message: > > TypeError: datetime.date(2011, 10, 2) is not JSON serializable > > Does anyone know an easy way to pass date variable to json? > > > Thanks in advance for help. Here is some code from the files: > > > > > > From the controller file: > > points=[[point.thedate, point.value] for point in pointlist] > > return dict(points=points) > > > > > > from the view file: > > > > <!-- > > jQuery(document).ready(function() { > > $.jqplot('chart1', [{{=simplejson.dumps(points)}}], { > > title:'Default Date Axis', > > axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}}, > > series:[{lineWidth:4, markerOptions:{style:'square'}}] > > });}); > > > --> > > > > > >
[web2py] date variables, json and jqplot
Hi, I want to draw a graph with jqplot, where the x-axis is a date- timeline, but I get this message: TypeError: datetime.date(2011, 10, 2) is not JSON serializable Does anyone know an easy way to pass date variable to json? Thanks in advance for help. Here is some code from the files: >From the controller file: points=[[point.thedate, point.value] for point in pointlist] return dict(points=points) from the view file:
[web2py] Re: list and loop problem
I meant that I'd like to print on a html _page_. On Mar 10, 6:34 pm, Rick wrote: > I'd like to print the list in a html file. > > On Mar 10, 6:16 pm, Bruno Rocha wrote: > > > > > > > > > where do you want to output this? > > > in to pure HTML or in a SQLTABLE? > > > 2011/3/10 Rick > > > > Hi, > > > > I want to print a linked list and add a "delete this item" button next > > > to each item: > > > > > > [item 1][delete this item] > > > [item 2][delete this item] > > > [item 3][delete this item] > > > > > > ...but I've no clue how to write the code. The problem is to direct > > > the second delete button to the second item. > > > > Thanks in advance for help!
[web2py] Re: list and loop problem
I'd like to print the list in a html file. On Mar 10, 6:16 pm, Bruno Rocha wrote: > where do you want to output this? > > in to pure HTML or in a SQLTABLE? > > 2011/3/10 Rick > > > > > > > > > Hi, > > > I want to print a linked list and add a "delete this item" button next > > to each item: > > > > [item 1][delete this item] > > [item 2][delete this item] > > [item 3][delete this item] > > > > ...but I've no clue how to write the code. The problem is to direct > > the second delete button to the second item. > > > Thanks in advance for help!
[web2py] list and loop problem
Hi, I want to print a linked list and add a "delete this item" button next to each item: [item 1][delete this item] [item 2][delete this item] [item 3][delete this item] ...but I've no clue how to write the code. The problem is to direct the second delete button to the second item. Thanks in advance for help!
[web2py] possibly difficult database form
I'd like to do something quite challenging (in my view) with web2py. I have a table (products), where each product has one or more codes. The list of possible codes are stored in a separate table (codes), and a third table (product_codes) stores the relationship(s) between the product and the code(s). I'd like a form that allows the user, on creating a new product, to choose one or more codes for the product. I assume this would be using checkboxes, pre-populated from the codes table. Upon submission, two tables are affected: the new product goes into the product table, and one or more records into the product_codes table. Is this possible? Is it possible using CRUD or SQLFORM? I'm at a loss as to how to start this. Thank you for your help, in advance.
[web2py] Re: passing varibales
Thanks a lot! It works now. On Jan 23, 4:37 am, Jason Brower wrote: > Ok here is what I see as the problem. > What you are doing is setting variable as 0 every time you start a webpage. > Every time you start a webpage this entire file is look over as if it > was never seen before. Doing so is a great thing but you have to take > the approch differently knowing this. > For example here... > variable = 0 > session.variable = variable > this resets it to 0 at every load. > What you should do is something like this because you have data that > needs to be checked first... > if not session.variable: > session.variable = 0 > > This then checks if you have any data there (if it doesn't it returns None) > Place that at the beginning of your file where you have variable = 0 and > see if that is more of what you expected. > --- > Best Regards, > Jason Brower > > On 01/23/2011 05:15 AM, Rick wrote: > > > > > > > > > Here is some code from the controller file: > > > > variable = 0 > > > def index() > > some operations with the variable... > > > def minorvar(): > > variable-=1 > > redirect(URL('index')) > > > > I also tried with this code, but the variable isn't changed after > > redirecting it to the index-function: > > > > variable = 0 > > session. variable = variable > > > def index() > > variable=session. variable > > some operations with the variable... > > > def minorvar(): > > session.variable-=1 > > redirect(URL('index')) > > > > > On Jan 23, 3:13 am, Jason Brower wrote: > >> I would recommend that you use session.variable if that's what you want > >> to do. > >> Could we see the controller for the page before? I wonder if there is a > >> way we could put the action in there to make your code a bit cleaner. > >> BR, > >> JB > > >> On 01/23/2011 01:04 AM, Rick wrote: > > >>> Thanks for the replies. I wrote a special def for the operation: > >>> def minorvar(): > >>> variable-=1 > >>> redirect(URL('index')) > >>> ...but I get an error that says that: > >>> local variable 'variable' referenced before assignment > >>> ...even though I've defined the variable as global at the beginning of > >>> the controller file. > >>> On Jan 22, 9:19 pm, Jason Brower wrote: > >>>> Yup... I think you should do that in the controller before you pass it. > >>>> It's a two second job so not hard to do. > >>>> That and session.variable=-1 is well... -1 it should be variable-=1. > >>>> On the other had, you may be going for -1 :P and you may be using a > >>>> special loop or something that needs to change as the page is formated. > >>>> Always exceptions when you have to print from the top down and build the > >>>> page before sending it to the client. :D > >>>> BR, > >>>> Jason > >>>> On 01/22/2011 02:53 PM, b0j3 wrote: > >>>>> On 22 jan., 11:47, Rick wrote: > >>>>>> Hi, > >>>>>> My problem is that I want to make a {{=A...}} tag that also changes > >>>>>> the value of the variable session.variable, and I don't know how to do > >>>>>> this. I tried with: > >>>>>> {{=A(("[< ]"), session.variable=-1, _href=URL('function'))}} > >>>>>> ...but it didn't work. > >>>>> Hi. > >>>>> I'm not sure if that is a good way to program. Some would say, that > >>>>> you shouldn't change variable in the view so I don't think (I might be > >>>>> wrong, though), that it could work like that. > >>>>> What would you like to achieve? > >>>>> B.
[web2py] Re: passing varibales
Here is some code from the controller file: variable = 0 def index() some operations with the variable... def minorvar(): variable-=1 redirect(URL('index')) I also tried with this code, but the variable isn't changed after redirecting it to the index-function: variable = 0 session. variable = variable def index() variable=session. variable some operations with the variable... def minorvar(): session.variable-=1 redirect(URL('index')) On Jan 23, 3:13 am, Jason Brower wrote: > I would recommend that you use session.variable if that's what you want > to do. > Could we see the controller for the page before? I wonder if there is a > way we could put the action in there to make your code a bit cleaner. > BR, > JB > > On 01/23/2011 01:04 AM, Rick wrote: > > > > > > > > > Thanks for the replies. I wrote a special def for the operation: > > def minorvar(): > > variable-=1 > > redirect(URL('index')) > > ...but I get an error that says that: > > local variable 'variable' referenced before assignment > > ...even though I've defined the variable as global at the beginning of > > the controller file. > > > On Jan 22, 9:19 pm, Jason Brower wrote: > >> Yup... I think you should do that in the controller before you pass it. > >> It's a two second job so not hard to do. > >> That and session.variable=-1 is well... -1 it should be variable-=1. > >> On the other had, you may be going for -1 :P and you may be using a > >> special loop or something that needs to change as the page is formated. > >> Always exceptions when you have to print from the top down and build the > >> page before sending it to the client. :D > >> BR, > >> Jason > > >> On 01/22/2011 02:53 PM, b0j3 wrote: > > >>> On 22 jan., 11:47, Rick wrote: > >>>> Hi, > >>>> My problem is that I want to make a {{=A...}} tag that also changes > >>>> the value of the variable session.variable, and I don't know how to do > >>>> this. I tried with: > >>>> {{=A(("[< ]"), session.variable=-1, _href=URL('function'))}} > >>>> ...but it didn't work. > >>> Hi. > >>> I'm not sure if that is a good way to program. Some would say, that > >>> you shouldn't change variable in the view so I don't think (I might be > >>> wrong, though), that it could work like that. > >>> What would you like to achieve? > >>> B.
[web2py] Re: passing varibales
Thanks for the replies. I wrote a special def for the operation: def minorvar(): variable-=1 redirect(URL('index')) ...but I get an error that says that: local variable 'variable' referenced before assignment ...even though I've defined the variable as global at the beginning of the controller file. On Jan 22, 9:19 pm, Jason Brower wrote: > Yup... I think you should do that in the controller before you pass it. > It's a two second job so not hard to do. > That and session.variable=-1 is well... -1 it should be variable-=1. > On the other had, you may be going for -1 :P and you may be using a > special loop or something that needs to change as the page is formated. > Always exceptions when you have to print from the top down and build the > page before sending it to the client. :D > BR, > Jason > > On 01/22/2011 02:53 PM, b0j3 wrote: > > > > > > > > > On 22 jan., 11:47, Rick wrote: > >> Hi, > >> My problem is that I want to make a {{=A...}} tag that also changes > >> the value of the variable session.variable, and I don't know how to do > >> this. I tried with: > >> {{=A(("[< ]"), session.variable=-1, _href=URL('function'))}} > >> ...but it didn't work. > > Hi. > > > I'm not sure if that is a good way to program. Some would say, that > > you shouldn't change variable in the view so I don't think (I might be > > wrong, though), that it could work like that. > > > What would you like to achieve? > > > B.
[web2py] passing varibales
Hi, My problem is that I want to make a {{=A...}} tag that also changes the value of the variable session.variable, and I don't know how to do this. I tried with: {{=A(("[ < ]"), session.variable=-1, _href=URL('function'))}} ...but it didn't work.
[web2py] Re: account for each user
I found that this line is the error-prone one: records = db(auth.settings.table_user==auth.user).select(db.day.theauth, distinct=True, orderby=db.day.thedate) ...I tested the next version too, but it also gave an error: records = db(db.day.theauth==auth.user).select(db.day.ALL, orderby=db.day.thedate) ...The last version worked, but it doesn't fulfill the function I want it to have, namely to select records that are associated with the user that is logged in: records = db().select(db.day.ALL, orderby=db.day.thedate) Any ideas? >On Jan 16, 9:54 pm, Rick wrote: > I suppose that the problem is that the "records" list isn't completely > returned from the controller file to create.html and that the > "thedate" field is lost in that process. > > On Jan 16, 9:32 pm, Rick wrote: > > > > > > > > > Hmmm... strange... the error disappeared, but it was replaced by > > another one: > > KeyError: 'thedate' > > ...and this error arises from the html-table in the create.html -- the > > code works when i delete the table. > > > On Jan 16, 8:40 pm, Rick wrote: > > > > Perhaps the previous post was a bit vague. I meant that create.html > > > works when it only contains {{=form}}. > > > > On Jan 16, 8:35 pm, Rick wrote: > > > > > Yes, {{=form}} works without the other code. > > > > > On Jan 16, 6:35 pm, Martín Mulone wrote: > > > > > > to test, put only {{=form}} in create.html remove all the other. Now > > > > > the > > > > > error continue? > > > > > > 2011/1/16 Rick > > > > > > > thanks for the comments. I deleted the #. At the beginning of > > > > > > create.html there is this code: > > > > > > {{import datetime}} > > > > > > {{import uuid}} > > > > > > {{recording=datetime.date(2000,01,01)}} > > > > > > ...but the error remains :( > > > > > > > On Jan 16, 2:13 pm, "Martin.Mulone" wrote: > > > > > > > in create.html > > > > > > > > #if recording!=record.thedate:} > > > > > > > > you commented this line but you hasn't commented the pass, the > > > > > > > same to > > > > > > > {{#session.uuid=record.uuid}} > > > > > > > and what is recording??. > > > > > > -- > > > > > Pablo Martín Mulone > > > > > (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/ > > > > > Paraná, Entre Ríos, Argentina (CP 3100). > > > > > > My blog:http://martin.tecnodoc.com.ar > > > > > Expert4Solution > > > > > Profile:http://www.experts4solutions.com/e4s/default/expert/6
[web2py] Re: account for each user
I suppose that the problem is that the "records" list isn't completely returned from the controller file to create.html and that the "thedate" field is lost in that process. On Jan 16, 9:32 pm, Rick wrote: > Hmmm... strange... the error disappeared, but it was replaced by > another one: > KeyError: 'thedate' > ...and this error arises from the html-table in the create.html -- the > code works when i delete the table. > > On Jan 16, 8:40 pm, Rick wrote: > > > > > > > > > Perhaps the previous post was a bit vague. I meant that create.html > > works when it only contains {{=form}}. > > > On Jan 16, 8:35 pm, Rick wrote: > > > > Yes, {{=form}} works without the other code. > > > > On Jan 16, 6:35 pm, Martín Mulone wrote: > > > > > to test, put only {{=form}} in create.html remove all the other. Now > > > > the > > > > error continue? > > > > > 2011/1/16 Rick > > > > > > thanks for the comments. I deleted the #. At the beginning of > > > > > create.html there is this code: > > > > > {{import datetime}} > > > > > {{import uuid}} > > > > > {{recording=datetime.date(2000,01,01)}} > > > > > ...but the error remains :( > > > > > > On Jan 16, 2:13 pm, "Martin.Mulone" wrote: > > > > > > in create.html > > > > > > > #if recording!=record.thedate:} > > > > > > > you commented this line but you hasn't commented the pass, the same > > > > > > to > > > > > > {{#session.uuid=record.uuid}} > > > > > > and what is recording??. > > > > > -- > > > > Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/ > > > > Paraná, Entre Ríos, Argentina (CP 3100). > > > > > My blog:http://martin.tecnodoc.com.ar > > > > Expert4Solution > > > > Profile:http://www.experts4solutions.com/e4s/default/expert/6
[web2py] Re: account for each user
Hmmm... strange... the error disappeared, but it was replaced by another one: KeyError: 'thedate' ...and this error arises from the html-table in the create.html -- the code works when i delete the table. On Jan 16, 8:40 pm, Rick wrote: > Perhaps the previous post was a bit vague. I meant that create.html > works when it only contains {{=form}}. > > On Jan 16, 8:35 pm, Rick wrote: > > > > > > > > > Yes, {{=form}} works without the other code. > > > On Jan 16, 6:35 pm, Martín Mulone wrote: > > > > to test, put only {{=form}} in create.html remove all the other. Now the > > > error continue? > > > > 2011/1/16 Rick > > > > > thanks for the comments. I deleted the #. At the beginning of > > > > create.html there is this code: > > > > {{import datetime}} > > > > {{import uuid}} > > > > {{recording=datetime.date(2000,01,01)}} > > > > ...but the error remains :( > > > > > On Jan 16, 2:13 pm, "Martin.Mulone" wrote: > > > > > in create.html > > > > > > #if recording!=record.thedate:} > > > > > > you commented this line but you hasn't commented the pass, the same to > > > > > {{#session.uuid=record.uuid}} > > > > > and what is recording??. > > > > -- > > > Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/ > > > Paraná, Entre Ríos, Argentina (CP 3100). > > > > My blog:http://martin.tecnodoc.com.ar > > > Expert4Solution > > > Profile:http://www.experts4solutions.com/e4s/default/expert/6
[web2py] Re: account for each user
Perhaps the previous post was a bit vague. I meant that create.html works when it only contains {{=form}}. On Jan 16, 8:35 pm, Rick wrote: > Yes, {{=form}} works without the other code. > > On Jan 16, 6:35 pm, Martín Mulone wrote: > > > > > > > > > to test, put only {{=form}} in create.html remove all the other. Now the > > error continue? > > > 2011/1/16 Rick > > > > thanks for the comments. I deleted the #. At the beginning of > > > create.html there is this code: > > > {{import datetime}} > > > {{import uuid}} > > > {{recording=datetime.date(2000,01,01)}} > > > ...but the error remains :( > > > > On Jan 16, 2:13 pm, "Martin.Mulone" wrote: > > > > in create.html > > > > > #if recording!=record.thedate:} > > > > > you commented this line but you hasn't commented the pass, the same to > > > > {{#session.uuid=record.uuid}} > > > > and what is recording??. > > > -- > > Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/ > > Paraná, Entre Ríos, Argentina (CP 3100). > > > My blog:http://martin.tecnodoc.com.ar > > Expert4Solution > > Profile:http://www.experts4solutions.com/e4s/default/expert/6
[web2py] Re: account for each user
Yes, {{=form}} works without the other code. On Jan 16, 6:35 pm, Martín Mulone wrote: > to test, put only {{=form}} in create.html remove all the other. Now the > error continue? > > 2011/1/16 Rick > > > > > > > > > > > thanks for the comments. I deleted the #. At the beginning of > > create.html there is this code: > > {{import datetime}} > > {{import uuid}} > > {{recording=datetime.date(2000,01,01)}} > > ...but the error remains :( > > > On Jan 16, 2:13 pm, "Martin.Mulone" wrote: > > > in create.html > > > > #if recording!=record.thedate:} > > > > you commented this line but you hasn't commented the pass, the same to > > > {{#session.uuid=record.uuid}} > > > and what is recording??. > > -- > Pablo Martín Mulone (mar...@tecnodoc.com.ar)http://www.tecnodoc.com.ar/ > Paraná, Entre Ríos, Argentina (CP 3100). > > My blog:http://martin.tecnodoc.com.ar > Expert4Solution Profile:http://www.experts4solutions.com/e4s/default/expert/6
[web2py] Re: account for each user
thanks for the comments. I deleted the #. At the beginning of create.html there is this code: {{import datetime}} {{import uuid}} {{recording=datetime.date(2000,01,01)}} ...but the error remains :( On Jan 16, 2:13 pm, "Martin.Mulone" wrote: > in create.html > > #if recording!=record.thedate:} > > you commented this line but you hasn't commented the pass, the same to > {{#session.uuid=record.uuid}} > and what is recording??.
[web2py] Re: request.vars and lists question
Ah! Thank you, that works great. - rick On Jan 16, 3:10 pm, Jonathan Lundell wrote: > Try: theAnimals = request.vars.getlist("animals")
[web2py] Re: request.vars and lists question
Ah! Thank you, that works great. - rick On Jan 16, 3:10 pm, Jonathan Lundell wrote: > Try: theAnimals = request.vars.getlist("animals")
[web2py] Re: request.vars and lists question
Ah! Thank you, that works great. - rick On Jan 16, 3:10 pm, Jonathan Lundell wrote: > Try: theAnimals = request.vars.getlist("animals")
[web2py] request.vars and lists question
I have a simple function: def simpletest(animals): theAnimals = request.vars["animals"] leng = len(theAnimals) return dict(leng = leng) When I call it with two animals: http://mySite.com/myApp/default/call/run/simpletest?animals=cat&animals=dog .. I get the answer 2, as I would expect When I call it with only one animal: http://mySite.com/myApp/default/call/run/simpletest?animals=cat .. I get the answer 3, the length of the string "cat" I would prefer to get a list with only a single value, like ["cat"], of length 1. What could I do differently to make that happen? Thank you, rick
[web2py] Re: account for each user
I changed the code and I suppose I'm on the right track but I get an error message when I try to run the app: ./create.html", line 91 response.write(form) ^ SyntaxError: invalid syntax Here is the code: ===in a controller file=== @auth.requires_login() def create(): records = db(auth.settings.table_user==auth.user).select(db.day.theauth, distinct=True, orderby=db.day.thedate) form = SQLFORM(db.day, fields=['thedate','value']) if form.accepts(request.post_vars, session): session.flash = 'Saved.' redirect(URL('create')) return dict(records=records, form=form) ===in create.html=== {{for record in records:}} {{#if recording!=record.thedate:}} {{#=record.thedate}} {{pass}} {{#session.uuid=record.uuid}} {{=record.value}} {{pass}} {{=form}} ===in the model file=== auth = Auth(globals(), db) auth.define_tables(username=True) import uuid import datetime now = datetime.date.today() db.define_table('day', Field('uuid', length=64, default=uuid.uuid4()), Field('thedate','date', default=request.now), Field('value', 'integer'), Field('theauth', auth.settings.table_user)) On Jan 16, 4:58 am, Rick wrote: > Hurray, I'm getting somewhere now! Thanks pbreit, now I try to do what > I want to do without modifying the authentication functionality and it > works better. But I get the message "invalid function" when I try to > login. Here is the code: > > ===in the model file=== > auth = Auth(globals(), db) > auth.define_tables(username=True) > > ===in the controller file=== > def users(): > return users[0].id > > def admin(): > records = db().select(auth.settings.table_user.ALL, > orderby=auth.settings.table_user.username) > form = SQLFORM(auth.settings.table_user, > fields=['username','password'],) > if form.accepts(request.post_vars, session): > session.flash = 'Address saved.' > redirect(URL('admin')) > return dict(form=form, records=records) > > ===in user.html=== > {{extend 'layout.html'}} > {{=request.args(0).replace('_',' ').capitalize()}} > {{=form}} > {{if request.args(0)=='login':}} > {{pass}} > > > > > > > > >On Jan 16, 3:24 am, Rick wrote: > > ...or maybe the problem lies int this function in the controller file: > > def admin(): > > records = db().select(custom_auth_table.ALL, > > orderby=custom_auth_table.username) > > form = SQLFORM(db[auth.settings.table_user_name]) > > if form.accepts(request.post_vars, session): > > session.flash = 'saved.' > > redirect(URL('admin')) > > return dict(form=form, records=records) > > > On Jan 16, 1:08 am, Rick wrote: > > > > Perhaps I should reformulate the problem -- I want to make one table > > > for each auth-user, so that an auth-user can't see the records of > > > ohters auth-users. > > > > On Jan 15, 11:52 pm, pbreit wrote: > > > > > I may not understand either. The user authentication functionality is > > > > automatically provided by web2py scaffolding. I would suggest using it > > > > without modifications until you run into limitations.
[web2py] Re: account for each user
Hurray, I'm getting somewhere now! Thanks pbreit, now I try to do what I want to do without modifying the authentication functionality and it works better. But I get the message "invalid function" when I try to login. Here is the code: ===in the model file=== auth = Auth(globals(), db) auth.define_tables(username=True) ===in the controller file=== def users(): return users[0].id def admin(): records = db().select(auth.settings.table_user.ALL, orderby=auth.settings.table_user.username) form = SQLFORM(auth.settings.table_user, fields=['username','password'],) if form.accepts(request.post_vars, session): session.flash = 'Address saved.' redirect(URL('admin')) return dict(form=form, records=records) ===in user.html=== {{extend 'layout.html'}} {{=request.args(0).replace('_',' ').capitalize()}} {{=form}} {{if request.args(0)=='login':}} {{pass}} >On Jan 16, 3:24 am, Rick wrote: > ...or maybe the problem lies int this function in the controller file: > def admin(): > records = db().select(custom_auth_table.ALL, > orderby=custom_auth_table.username) > form = SQLFORM(db[auth.settings.table_user_name]) > if form.accepts(request.post_vars, session): > session.flash = 'saved.' > redirect(URL('admin')) > return dict(form=form, records=records) > > On Jan 16, 1:08 am, Rick wrote: > > > > > > > > > Perhaps I should reformulate the problem -- I want to make one table > > for each auth-user, so that an auth-user can't see the records of > > ohters auth-users. > > > On Jan 15, 11:52 pm, pbreit wrote: > > > > I may not understand either. The user authentication functionality is > > > automatically provided by web2py scaffolding. I would suggest using it > > > without modifications until you run into limitations.
[web2py] Re: account for each user
...or maybe the problem lies int this function in the controller file: def admin(): records = db().select(custom_auth_table.ALL, orderby=custom_auth_table.username) form = SQLFORM(db[auth.settings.table_user_name]) if form.accepts(request.post_vars, session): session.flash = 'saved.' redirect(URL('admin')) return dict(form=form, records=records) On Jan 16, 1:08 am, Rick wrote: > Perhaps I should reformulate the problem -- I want to make one table > for each auth-user, so that an auth-user can't see the records of > ohters auth-users. > > On Jan 15, 11:52 pm, pbreit wrote: > > > > > > > > > I may not understand either. The user authentication functionality is > > automatically provided by web2py scaffolding. I would suggest using it > > without modifications until you run into limitations.
[web2py] Re: account for each user
Perhaps I should reformulate the problem -- I want to make one table for each auth-user, so that an auth-user can't see the records of ohters auth-users. On Jan 15, 11:52 pm, pbreit wrote: > I may not understand either. The user authentication functionality is > automatically provided by web2py scaffolding. I would suggest using it > without modifications until you run into limitations.
[web2py] Re: account for each user
Thanks for the replies. My problem is that with the code I can create one account for all users, but I want to create one account for each user. >On Jan 4, 1:14 am, Martín Mulone wrote: > Commonly in internet, the users create their accounts, via > (/myapp/default/user/register/) > > But if you want to create some accounts take a look to this: > > def new_user(first_name, last_name, email, passw): > > users = db(db.auth_user.email==email).select() > if users: > return users[0].id > else: > my_crypt = CRYPT(key=auth.settings.hmac_key) > crypt_pass = my_crypt(passw)[0] > id_user= db.auth_user.insert( > first_name=first_name, > last_name=last_name, > email = email, > password = crypt_pass > > ) > return id_user > > iduser = new_user('Chris','Mills','ch...@nobody.com','somepasswordhere') > > 2011/1/3 mdipierro : > > > > > > > > > > > I do not understand the question.sorry. > > > On Jan 3, 3:46 pm, Rick wrote: > >> Hi, > > >> I suppose that this is a very elementary question, but I can't find > >> the solution. My question is -- how to make a account for each user? > > >> I've tried with this code, but it gives just one account for all user: > > >> ==on the model file== > >> db.define_table( > >> auth.settings.table_user_name, > >> Field('username'), > >> Field('password'), > >> Field('registration_key', default='')) > >> auth.define_tables() > >> custom_auth_table = db[auth.settings.table_user_name] # get the > >> custom_auth_table > >> db.define_table('day', > >> Field('person', db[auth.settings.table_user_name]), > >> Field('thedate','date'), > >> Field('value', 'integer')) > > >> ==in a controller file== > >> @auth.requires_login() > >> def create(): > >> some code > > >> def user(): > >> return dict(form=auth()) > > -- > My blog:http://martin.tecnodoc.com.ar > My portfolio *spanish*:http://www.tecnodoc.com.ar > Checkout my last proyect instant-press:http://www.instant2press.com > Expert4Solution Profile:http://www.experts4solutions.com/e4s/default/expert/6
[web2py] Re: Number of records
So the problem was that the controller file line creates an error when I add the 'id' field and 'migrate=False' to the day table. Here is some more code: ===in the model file=== import datetime now = datetime.date.today() db.define_table('day', Field('the_id', 'id'), Field('thedate','date', default=request.now), Field('value', 'integer'), migrate=False) ===in the controller file=== records = db().select(db.day.ALL, orderby=db.day.thedate) On Jan 15, 8:16 am, Kenneth Lundström wrote: > Could you shows us the relevant part of your models file, where the > table is defined and then also the error ticket. > > Kenneth > > > > > > > > > Thanks for the suggestion! The 'id' field looks like a smart solution. > > But there seem to be a problem -- This line creates an error when I > > add the 'id' field and 'migrate=False' to the day table: > > records = db().select(db.day.ALL, orderby=db.day.thedate) > > Any ideas? > > > On Jan 4, 4:03 am, Fabiano wrote: > >> What stops you from using 'id' field?
[web2py] Re: Number of records
Thanks for the suggestion! The 'id' field looks like a smart solution. But there seem to be a problem -- This line creates an error when I add the 'id' field and 'migrate=False' to the day table: records = db().select(db.day.ALL, orderby=db.day.thedate) Any ideas? On Jan 4, 4:03 am, Fabiano wrote: > What stops you from using 'id' field?
[web2py] account for each user
Hi, I suppose that this is a very elementary question, but I can't find the solution. My question is -- how to make a account for each user? I've tried with this code, but it gives just one account for all user: ==on the model file== db.define_table( auth.settings.table_user_name, Field('username'), Field('password'), Field('registration_key', default='')) auth.define_tables() custom_auth_table = db[auth.settings.table_user_name] # get the custom_auth_table db.define_table('day', Field('person', db[auth.settings.table_user_name]), Field('thedate','date'), Field('value', 'integer')) ==in a controller file== @auth.requires_login() def create(): some code def user(): return dict(form=auth())
[web2py] Re: Number of records
Unfortunately the code bellow seems to be errors-prone: ==in a model file== class MyVirtualFields(object): def input_number(self): return some_variable db.input.virtualfields.append(MyVirtualFields()) >On Jan 3, 8:03 pm, Rick wrote: > Perhaps this would be a good idea to keep track of the records: > > ==in a model file== > n = 0 > class MyVirtualFields(): > def day_number(self): > n=n+1 > return n > > but I'm not sure about how to write this idea properly in python. > Perhaps there should be some kind of loop in the controller file? > > On Jan 3, 7:39 pm, Rick wrote: > > > > > > > > > Thanks for the replies. Now I try to add the ability to delete > > records, but it doesn't seem to work: > > db(db.input.virtualfields==session.virtualfields).delete() > > > >On Jan 3, 1:52 pm, Bruno Rocha wrote: > > > [ Copy Paste Mystake ] > > > > Correct is: > > > > you have two options: > > > > 1. define the virtual fields in model > > > > =in a model file== > > > db.define_table('input', > > > Field('value', 'integer')) > > > class MyVirtualFields(object): > > > def input_number(self): > > > return self.input.value > > > > db.input.virtualfields.append(MyVirtualFields()) > > > > 2. In controller use the setvirtualfields method of Rows > > > > ==in a controller file== > > > records = db(db.input.id>0).select() # or any other query > > > records.setvirtualfields(virtual=MyVirtualFields()) > > > > > 2011/1/3 Rick > > > > > Thanks for the advice. I changed my code, but I don't know if I'm on > > > >> the right track. Anyhow it doesn't work. > > > > >> ==in a model file== > > > >> db.define_table('input', > > > >> Field('value', 'integer')) > > > >> class MyVirtualFields(object): > > > >> def input_number(self): > > > >> return self.input.value > > > > >> ==in a controller file== > > > >> def create(): > > > >> records = db().select(db.day.ALL, orderby=db.day.thedate) > > > >> form = SQLFORM(db.input, fields=['value']) > > > >> db.day.virtualfields.append(MyVirtualFields()) > > > >> return dict(form = form) > > > >> def deleterec(): > > > >> session.virtualfields.remove(MyVirtualFields()) > > > >> db.input.input_number.remove(MyVirtualFields()) > > > >> redirect(URL('create')) > > > > >> ==in create.html== > > > >> {{for record in records:}} > > > >> {{session.virtualfields=record.virtualfields}} > > > >> {{=record.value}} : [ {{=A(("Delete this record"), > > > >> _href=URL('deleterec'))}} > > > > >> >On Jan 2, 10:36 pm, Kenneth Lundström > > > >> wrote: > > > >> > If you only want to display a number I guess virtual fields is what > > > >> > you > > > >> > need. Look at > > > > >> >http://www.web2py.com/book/default/chapter/06?search=virtual#Virtual-. > > > >> .. > > > > >> > Kenneth > > > > >> > > Hi, > > > >> > > In addition to the records that are submitted with a SQLFORM, I > > > >> > > want > > > >> > > to give each record a specific "identification" number, so that the > > > >> > > first record has number=1 and so on: > > > > >> > > ==from model/db.py== > > > >> > > db.define_table('input', > > > >> > > Field('number', 'integer'), > > > >> > > Field('value', 'integer')) > > > > >> > > ...My problem is that I don't know how to automatically add the > > > >> > > number > > > >> > > to this form: > > > >> > > form = SQLFORM(db.input, fields=['value']) > > > > >> > > Thanks in advance for help. > > > > > -- > > > > > Bruno Rocha > > > >http://about.me/rochacbruno/bio > > > > -- > > > > Bruno Rochahttp://about.me/rochacbruno/bio
[web2py] Re: Number of records
Perhaps this would be a good idea to keep track of the records: ==in a model file== n = 0 class MyVirtualFields(): def day_number(self): n=n+1 return n but I'm not sure about how to write this idea properly in python. Perhaps there should be some kind of loop in the controller file? On Jan 3, 7:39 pm, Rick wrote: > Thanks for the replies. Now I try to add the ability to delete > records, but it doesn't seem to work: > db(db.input.virtualfields==session.virtualfields).delete() > > > > > > > > >On Jan 3, 1:52 pm, Bruno Rocha wrote: > > [ Copy Paste Mystake ] > > > Correct is: > > > you have two options: > > > 1. define the virtual fields in model > > > =in a model file== > > db.define_table('input', > > Field('value', 'integer')) > > class MyVirtualFields(object): > > def input_number(self): > > return self.input.value > > > db.input.virtualfields.append(MyVirtualFields()) > > > 2. In controller use the setvirtualfields method of Rows > > > ==in a controller file== > > records = db(db.input.id>0).select() # or any other query > > records.setvirtualfields(virtual=MyVirtualFields()) > > > > 2011/1/3 Rick > > > > Thanks for the advice. I changed my code, but I don't know if I'm on > > >> the right track. Anyhow it doesn't work. > > > >> ==in a model file== > > >> db.define_table('input', > > >> Field('value', 'integer')) > > >> class MyVirtualFields(object): > > >> def input_number(self): > > >> return self.input.value > > > >> ==in a controller file== > > >> def create(): > > >> records = db().select(db.day.ALL, orderby=db.day.thedate) > > >> form = SQLFORM(db.input, fields=['value']) > > >> db.day.virtualfields.append(MyVirtualFields()) > > >> return dict(form = form) > > >> def deleterec(): > > >> session.virtualfields.remove(MyVirtualFields()) > > >> db.input.input_number.remove(MyVirtualFields()) > > >> redirect(URL('create')) > > > >> ==in create.html== > > >> {{for record in records:}} > > >> {{session.virtualfields=record.virtualfields}} > > >> {{=record.value}} : [ {{=A(("Delete this record"), > > >> _href=URL('deleterec'))}} > > > >> >On Jan 2, 10:36 pm, Kenneth Lundström > > >> wrote: > > >> > If you only want to display a number I guess virtual fields is what you > > >> > need. Look at > > > >> >http://www.web2py.com/book/default/chapter/06?search=virtual#Virtual-. > > >> .. > > > >> > Kenneth > > > >> > > Hi, > > >> > > In addition to the records that are submitted with a SQLFORM, I want > > >> > > to give each record a specific "identification" number, so that the > > >> > > first record has number=1 and so on: > > > >> > > ==from model/db.py== > > >> > > db.define_table('input', > > >> > > Field('number', 'integer'), > > >> > > Field('value', 'integer')) > > > >> > > ...My problem is that I don't know how to automatically add the > > >> > > number > > >> > > to this form: > > >> > > form = SQLFORM(db.input, fields=['value']) > > > >> > > Thanks in advance for help. > > > > -- > > > > Bruno Rocha > > >http://about.me/rochacbruno/bio > > > -- > > > Bruno Rochahttp://about.me/rochacbruno/bio
[web2py] Re: Number of records
Thanks for the replies. Now I try to add the ability to delete records, but it doesn't seem to work: db(db.input.virtualfields==session.virtualfields).delete() >On Jan 3, 1:52 pm, Bruno Rocha wrote: > [ Copy Paste Mystake ] > > Correct is: > > you have two options: > > 1. define the virtual fields in model > > =in a model file== > db.define_table('input', > Field('value', 'integer')) > class MyVirtualFields(object): > def input_number(self): > return self.input.value > > db.input.virtualfields.append(MyVirtualFields()) > > 2. In controller use the setvirtualfields method of Rows > > ==in a controller file== > records = db(db.input.id>0).select() # or any other query > records.setvirtualfields(virtual=MyVirtualFields()) > > > > > > > > > > > > > 2011/1/3 Rick > > > Thanks for the advice. I changed my code, but I don't know if I'm on > >> the right track. Anyhow it doesn't work. > > >> ==in a model file== > >> db.define_table('input', > >> Field('value', 'integer')) > >> class MyVirtualFields(object): > >> def input_number(self): > >> return self.input.value > > >> ==in a controller file== > >> def create(): > >> records = db().select(db.day.ALL, orderby=db.day.thedate) > >> form = SQLFORM(db.input, fields=['value']) > >> db.day.virtualfields.append(MyVirtualFields()) > >> return dict(form = form) > >> def deleterec(): > >> session.virtualfields.remove(MyVirtualFields()) > >> db.input.input_number.remove(MyVirtualFields()) > >> redirect(URL('create')) > > >> ==in create.html== > >> {{for record in records:}} > >> {{session.virtualfields=record.virtualfields}} > >> {{=record.value}} : [ {{=A(("Delete this record"), > >> _href=URL('deleterec'))}} > > >> >On Jan 2, 10:36 pm, Kenneth Lundström > >> wrote: > >> > If you only want to display a number I guess virtual fields is what you > >> > need. Look at > > >> >http://www.web2py.com/book/default/chapter/06?search=virtual#Virtual-. > >> .. > > >> > Kenneth > > >> > > Hi, > >> > > In addition to the records that are submitted with a SQLFORM, I want > >> > > to give each record a specific "identification" number, so that the > >> > > first record has number=1 and so on: > > >> > > ==from model/db.py== > >> > > db.define_table('input', > >> > > Field('number', 'integer'), > >> > > Field('value', 'integer')) > > >> > > ...My problem is that I don't know how to automatically add the number > >> > > to this form: > >> > > form = SQLFORM(db.input, fields=['value']) > > >> > > Thanks in advance for help. > > > -- > > > Bruno Rocha > >http://about.me/rochacbruno/bio > > -- > > Bruno Rochahttp://about.me/rochacbruno/bio
[web2py] Re: Number of records
Thanks for the advice. I changed my code, but I don't know if I'm on the right track. Anyhow it doesn't work. ==in a model file== db.define_table('input', Field('value', 'integer')) class MyVirtualFields(object): def input_number(self): return self.input.value ==in a controller file== def create(): records = db().select(db.day.ALL, orderby=db.day.thedate) form = SQLFORM(db.input, fields=['value']) db.day.virtualfields.append(MyVirtualFields()) return dict(form = form) def deleterec(): session.virtualfields.remove(MyVirtualFields()) db.input.input_number.remove(MyVirtualFields()) redirect(URL('create')) ==in create.html== {{for record in records:}} {{session.virtualfields=record.virtualfields}} {{=record.value}} : [ {{=A(("Delete this record"), _href=URL('deleterec'))}} >On Jan 2, 10:36 pm, Kenneth Lundström wrote: > If you only want to display a number I guess virtual fields is what you > need. Look at > > http://www.web2py.com/book/default/chapter/06?search=virtual#Virtual-... > > Kenneth > > > > > > > > > Hi, > > In addition to the records that are submitted with a SQLFORM, I want > > to give each record a specific "identification" number, so that the > > first record has number=1 and so on: > > > ==from model/db.py== > > db.define_table('input', > > Field('number', 'integer'), > > Field('value', 'integer')) > > > ...My problem is that I don't know how to automatically add the number > > to this form: > > form = SQLFORM(db.input, fields=['value']) > > > Thanks in advance for help.
[web2py] Number of records
Hi, In addition to the records that are submitted with a SQLFORM, I want to give each record a specific "identification" number, so that the first record has number=1 and so on: ==from model/db.py== db.define_table('input', Field('number', 'integer'), Field('value', 'integer')) ...My problem is that I don't know how to automatically add the number to this form: form = SQLFORM(db.input, fields=['value']) Thanks in advance for help.
[web2py] Re: How to delete a user?
Thanks a lot! I find this being a good solution: ==in admin.html== {{=A(("Delete this user"), _href=URL('deleteusr'))}} ==in the controller file== def deleteusr(): db(custom_auth_table.username==session.username).delete() redirect(URL('admin')) On Jan 2, 8:19 pm, Jonathan Lundell wrote: > On Jan 2, 2011, at 11:10 AM, Arun K.Rajeevan wrote: > > > Try this, > > Delete this > > user > > > I haven't tested, but must work. > > If I were coding this for myself, I think I'd self-submit and conditionally > do the user-delete and redirect in the original controller.
[web2py] Re: How to delete a user?
Thanks, I changed the code to this: Users: ==in admin.html== {{for record in records:}} {{=record.username}} : {{=record.password}} [ {{session.username=record.username}} Delete this user ] {{pass}} ==in a controller file== def deleteusr(): db(custom_auth_table.username==session.username).delete() return 'the record has been deleted' ...but I don't know how to reload the page automatically after deleting a user. Any ideas? On Jan 2, 5:13 pm, Jonathan Lundell wrote: > On Jan 2, 2011, at 7:01 AM, Rick wrote: > > > > > I changed the code but it still doesn't work: > > Here's a fragment of my code that I use to delete a user. It's not ajax, but > you'll get the idea: > > ut = auth.settings.table_user > uu = urow.auth_user > ... > if not db(ut.username == username).count(): > ...complain and redirect... > auth.del_group(auth.user_group(uu.id)) # uu.id is the user id > I'm deleting > db(ut.username == username).delete() > > If you look at auth.del_group, you'll see that it does quite a bit of work to > clean a user out of the group tables. I think I picked up this logic from the > admin app, but I don't quite remember. > > I think it'd be nice if auth had a comprehensive delete-user function. > > > > > > > > > > > ==admin.html== > > {{extend 'layout.html'}} > > Add a user: > > {{=form}} > > > > Users: > > > > {{for record in records:}} > > {{=record.username}} : {{=record.password}} > > [ > > > onclick="ajax('{{=URL('db(auth.settings.table_user_name==record.username).d > > elete()')}}', > > [],'')">Delete this user > > ] > > {{pass}} > > > > > ==Here is some code from models/db.py== > > auth = Auth(globals(), db) > > > db.define_table( > > auth.settings.table_user_name, > > Field('username'), > > Field('password'), > > Field('registration_key', default='')) > > > auth.define_tables() > > > custom_auth_table = db[auth.settings.table_user_name] # get the > > custom_auth_table > > == > > > On Dec 30 2010, 6:21 pm, Rick wrote: > >> Hi, > > >> I don't know if the way I add users is proper, but it works. Now I try > >> to write a tag for deleting users, and it doesn't work. Here is > >> the code: > > >> ==in a controller file== > >> def admin(): > >> records = db().select(custom_auth_table.ALL, > >> orderby=custom_auth_table.username) > >> #records = SQLFORM(custom_auth_table, user, deletable=True) > >> form = SQLFORM(db[auth.settings.table_user_name]) > >> if form.accepts(request.post_vars, session): > >> session.flash = 'Address saved.' > >> redirect(URL('admin')) > >> return dict(form=form, records=records) > >> > > >> ==admin.html== > >> {{extend 'layout.html'}} > >> Add a user: > >> {{=form}} > >> > >> Users: > >> > >> {{for record in records:}} > >> {{=record.username}} : {{=record.password}} > >> [ > >> >> onclick="ajax('{{=URL('db[auth.remove.record.username]')}}', > >> [],'')">Delete this user > >> ] > >> > >> {{pass}} > >> > > >> Thanks in advance for help
[web2py] Re: How to delete a user?
I changed the code but it still doesn't work: ==admin.html== {{extend 'layout.html'}} Add a user: {{=form}} Users: {{for record in records:}} {{=record.username}} : {{=record.password}} [ Delete this user ] {{pass}} ==Here is some code from models/db.py== auth = Auth(globals(), db) db.define_table( auth.settings.table_user_name, Field('username'), Field('password'), Field('registration_key', default='')) auth.define_tables() custom_auth_table = db[auth.settings.table_user_name] # get the custom_auth_table == On Dec 30 2010, 6:21 pm, Rick wrote: > Hi, > > I don't know if the way I add users is proper, but it works. Now I try > to write a tag for deleting users, and it doesn't work. Here is > the code: > > ==in a controller file== > def admin(): > records = db().select(custom_auth_table.ALL, > orderby=custom_auth_table.username) > #records = SQLFORM(custom_auth_table, user, deletable=True) > form = SQLFORM(db[auth.settings.table_user_name]) > if form.accepts(request.post_vars, session): > session.flash = 'Address saved.' > redirect(URL('admin')) > return dict(form=form, records=records) > > > ==admin.html== > {{extend 'layout.html'}} > Add a user: > {{=form}} > > Users: > > {{for record in records:}} > {{=record.username}} : {{=record.password}} > [ > onclick="ajax('{{=URL('db[auth.remove.record.username]')}}', > [],'')">Delete this user > ] > > {{pass}} > > > Thanks in advance for help
[web2py] How to delete a user?
Hi, I don't know if the way I add users is proper, but it works. Now I try to write a tag for deleting users, and it doesn't work. Here is the code: ==in a controller file== def admin(): records = db().select(custom_auth_table.ALL, orderby=custom_auth_table.username) #records = SQLFORM(custom_auth_table, user, deletable=True) form = SQLFORM(db[auth.settings.table_user_name]) if form.accepts(request.post_vars, session): session.flash = 'Address saved.' redirect(URL('admin')) return dict(form=form, records=records) ==admin.html== {{extend 'layout.html'}} Add a user: {{=form}} Users: {{for record in records:}} {{=record.username}} : {{=record.password}} [ Delete this user ] {{pass}} Thanks in advance for help
[web2py] reload a div
Hi, How to reload/update a div tag as that below with AJAX? {{=variable}} update the div Thanks in advance for replies.
[web2py] Re: variables
If "n" would be a global variable in a controller file, can I use something like this then? {{=n}} plus On Dec 18, 4:23 pm, Rick wrote: > Perhaps there is a way to get different variable values depending on > what address you load??? For example: > http:...default/index.html...something...n=1,m=0 > > On Dec 18, 4:07 am, Luther Goh Lu Feng wrote: > > > > > > > > > You can use javascript or jquery(since web2py includes jquery) to do > > this: > > > ==javascript== > > $('#some_id).click(function() > > { > > $('#target").val( ($('#target").val()+1) ); > > } > > ) > > > ==html== > > Click me > > > 2 > > > This should more or less work. > > > On Dec 18, 10:02 am, Rick wrote: > > > > Thanks for the replies! The variable that I'm operating with is python > > > type, not javascript. Mdipierro, your solution looks nice, but i can't > > > get it working. The value of the variable doesn't seem to change. Here > > > is my code: > > > > from views/default/index.html: > > > {{n=1}} > > > plus > > > {{=n}} > > > > controller.py > > > def plus_n(): > > > # check this was called by the ajax post > > > if request.env.request_method=='POST': > > > # do anything you need to do > > > session.n=session.n+1 > > > # optional return instructions in JS > > > return "$('.flash').html('n was incremented').slideDown();" > > > > On Dec 18, 2:26 am, pbreit wrote: > > > > > I don't really understand the question. Do you want to change a > > > > JavaScript > > > > variable? Or a variable in your web2py code? I don't think you would be > > > > able > > > > to modify a web2py variable as the result of a click. By the time the > > > > suer > > > > views your page, all the web2py code has been rendered into HTML. You'll > > > > either need to code some JavaScript or perform some sort of Ajax call > > > > back > > > > to your server. > > > > > What exactly are you trying to do?
[web2py] Re: variables
Perhaps there is a way to get different variable values depending on what address you load??? For example: http:...default/index.html...something...n=1,m=0 On Dec 18, 4:07 am, Luther Goh Lu Feng wrote: > You can use javascript or jquery(since web2py includes jquery) to do > this: > > ==javascript== > $('#some_id).click(function() > { > $('#target").val( ($('#target").val()+1) ); > } > ) > > ==html== > Click me > > 2 > > This should more or less work. > > On Dec 18, 10:02 am, Rick wrote: > > > > > > > > > Thanks for the replies! The variable that I'm operating with is python > > type, not javascript. Mdipierro, your solution looks nice, but i can't > > get it working. The value of the variable doesn't seem to change. Here > > is my code: > > > from views/default/index.html: > > {{n=1}} > > plus > > {{=n}} > > > controller.py > > def plus_n(): > > # check this was called by the ajax post > > if request.env.request_method=='POST': > > # do anything you need to do > > session.n=session.n+1 > > # optional return instructions in JS > > return "$('.flash').html('n was incremented').slideDown();" > > > On Dec 18, 2:26 am, pbreit wrote: > > > > I don't really understand the question. Do you want to change a JavaScript > > > variable? Or a variable in your web2py code? I don't think you would be > > > able > > > to modify a web2py variable as the result of a click. By the time the suer > > > views your page, all the web2py code has been rendered into HTML. You'll > > > either need to code some JavaScript or perform some sort of Ajax call back > > > to your server. > > > > What exactly are you trying to do?
[web2py] Re: variables
Thanks for the replies! The variable that I'm operating with is python type, not javascript. Mdipierro, your solution looks nice, but i can't get it working. The value of the variable doesn't seem to change. Here is my code: from views/default/index.html: {{n=1}} plus {{=n}} controller.py def plus_n(): # check this was called by the ajax post if request.env.request_method=='POST': # do anything you need to do session.n=session.n+1 # optional return instructions in JS return "$('.flash').html('n was incremented').slideDown();" On Dec 18, 2:26 am, pbreit wrote: > I don't really understand the question. Do you want to change a JavaScript > variable? Or a variable in your web2py code? I don't think you would be able > to modify a web2py variable as the result of a click. By the time the suer > views your page, all the web2py code has been rendered into HTML. You'll > either need to code some JavaScript or perform some sort of Ajax call back > to your server. > > What exactly are you trying to do?
[web2py] variables
Hi, I want to change the value of a variable by clicking on an tag, but can't find any information about the topic. I suppose the code would look something like this: {{=A('<', request n=n-1) }} Thanks in advance for help
[web2py] variables
Hi, I want to change the value of a variable by clicking on an tag, but can't find any information about the topic. I suppose the code would look something like this: {{=A('<', request n=n-1) }} Thanks in advance for help
[web2py] Re: interval in a list
Oh no, the code above failed. Here is the final code where n is the week number: {{for record in db().select(db.table.ALL, orderby=db.table.day, limitby=((n-1)*7, n*7)):}} On Dec 18, 1:30 am, Rick wrote: > Sorry for spamming, but I want to be exact. Here is the final code, > where n is the week number: > {{for record in db().select(db.table.ALL, orderby=db.table.day, > limitby=(n*0, n*7)):}} > > On Dec 18, 1:24 am, Rick wrote: > > > > > > > > > Thanks a lot! The final code looks like this: > > {{for record in db().select(db.table.ALL, orderby=db.table.day, > > limitby=(0, 7)):}} > > > On Dec 18, 12:59 am, Luther Goh Lu Feng wrote: > > > > Fromhttp://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-... > > > > I think the following may work: > > > > for row in db().select(db.table.ALL, limitby=(0, 7)): > > > print row.record > > > > for row in db().select(db.table.ALL, limitby=(0, 3). > > > orderby=~db.table.id): > > > print row.record > > > > On Dec 18, 7:30 am, Rick wrote: > > > > > Hi, > > > > > In the database there are value records for 31 days. Now I'm trying to > > > > make a html file where a value is presented for each day of a week. > > > > The code below presents all the recorded values, and I don't know how > > > > to make it printing the 7 first records only, or the last 3 records. > > > > > Thanks in advance for help. > > > > > > > > > > > > > Day| Value| > > > > {{for record in records:}} > > > > {{=record.day}} {{=record.value}} > > > > {{pass}} > > > > > > > >
[web2py] Re: interval in a list
Sorry for spamming, but I want to be exact. Here is the final code, where n is the week number: {{for record in db().select(db.table.ALL, orderby=db.table.day, limitby=(n*0, n*7)):}} On Dec 18, 1:24 am, Rick wrote: > Thanks a lot! The final code looks like this: > {{for record in db().select(db.table.ALL, orderby=db.table.day, > limitby=(0, 7)):}} > > On Dec 18, 12:59 am, Luther Goh Lu Feng wrote: > > > > > > > > > Fromhttp://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-... > > > I think the following may work: > > > for row in db().select(db.table.ALL, limitby=(0, 7)): > > print row.record > > > for row in db().select(db.table.ALL, limitby=(0, 3). > > orderby=~db.table.id): > > print row.record > > > On Dec 18, 7:30 am, Rick wrote: > > > > Hi, > > > > In the database there are value records for 31 days. Now I'm trying to > > > make a html file where a value is presented for each day of a week. > > > The code below presents all the recorded values, and I don't know how > > > to make it printing the 7 first records only, or the last 3 records. > > > > Thanks in advance for help. > > > > > > > > > > Day| Value| > > > {{for record in records:}} > > > {{=record.day}} {{=record.value}} > > > {{pass}} > > > > > >
[web2py] Re: interval in a list
Thanks a lot! The final code looks like this: {{for record in db().select(db.table.ALL, orderby=db.table.day, limitby=(0, 7)):}} On Dec 18, 12:59 am, Luther Goh Lu Feng wrote: > Fromhttp://web2py.com/book/default/chapter/06#orderby,-groupby,-limitby,-... > > I think the following may work: > > for row in db().select(db.table.ALL, limitby=(0, 7)): > print row.record > > for row in db().select(db.table.ALL, limitby=(0, 3). > orderby=~db.table.id): > print row.record > > On Dec 18, 7:30 am, Rick wrote: > > > > > > > > > Hi, > > > In the database there are value records for 31 days. Now I'm trying to > > make a html file where a value is presented for each day of a week. > > The code below presents all the recorded values, and I don't know how > > to make it printing the 7 first records only, or the last 3 records. > > > Thanks in advance for help. > > > > > > > Day| Value| > > {{for record in records:}} > > {{=record.day}} {{=record.value}} > > {{pass}} > > > >
[web2py] interval in a list
Hi, In the database there are value records for 31 days. Now I'm trying to make a html file where a value is presented for each day of a week. The code below presents all the recorded values, and I don't know how to make it printing the 7 first records only, or the last 3 records. Thanks in advance for help. Day| Value| {{for record in records:}} {{=record.day}} {{=record.value}} {{pass}}
[web2py] Re: auth model
Now I've changed a little, but it still doesn't work: from db.py auth = Auth(globals(), db) db.define_table( auth.settings.table_user_name, Field('username'), Field('password')) auth.define_tables() custom_auth_table = db[auth.settings.table_user_name] # get the custom_auth_table custom_auth_table.requires = IS_NOT_IN_DB(db, custom_auth_table.username) from layout.html {{if not custom_auth_table.username and not request.function=='username':}} {{=custom_auth_table.login (next=URL(r=request,args=args))}} {{pass}} {{include}} **** On Dec 15, 9:55 pm, Rick wrote: > Thanks for the advice. This code seems to work: > > ** > from gluon.settings import settings > from gluon.tools import * > > # if running on Google App Engine > if settings.web2py_runtime_gae: > from gluon.contrib.gql import * > # connect to Google BigTable > db = DAL('gae') > # and store sessions there > session.connect(request, response, db=db) > else: > # if not, use SQLite or other DB > db = DAL("sqlite://db.db") > > db.define_table('todo', > Field('time'), > Field('thing')) > > auth = Auth(globals(), db) > > db.define_table( > auth.settings.table_user_name, > Field('name'), > Field('password')) > > auth.define_tables() > > custom_auth_table = db[auth.settings.table_user_name] # get the > custom_auth_table > ** > > ...but now I try to write a kind of log in/out interface in views/ > layout.html. I don't know how it should look like in the case of > custom auth. I tried with this that that gave an error mesage: > > {{if not auth.user and not request.function=='user':}} > {{=atuh.login(next=URL(r=request,args=args))}} > {{pass}} > > Any ideas? > > On Dec 15, 2:37 am, pbreit wrote: > > > > > > > > > To customize auth, have a look > > at:http://web2py.com/book/default/chapter/08#Customizing-Auth > > > For one thing, the table definitely needs to be placed between auth = > > Auth(globals(), db) and auth.define_tables()
[web2py] Re: auth model
Thanks for the advice. This code seems to work: ** from gluon.settings import settings from gluon.tools import * # if running on Google App Engine if settings.web2py_runtime_gae: from gluon.contrib.gql import * # connect to Google BigTable db = DAL('gae') # and store sessions there session.connect(request, response, db=db) else: # if not, use SQLite or other DB db = DAL("sqlite://db.db") db.define_table('todo', Field('time'), Field('thing')) auth = Auth(globals(), db) db.define_table( auth.settings.table_user_name, Field('name'), Field('password')) auth.define_tables() custom_auth_table = db[auth.settings.table_user_name] # get the custom_auth_table ** ...but now I try to write a kind of log in/out interface in views/ layout.html. I don't know how it should look like in the case of custom auth. I tried with this that that gave an error mesage: {{if not auth.user and not request.function=='user':}} {{=atuh.login(next=URL(r=request,args=args))}} {{pass}} Any ideas? On Dec 15, 2:37 am, pbreit wrote: > To customize auth, have a look > at:http://web2py.com/book/default/chapter/08#Customizing-Auth > > For one thing, the table definitely needs to be placed between auth = > Auth(globals(), db) and auth.define_tables()
[web2py] auth model
Hi, I'm trying to make a very simple todo application for many users. The passwords and usernames would be given from a administrator, so hence there wouldn't be any registration through e-mail. My problem is that I don't know how to properly write the model/db.py file. I tried with this, where there is one table for auth and one for the todo post, I I just get error messages: from gluon.settings import settings from gluon.tools import * # if running on Google App Engine if settings.web2py_runtime_gae: from gluon.contrib.gql import * # connect to Google BigTable db = DAL('gae') # and store sessions there session.connect(request, response, db=db) else: # if not, use SQLite or other DB db = DAL("sqlite://db.db") auth = Auth(globals(), db) auth.define_tables() db.define_table('todo', Field('time'), tha Field('thing')) db.define_table( auth.settings.table_user_name, Field('password', 'password', length=512, readable=False, label='Password'), Field('registration_id', length=512, writable=False, readable=False, default='')) Thanks for help in advance
[web2py] Re: simple db app
Thanks for the help! I got it working with this code: == controller file == def index(): records = db().select(db.addresses.ALL, orderby=db.addresses.person) return dict(records=records) def create(): form = SQLFORM(db.addresses) if form.accepts(request.post_vars, session): session.flash = 'Address saved.' redirect(URL('index')) return dict(form=form) == db.py == db.define_table('addresses', Field('person'), Field('address')) == index.html == {{extend 'layout.html'}} Addresses {{for record in records:}} {{=record.person}} : {{=record.address}} {{pass}} [ {{=A('Add Address', _href=URL('create'))}} ] == create.html == {{extend 'layout.html'}} {{=form}} On Dec 14, 5:16 pm, DenesL wrote: > Correction, you should not set vars using field names already in the > form, otherwise they will be duplicated. > > def show(): > rid=request.vars.rid > record=db(db.addresses.id==rid).select() > > def input(): > form = SQLFORM(db.addresses) > if form.accepts(request.vars, session): > redirect(URL(r=request, > f='show',vars={'rid':form.vars.id})) > return dict(form=form) > > On Dec 13, 10:48 pm, DenesL wrote: > > > > > > > > > Hi Rick, > > > On Dec 13, 6:55 pm, Rick wrote: > > > > Hi, > > > > I'm trying to make a data base for storing names and addresses, but > > > since I'm a n00b then I can't get it working. I've no idea what's > > > wrong. The problem is that the input function doesn't redirect to the > > > show function and that the show function doesn't show any data. Here's > > > the code: > > > > the controller file: > > > def show(): > > > id=request.vars.id > > > record=db(db.measure.id==id).select() > > > record=db(db.addresses.id==id).select() > > > > return dict(record=record) > > > > def input(): > > > form = SQLFORM(db.addresses) > > > if form.accepts(request.vars, session): > > > redirect(URL(r=request, f='show')) > > > redirect(URL(r=request, f='show',vars={'id':form.vars.id})) > > > > return dict(form=form) > > > > ** > > > > and the model file table: > > > > db.define_table('addresses', > > > Field('person'), > > > Field('adress')) > > > Field('address')) > > > > ** > > > > input.html > > > {{extend 'layout.html'}} > > > {{=form}} > > > > ** > > > > show.html: > > > {{extend 'layout.html'}} > > > Addresses > > > {{for record in record:}} > > > {{=record.name}} : {{=record.address}} > > > {{=record.person}} : {{=record.address}} > > > > {{pass}} > > > > ** > > > > Thanks in advance for help!
[web2py] Re: simple db app
Thanks for the reply. Unfortunately this code idea gives the same result as mine. On Dec 14, 2:51 am, pbreit wrote: > I would envision something more like this (not tested): > > == db.py == > db.define_table('address', > Field('person'), > Field('address')) > > == default.py == > def index(): > records = db().select(db.address.ALL, orderby=db.address.name) > return dict(records=records) > > def create(): > form = SQLFORM(table) > if form.accepts(request.post_vars, session): > session.flash = 'Address saved.' > redirect(URL('index')) > > == default/index.html == > {{extend 'layout.html'}} > Addresses > {{for record in records:}} > {{=record.name}} : {{=record.address}} > {{pass}} > [ {{=A('Add Address', _href=URL('create'))}} ] > > == default/create.html == > {{extend 'layout.html'}} > {{=form}}
[web2py] Re: simple db app
http://groups.google.com/group/web2py/browse_thread/thread/b7cd19c53648ef0d On 12/14/10, Rick wrote: > Hi, > > I'm trying to make a data base for storing names and addresses, but > since I'm a n00b then I can't get it working. I've no idea what's > wrong. The problem is that the input function doesn't redirect to the > show function and that the show function doesn't show any data. Here's > the code: > > the controller file: > def show(): > id=request.vars.id > record=db(db.measure.id==id).select() > return dict(record=record) > > def input(): > form = SQLFORM(db.addresses) > if form.accepts(request.vars, session): > redirect(URL(r=request, f='show')) > return dict(form=form) > > ** > > and the model file table: > > db.define_table('addresses', > Field('person'), > Field('adress')) > > ** > > input.html > {{extend 'layout.html'}} > {{=form}} > > > ** > > show.html: > {{extend 'layout.html'}} > Addresses > {{for record in record:}} > {{=record.name}} : {{=record.address}} > {{pass}} > > ** > > Thanks in advance for help!
[web2py] simple db app
Hi, I'm trying to make a data base for storing names and addresses, but since I'm a n00b then I can't get it working. I've no idea what's wrong. The problem is that the input function doesn't redirect to the show function and that the show function doesn't show any data. Here's the code: the controller file: def show(): id=request.vars.id record=db(db.measure.id==id).select() return dict(record=record) def input(): form = SQLFORM(db.addresses) if form.accepts(request.vars, session): redirect(URL(r=request, f='show')) return dict(form=form) ** and the model file table: db.define_table('addresses', Field('person'), Field('adress')) ** input.html {{extend 'layout.html'}} {{=form}} ** show.html: {{extend 'layout.html'}} Addresses {{for record in record:}} {{=record.name}} : {{=record.address}} {{pass}} ** Thanks in advance for help!
[web2py] list:string thoughts
I'm getting frustrated with the list:string field type. I store products, each product has "keywords" that describe the product. db.define_table('products', Field('keywords', 'list:string')) I don't know what the keywords will be, so I can't use IS_IN_SET() It seems to stores the keywords fine, as long as (I'm using Crud) I separate the keywords like this: green|blue|red But when I make this call rows = db(db.products.keywords.contains(keyword)).select() I don't get all the products back that I should! In fact, it seems that I need to do an update on the product (again using Crud, and any sort of update) before the product's keywords will be picked up. Is this a problem with using Crud? In all honesty, I'd be more comfortable not using list:string, and having a separate table "keywords" that linked (many-to-one) to the products table, but I really don't know how I would even begin to do that in web2py.. Thanks for reading! - rick
[web2py] Re: GAE address
Thanks for the link and the answer. Now I've figured out what I exactly try to ask: How to make the "root site" 127.0.0.1:8080 redirect to 127.0.0.1:8080/myapp/views/default/index instead of 127.0.0.1:8080/myapp/welcome/default/index ? On Sep 30, 8:20 pm, mdipierro wrote: > This is what I do: > > - I run web2py.py using 127.0.0.1:8000 > - I test in dev_appserver on 127.0.0.1:8080 > > On port 8000 admin works and I can deploy apps locally. They will then > be visible on port 8080 too. > After I test that everything works I deply using the AppEngineLauncher > or appcfg.py > > This may also help: > > http://gluonframework.wordpress.com/2010/03/02/shell-only-web2py/ > > Massimo > > On Sep 30, 12:06 pm, Rick wrote: > > > But how to upload it in my local copy? I understand that I'd somehow > > get the app on the address http://127.0.0.1:8000butI don't > > understand how to get it there. It has still the > > address:http://127.0.0.1:8000/myapp > > I'm running linux. Perhaps that has an impact on the procedure? > > > On Sep 28, 5:46 pm, mdipierro wrote: > > > > You have to upload it in your local copy and then doply it again. > > > > On Sep 28, 11:20 am, Rick wrote: > > > > > Hi, > > > > > When I upload my app with GAE the address will be myapp.appspot.com/ > > > > myapp . On the site myapp.appspot.com there is the administrative > > > > interface that doesn't work with GAE. My question is: how to put my > > > > app on myapp.appspot.com ? > > > > > Thanks in advance for help! > >
[web2py] Re: GAE address
But how to upload it in my local copy? I understand that I'd somehow get the app on the address http://127.0.0.1:8000 but I don't understand how to get it there. It has still the address: http://127.0.0.1:8000/myapp I'm running linux. Perhaps that has an impact on the procedure? On Sep 28, 5:46 pm, mdipierro wrote: > You have to upload it in your local copy and then doply it again. > > On Sep 28, 11:20 am, Rick wrote: > > > > > Hi, > > > When I upload my app with GAE the address will be myapp.appspot.com/ > > myapp . On the site myapp.appspot.com there is the administrative > > interface that doesn't work with GAE. My question is: how to put my > > app on myapp.appspot.com ? > > > Thanks in advance for help!
[web2py] Re: superfish
Thanks for taking the time for my problem. I couldn't find any good example that shows how to make a nice menu. While trying different solutions I made a mess of the code. But at the end I made this solution: {{ submenu1=[ ['item1',False,URL(r=request,f='item1')], ['item2',False,URL(r=request,f='item2')], ] submenu2=[ ['item3',False,URL(r=request,f='item3')], ['item4',False,URL(r=request,f='item4')], ] response.menu=[ ['header1',False,'#',submenu1], ['header2',False,'#',submenu2], ]}} {{## superfish menu }} {{=MENU(response.menu,_class='sf-menu')}} jQuery(document).ready(function(){ jQuery('ul.sf-menu').superfish({delay:400});}); On Sep 29, 1:23 pm, mdipierro wrote: > everything I see here appears correct. Can we see the generated html? > Can you try load the page with firebug and see if you get any error? > > On Sep 28, 11:50 pm, Rick wrote: > > > > > Hi, > > > I've put this into a viewer file named layout.html but it doesn't > > work: > > > > > {{response.files.append(URL(request.application,'static','superfish.js'))}} > > {{include 'web2py_ajax.html'}} > > > > > ...some code > > > {{ > > response.menu=[ > > > > ('Home',request.function=='home',URL(r=request,f='home'),[]), > > ('Store > > Information',request.function=='info',URL(r=request,f=info'), > > []),] > > }} > > > Thanks in advance for help! > > > {{## superfish menu }} > > {{=MENU(response.menu,_class='sf-menu')}} > > > > jQuery(document).ready(function(){ > > jQuery('ul.sf-menu').superfish({delay:400});}); > >
[web2py] superfish
Hi, I've put this into a viewer file named layout.html but it doesn't work: {{response.files.append(URL(request.application,'static','superfish.js'))}} {{include 'web2py_ajax.html'}} ...some code {{ response.menu=[ ('Home',request.function=='home',URL(r=request,f='home'),[]), ('Store Information',request.function=='info',URL(r=request,f=info'), []),] }} Thanks in advance for help! {{## superfish menu }} {{=MENU(response.menu,_class='sf-menu')}} jQuery(document).ready(function(){ jQuery('ul.sf-menu').superfish({delay:400});});
[web2py] GAE address
Hi, When I upload my app with GAE the address will be myapp.appspot.com/ myapp . On the site myapp.appspot.com there is the administrative interface that doesn't work with GAE. My question is: how to put my app on myapp.appspot.com ? Thanks in advance for help!
[web2py] Re: JQuery plugin
Thanks for the suggestions. Now I consider this plugin: http://www.happyworm.com/jquery/jplayer/ On Sep 25, 3:33 am, Magnitus wrote: > Assuming that you know how to create sound effects in regular > Javascript, making your own pluggin for it doesn't seem that > difficult. > > Lets assume that you want a pluggin that affect only div elements in a > wrapped set and you want to be able to specify the sound... > > It'd look something like this (note that this is a quick-and-dirty > piece of code... totally untested): > > {function($){ > $.fn.AddSoundOnClick = function(SoundEffect) { > return this.filter('div').bind('click',function(event){ > //Stick the logic to emit the sound effect here > }).end(); > }; > > })(jQuery); > > Afterwards, lets say that you have a sound effect stored in the > variable CowSound and a div with class "SoundDiv", you could add the > cow sound like this: > > jQuery('div.SoundDiv').AddSoundOnClick(CowSound); > > Here's terrific book for jQuery: > > http://www.amazon.ca/jQuery-Action-Second-Bear-Bibeault/dp/1935182323... > > If you're serious about using jQuery properly, it'll be the best 30$ > you ever spent. Sure learned a lot from it. > > On Sep 24, 4:13 pm, Rick wrote: > > > > > Hi, > > > I'd like to make a button that generates a sound when clicking on it. > > This JQuery plugin was the best way I could > > found:http://plugins.jquery.com/project/sound > > and I wrote this code: > > > views/default/index.html: > > {{extend 'layout.html'}} > > > > onClick="jQuery(this).sound.play(/static/success.wav)" > > > > > views/layout.html: > > > > > {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}} > > > > > Since I'm totally new to JQuery I understand that this is completely > > wrong. Could anyone tell me how it should look like, please?
[web2py] Re: JQuery plugin
Thanks! I think there are better plugins for this purpose than this sound- plugin. But now I know how to install it into my application. On Sep 24, 8:26 pm, Bruno Rocha wrote: > You should append JS files before the {{include 'web2py_ajax.html'}} > > views/layout.html: > > > {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}} > > {{include 'web2py_ajax.html'}} > > > and in your div the OnClick event is used in the wrong way, it is not > recommended to use onclick event in a div, you should use , or > another element, and the file URL should be build with URL helper: > > views/default/index.html: > {{extend 'layout.html'}} > > > onclick="jQuery(this).sound.play({{=URL('static',args='success.wav')}})"> > Click here to listen the sound > > > > 2010/9/24 Rick > > > > > > > Hi, > > > I'd like to make a button that generates a sound when clicking on it. > > This JQuery plugin was the best way I could found: > >http://plugins.jquery.com/project/sound > > and I wrote this code: > > > views/default/index.html: > > {{extend 'layout.html'}} > > > > onClick="jQuery(this).sound.play(/static/success.wav)" > > > > > views/layout.html: > > > > > {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}} > > > > > Since I'm totally new to JQuery I understand that this is completely > > wrong. Could anyone tell me how it should look like, please? > > -- > > http://rochacbruno.com.br
[web2py] JQuery plugin
Hi, I'd like to make a button that generates a sound when clicking on it. This JQuery plugin was the best way I could found: http://plugins.jquery.com/project/sound and I wrote this code: views/default/index.html: {{extend 'layout.html'}} onClick="jQuery(this).sound.play(/static/success.wav)" views/layout.html: {{response.files.append(URL(r=request,c='static',f='jquery.sound.js'))}} Since I'm totally new to JQuery I understand that this is completely wrong. Could anyone tell me how it should look like, please?
[web2py] database question
Hi, I'm having trouble figuring out the syntax for this type of database inquiry. I have three tables: 1) stores, which has a name 2) regions, which has a 2-letter abbreviation 3) store-region, which puts stores in certain regions. I want to pass in a 2-letter region abbreviation, and receive back the names of the stores in that region. So I need to use the results of one query (regions with the abbreviation "NY", say), to get another set of results (store ids with that region id), to get the third set of results (stores names that matched the store ids) Thanks for reading..