Re: [web2py] Re: New feature in trunk conditional fields RFC
Hello How do i implement these conditional fields in a custom auth table? I tried the following but does not seem to hide the grade field. #Start of definition of custom Auth tables to be used instead of the default ones. auth = Auth(db) db.define_table(auth.settings.table_user_name, Field('role', 'string', requires=IS_IN_SET(['teacher', 'principal', 'head of dept', 'secretary', 'school board'])), Field('grade', 'string'), Field('first_name', length=128, default=''), Field('last_name', length=128, default=''), Field('date_of_birth', 'date', length=128), Field('national_id', length=128, label='Birth Registration No or ID_No'), Field('postal_address', length=128), Field('username', length=128, default=''), Field('password', 'password', length=512, readable=False, label='Password'), Field('registration_key', length=512, writable=False, readable=False, default=''), Field('reset_password_key', length=512, writable=False, readable=False, default=''), Field('registration_id', length=512, writable=False, readable=False, default='')) #get the custom_auth_table custom_auth_table = db[auth.settings.table_user_name] custom_auth_table.grade.show_if=custom_auth_table.role.belongs(('teacher','principal','head of dept')) custom_auth_table.last_name.requires = IS_NOT_EMPTY(error_message=auth.messages.is_empty) custom_auth_table.password.requires = [IS_STRONG(), CRYPT()] custom_auth_table.username.requires = IS_NOT_IN_DB(db, custom_auth_table.username, error_message='User name already in use, please choose another name') #custom_auth_table.parent_cell_no.requires = IS_MATCH('^\d{3}-\d{7}$',error_message='Enter a cellphone number like this: 081-1234567') auth.settings.table_user = custom_auth_table #Tell auth to use custom_auth_table auth.define_tables() #End of definition of custom Auth tables On Tuesday, June 4, 2013 at 10:55:31 PM UTC+2, Ramos wrote: > > Show if =visible when > No dia 04/06/2013 21:51, "Niphlod"> escreveu: > >> it works, but a few hiccups with the examples posted >> >> def index1(): >> """ shows bb only if aa is checked """ >> db.define_table('thing', Field('aa','boolean'),Field('bb')) >> db.thing.bb.show_if = db.thing.aa==True >> form = SQLFORM(db.thing) >> return locals() >> >> def index2(): >> """ shows bb only when aa is not set to "x" """ >> db.define_table('thing', Field('aa'),Field('bb')) >> >> db.thing.aa.requires=IS_IN_SET(('x','y','z')) >> db.thing.bb.show_if = >> db.thing.aa!='x' >> form = SQLFORM(db.thing) >> return locals() >> >> def index3(): >> """ shows bb only when one types "x" or "y" in aa""" >> db.define_table('thing', Field('aa'),Field('bb')) >> db.thing.bb.show_if = db.thing.aa.belongs(('x','y')) >> form = SQLFORM(db.thing) >> return locals() >> >> def index4(): >> """ shows bb only when one types "abcd" in aa""" >> db.define_table('thing', Field('aa'),Field('bb')) >> db.thing.bb.show_if = db.thing.aa.contains('abcd') >> form = SQLFORM(db.thing) >> return locals() >> >> -- >> >> --- >> 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 . >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- 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: Check to establish whether or not a record exists
Hi Massimo Just came across this post and got a bit alarmed, so when i check if a record exists i don't have to use the usual '==' but instead '=' ? On Monday, October 10, 2011 at 3:55:27 PM UTC+2, Massimo Di Pierro wrote: > > row = db.postcode_cache(postcode=postcode) > if not row: > db.postcode_cache.insert(postcode=postcode,nearset=nearest) > elif not row.nearest: row.update_record(nearset=nearest) > else: pass # do nothing > > On Oct 10, 8:22 am, Chris Rowsonwrote: > > Hi list, > > > > I have a database table which looks like this: > > > > postcode_cache > > > > postcode (UNIQUE) > > lat > > lon > > nearest > > > > I want to test first whether or not a record exists for 'postcode' and > > if a record does exist, I want to check whether the 'nearest' field > > contains any data. > > > > I've tried this: > > > > if db(db.postcode_cache.postcode==postcode).select().first()==None: > > create_a_new_postcode_record() > > > > elif > db(db.postcode_cache.postcode==postcode).select(db.postcode_cache.nearest)= > =None: > > populate_the_nearest_field() > > > > else: > > nothing_to_do() > > > > And while the check to establish whether or not a record exists seems > > to work, the check to see whether or not the 'nearest' field within > > the record is populated doesn't seem to work. > > > > Can anyone tell me what I'm doing wrong please? > > > > Thank you, > > > > Chris -- 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: Web2py Update records only if user is signed in with a different session from previous
Ok, i was first storing the current session id from some insert statement, thanks now i can just access it directly from response.session_id. I guess my logic is wrong since i am running all these queries in the same function, i end up inserting the current session_id and testing it against itself (expecting it to be different sometimes), which will not happen for any user session. Any idea of how i could set it up such that the next time a user logs in with a different session, then i can trigger some operation?? On Tuesday, October 4, 2016 at 6:13:24 PM UTC+2, Anthony wrote: > > On Tuesday, October 4, 2016 at 3:16:06 AM UTC-4, Meinolf wrote: >> >> Hi there, >> >> I need to update my table record only if the user is logged in with a >> different session from the previous, but with the code i have, it keeps >> updating when i thought the user still logged in with the same session. >> problem is i can't view the session id which seem to be encrypted, i can't >> tell when its the same and when its not. Did i miss something? below is my >> code: >> >> prev_ses_id = db((db.rates.user_id==auth.user.id) & >> (db.rates.item_id==request.args(0))).select(db.rates.ses_id) >> > > How and where are you setting the value of db.rates.ses_id? Do you expect > the above to return only a single record? Note, prev_ses_id is a Rows > object, not a Row object, and not an individual session id value. If you > want the value of the ses_id field, you need to do prev_ses_id[0].ses_id. > > Note, if you need the session id of the current session, it is in > response.session_id. > > Anthony > -- 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] Web2py Update records only if user is signed in with a different session from previous
Hi there, I need to update my table record only if the user is logged in with a different session from the previous, but with the code i have, it keeps updating when i thought the user still logged in with the same session. problem is i can't view the session id which seem to be encrypted, i can't tell when its the same and when its not. Did i miss something? below is my code: prev_ses_id = db((db.rates.user_id==auth.user.id) & (db.rates.item_id==request.args(0))).select(db.rates.ses_id) myrow = db((db.rates.user_id==auth.user.id) & (db.rates.item_id==request.args(0)) & ~(db.rates.ses_id==prev_ses_id)).update(search_term=db.rates.search_term + ' ' + str(request.vars.search_term),interest=db.rates.interest + ' ' + (dictionary.synonym(request.vars.search_term)), clicks=db.rates.clicks+1) Will appreciate all the help i can get. Thanks -- 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: Passing a list as query parameter and storing the retrieved rows in a list
Thanks Anthony, i understand clearly now, getcourseids was indeed a Rows object and it works now with just this line: s = db(db.item.id.belongs([c.item_id for c in getcourseids])).select(db.item .course_title) Thanks a lot really! On Wednesday, September 21, 2016 at 8:59:05 PM UTC+2, Anthony wrote: > > On Wednesday, September 21, 2016 at 3:30:49 AM UTC-4, Meinolf wrote: >> >> OMG, Is this normal? >> i got chills telling me it had something to do with the *For Loop*, >> played around with the LBs and UBs and the following worked: >> >>* for i in range(-1, (len(getcourseids)-1)):* >> > > First, if you want the subscripts of a list, just do range(len(thelist)). > Do not subtract 1 from the length of the list -- range already handles that > for you (it returns integers that are strictly less than the second > argument). Also, no need to start with 0, as that is the default. And don't > start with -1 -- when used as a subscript, that will simply retrieve the > *last* item in the list, not the first. Also, in Python 2, use xrange() > in for loops, which is more memory efficient (in Python 3, range has been > replaced by xrange). > > >>* c = db.item.id <http://db.item.id>==getcourseids[i].item_id* >> *s.append(db(c).select(db.item.course_title)[i])* >> > > Here it is not clear why you are subscripting the result of the select > with [i]. Presumably each query returns a single matching row, which means > you want the subscript to always be [0] -- otherwise, you will get a list > index out of range error. > > Actually, given that you don't really need the index of each element in > the list, you can instead just iterate over the list itself: > > for item in getcourseids: > > And if you did need the index values in addition to the elements, the more > typical approach in Python would be: > > for i, item in enumerate(getcourseids): > > Anyway, in this case you should not be using the above method at all, as > it is very inefficient (you are doing a separate database query for every > single item in getcourseids, when you could instead use a single query). > Villas has the right idea, but getcourseids.values() assumes getcourseids > is a dictionary -- presumably it is actually a Rows object. So, you can do: > > s = db(db.item.id.belongs([c.item_id for c in > getcourseids])).select(db.item.course_title) > > Note, the above is a Rows object. You can convert it to a list if you > really need a list, but most likely you can work with the Rows object (it > can be iterated and indexed just like a list). > > Assuming getcourseids is a Rows object and the only reason it was created > was to get the item_id values to be used in this subsequent query, you can > instead skip the creation of getcourseids and just use a nested select > <http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#belongs> > : > > id_query = db([your query to retrieve course > ids])._select(db.your_course_table.item_id) > s = db(db.item.id.belongs(id_query)).select(db.item.course_title) > > > Anthony > -- 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: Passing a list as query parameter and storing the retrieved rows in a list
OMG, Is this normal? i got chills telling me it had something to do with the *For Loop*, played around with the LBs and UBs and the following worked: * for i in range(-1, (len(getcourseids)-1)):* * c = db.item.id==getcourseids[i].item_id* *s.append(db(c).select(db.item.course_title)[i])* Now i'm puzzled as to why give a lower bound of -1 for the range, will this keep on working or my code could later crash I put it under a *Try..Except * block though..please help if there's a safer alternative, this is new to me and sort of contradicts what i know of starting from 0. On Monday, September 19, 2016 at 7:59:27 PM UTC+2, Meinolf wrote: > > Hi There, > > When i test the code below, for a list that is supposed to have multiple > items, i only get one result for the last item, did i miss something in the > for loop or anywhere else? > > for i in range(0, (len(getcourseids)-1)): > c = db.item.id==getcourseids[i].item_id > s.append(db(c).select(db.item.course_title)[i]) > > Any help will be appreciated. > -- 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: Passing a list as query parameter and storing the retrieved rows in a list
I tried both approaches but i get the following error: 'Rows' object has no attribute 'values' the Rows object being referred to in the error is *getcourseids, *which is true because it holds a set of rows retrieved from the database before. How can i get around it then? On Tuesday, September 20, 2016 at 11:18:10 PM UTC+2, villas wrote: > > Maybe you could better use more of the power of web2py. Something like > this? > > s = db( db.item.id.belongs(getcourseids.values()) ).select( >db.item.course_title).as_list() > > or perhaps a bit longer, something like this... > > rows = db( db.item.id.belongs(getcourseids.values()) ).select( >db.item.course_title) > > s = [r.course_title for r in rows] > > > > On Monday, 19 September 2016 18:59:27 UTC+1, Meinolf wrote: >> >> Hi There, >> >> When i test the code below, for a list that is supposed to have multiple >> items, i only get one result for the last item, did i miss something in the >> for loop or anywhere else? >> >> for i in range(0, (len(getcourseids)-1)): >> c = db.item.id==getcourseids[i].item_id >> s.append(db(c).select(db.item.course_title)[i]) >> >> Any help will be appreciated. >> > -- 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] Passing a list as query parameter and storing the retrieved rows in a list
Hi There, When i test the code below, for a list that is supposed to have multiple items, i only get one result for the last item, did i miss something in the for loop or anywhere else? for i in range(0, (len(getcourseids)-1)): c = db.item.id==getcourseids[i].item_id s.append(db(c).select(db.item.course_title)[i]) Any help will be appreciated. -- 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] extracting a field value from a row gives me
Thanks, I solved it with: query = (db.rates.item_id==request.args(0)) & ~(db.rates.user_id==auth.user.id) results = db(query).select(db.rates.user_id, orderby=~db.rates.clicks) maxrating = results[0].user_id i can now use maxrating for my query. On Monday, September 19, 2016 at 12:03:42 PM UTC+2, Kiran Subbaraman wrote: > > Check the structure of your returned result. Does it have 'clicks' as a > first-level attribute? Or should it be 'rates.clicks'? > > > Kiran Subbaramanhttp://subbaraman.wordpress.com/about/ > > On Mon, 19-09-2016 11:51 AM, Meinolf wrote: > > What could be wrong with my code below? > > sim = db((db.rates.item_id==request.args(0)) & ~(db.rates.user_id== > auth.user.id)).select(db.rates.clicks.max()).first().clicks > > I need to access the value of the field *clicks* so that i can use it as > a parameter in another query. It keeps giving me 'exceptions.AttributeError'> > -- > 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 . > 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] extracting a field value from a row gives me
What could be wrong with my code below? sim = db((db.rates.item_id==request.args(0)) & ~(db.rates.user_id==auth.user.id)).select(db.rates.clicks.max()).first().clicks I need to access the value of the field *clicks* so that i can use it as a parameter in another query. It keeps giving me -- 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: Web2py - How to update a table field appending a string to an existing field value
Excellent, the None value was indeed the problem, so i just gave a default string value in the table definition as *Field('search_term', 'string', default='')* and now it works. Thanks a lot. On Monday, September 19, 2016 at 4:59:00 AM UTC+2, Massimo Di Pierro wrote: > > This works for me, I just tried: > > >>> db.define_table('rated_items', > > Field('search_term','string'), > > ) > > > >>> k = db.rated_items.insert(search_term='a') > > >>> db(db.rated_items.id > ==k).update(search_term=db.rated_items.search_term+'b') > > >>> print db.rated_items[k] > > > > > you probably have None into the search_term field and it cannot be > concatenated with string. > > On Friday, 16 September 2016 05:44:36 UTC-5, Meinolf wrote: >> >> I had tried that and tried it just now but still gives a None value in >> the rated_items.search_term field. maybe it's got to do with the table def; >> my table definition is as follows: >> >> db.define_table('rated_items', >> Field('search_term','string'), >> Field('user_id', 'reference auth_user', default=auth.user and >> auth.user.id), >> Field('item_id', 'integer'), >> Field('clicks', 'integer', default=0), >> migrate=True, >> ) >> >> On Friday, September 16, 2016 at 12:00:09 AM UTC+2, Meinolf wrote: >>> >>> Hi there >>> >>> So far i only know how to update a record by replacing the old field >>> value with the new value. Suppose i want to append the search_term string >>> value the corresponding text field so that both values are stored, how can >>> i do that in this code: >>> >>> myrow = db((db.rated_items.user_id==auth.user.id) & >>> >>> (db.rated_items.item_id==request.args(0))).update(search_term=str(request.vars.search_term) >>> >>> Would appreciate any help!! >>> >> -- 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: Web2py - How to update a table field appending a string to an existing field value
I had tried that and tried it just now but still gives a None value in the rated_items.search_term field. maybe it's got to do with the table def; my table definition is as follows: db.define_table('rated_items', Field('search_term','string'), Field('user_id', 'reference auth_user', default=auth.user and auth.user.id), Field('item_id', 'integer'), Field('clicks', 'integer', default=0), migrate=True, ) On Friday, September 16, 2016 at 12:00:09 AM UTC+2, Meinolf wrote: > > Hi there > > So far i only know how to update a record by replacing the old field value > with the new value. Suppose i want to append the search_term string value > the corresponding text field so that both values are stored, how can i do > that in this code: > > myrow = db((db.rated_items.user_id==auth.user.id) & > > (db.rated_items.item_id==request.args(0))).update(search_term=str(request.vars.search_term) > > Would appreciate any help!! > -- 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] Web2py - How to update a table field appending a string to an existing field value
Hi there So far i only know how to update a record by replacing the old field value with the new value. Suppose i want to append the search_term string value the corresponding text field so that both values are stored, how can i do that in this code: myrow = db((db.rated_items.user_id==auth.user.id) & (db.rated_items.item_id==request.args(0))).update(search_term=str(request.vars.search_term) Would appreciate any help!! -- 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: Web2py sqlite select database records using wildcards
yes an example would do especially to use a string variable name instead of 'value', i.e db.mytable.myfield.like(variablename).select() for example. But thanks for the response, so far at least i've got an idea.. On Monday, September 12, 2016 at 10:08:16 PM UTC+2, Dave S wrote: > > > > On Monday, September 12, 2016 at 12:39:17 PM UTC-7, Meinolf wrote: >> >> Anyone knows the web2py's sqlite syntax to select database records using >> wildcards such as %like% or contains instead of query = db.mytable.myfield >> == 'value'? >> >> > According to the book, it's db(db.log.event.like('string%')).select() > (where I've used the example DB names). > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#like--ilike--regexp--startswith--endswith--contains--upper--lower > > > > (I found it a good idea to pretty much read the book through ... I got the > hardcopy, which is not quite up-to-date now ... and that made it easier to > search through for answers to specific questions.) > > I don't have examples on this computer (instead, the early code here used > executesql() with "LIKE" in the WHERE clause), but I probably have an > example at home. > > /dps > > > > -- 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: Web2Py Navigating table records one at a time
resolved, i completely changed the approach to something else. -- 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] Web2py sqlite select database records using wildcards
Anyone knows the web2py's sqlite syntax to select database records using wildcards such as %like% or contains instead of query = db.mytable.myfield == 'value'? -- 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: Web2Py Navigating table records one at a time
Now i have changed the idea. My new idea is to track users' activity as they search for study courses, depending on their search terms, i want to recommend to them some courses they might be interested in. Any idea of which tools in Web2Py i can make use of and how to use them: Auth, session or cookies??? Thanks -- 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] Web2Py Navigating table records one at a time
Hi I am new to python and web2py. I have a small sqlite table of "career test" questions that i need to be presented to a user in form of a quiz, one question appearing at a time Problems: 1. I can't figure out how to safely stop at the last record, it breaks and after 3 more clicks, it takes me to "None" white page. 2. I need to capture each instance of the quiz for a specific user without them login in, how do i collect the questions with a session identifier? Below is my code: def career(): q = db().select(db.quest.ALL, orderby=db.quest.q_id) answerForm = SQLFORM(db.quiz) while True: while not form.process().accepted: session.counter = len(q)-1 question = q[session.counter]['q_id'] return dict(question=question, answerForm=answerForm) else: session.counter -= 1 question = q[session.counter]['q_id'] if session.counter < 0: question = q[0]['q_id'] return dict(question=question, answerForm=answerForm) Any ideas on a better approach asap will be highly appreciated. -- 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.