Re: [web2py] how to connect to another DB
Il 04/06/13 02:06, Nam Soo In ha scritto: I am trying to write a application that connects two DB I have locally running sqlite DB and I need to access one remote MSSql db. I have default set-up on sqlite and I am trying to setup MSSql db access. MSSql side I only have one given view name. I dont have access to other tables only one view. what is the way to set it up DAL? Thank you in advance. Hi Nam, if you have the complete description of the MSSql table create a second DAL connection and define the view as you would do with a table following: http://web2py.com/books/default/chapter/29/06#DAL,-Table,-Field e.g. mssqldb = DAL(your string connection) mssqldb.define_table(your table name, Field(...), ...) I hope I've been of any help Cheers Manuele -- --- 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. -- --- 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.
Re: [web2py] Re: Fixed issue 1422 introduced a bug in generic rss views?
Hello all, Am I the only one having issues with generic RSS views? Is there any workaround for my problem? Thank you Le dimanche 2 juin 2013 14:16:25 UTC+2, Loïc a écrit : Well, I replaced python27/lib/xml/sax/*saxutils.py *with the patched file (see attached) But I still have the same error : Ticket ID 127.0.0.1.2013-06-02.14-13-25.c9feb7ca-4163-463e-ad44-185a7141dc9d type 'exceptions.UnicodeDecodeError' 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128)Versionweb2py™Version 2.4.7-stable+timestamp.2013.05.24.17.48.47PythonPython 2.7.5: C:\Python27\python.exe (prefix: C:\Python27)Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. Traceback (most recent call last): File D:\Google Drive\loic\web2py\web2py\gluon\restricted.py, line 212, in restricted exec ccode in environment File D:\Google Drive\loic\web2py\web2py\applications\dommartin25\views\generic.rss, line 10, in module from gluon.serializers import rss}}{{=XML(rss(response._vars))}} File D:\Google Drive\loic\web2py\web2py\gluon\serializers.py, line 174, in rss ) for entry in feed.get('entries', [])]) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128) Any idea? Thank you Le vendredi 31 mai 2013 12:30:34 UTC+2, Loïc a écrit : Sorry but I installed latest python version on my laptop (python 2.7.5 on Win7 x64) and it still doesn't work : type 'exceptions.UnicodeDecodeError' 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128) Versionweb2py™Version 2.4.7-stable+timestamp.2013.05.24.17.48.47PythonPython 2.7.5: C:\Python27\python.exe (prefix: C:\Python27)Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. Traceback (most recent call last): File D:\Google Drive\loic\web2py\web2py\gluon\restricted.py, line 212, in restricted exec ccode in environment File D:\Google Drive\loic\web2py\web2py\applications\dommartin25\views\generic.rss, line 10, in module from gluon.serializers import rss}}{{=XML(rss(response._vars))}} File D:\Google Drive\loic\web2py\web2py\gluon\serializers.py, line 174, in rss ) for entry in feed.get('entries', [])]) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 9: ordinal not in range(128) I'm not a python-master like you, Niphlod and Sebastian, but would it be possible to make something like below in order not to break backward compatibility when one updates Web2py 2.4.5 to 2.4.7? *in seriaizers.py (this code doesn't work, it is just to explain my idea...)* * def rss(feed): if not 'entries' in feed and 'items' in feed: feed['entries'] = feed['items'] now = datetime.datetime.now() try: rss = rss2.RSS2(title=str(feed.get('title', '(notitle)').encode( 'utf-8', 'replace')), link=str(feed.get('link', None).encode('utf-8', 'replace')), description=str(feed.get('description', ''). encode('utf-8', 'replace')), lastBuildDate=feed.get('created_on', now), items=[rss2.RSSItem( title=str(entry.get('title', '(notitle)'). encode('utf-8', 'replace')), link=str(entry.get('link', None).encode( 'utf-8', 'replace')), description=str(entry.get('description', '').encode('utf-8', 'replace')), pubDate=entry.get('created_on', now) ) for entry in feed.get('entries', [])]) except Exception: #if an exception is raised, we use the former methon which works fine rss = rss2.RSS2(title=str(feed.get('title', '(notitle)')), link=str(feed.get('link', None)), description=str(feed.get('description', '')), lastBuildDate=feed.get('created_on', now), items=[rss2.RSSItem( title=str(entry.get('title', '(notitle)' )), link=str(entry.get('link', None)), description=str(entry.get('description', '')), pubDate=entry.get('created_on', now) ) for entry in feed.get('entries', [])]) return rss.to_xml(encoding='utf-8') * Thank you Le jeudi 30 mai 2013 23:09:53 UTC+2, Sebastian Ortiz Vasquez a écrit : Is not mandatory, is enough appling the patch described above to the sax_parser. On Thu, May 30, 2013 at 4:08 PM, Loïc ESPERN lo...@espern.net wrote: I'm currently using python 2.7.3 Should I update to the latest 2.7.5 to get this work ? Le 30 mai 2013 21:57, Sebastian Ortiz Vasquez neo...@gmail.com a écrit : Hi, Yes, in order to get this working, you should also update your cpython distribution, check the bug here http://bugs.python.org/issue17606 On
[web2py] Re: br / in a view
This works. Thanks On Monday, June 3, 2013 5:14:37 PM UTC+2, villas wrote: Try this: {{cell_value = XML(br /.join(map(str, cell_value)))}} On Monday, 3 June 2013 16:03:01 UTC+1, Domagoj Kovač wrote: Hi, I have a code like this: {{for row in table:}} tr {{for report_attribute in report_attributes:}} {{cell_value = table[row][ report_attribute.report_attribute.id][cell_value]}} {{if type(cell_value) is list:}} {{cell_value = br /.join(map(str, cell_value))}} {{pass}} {{=TD(cell_value, _class=table[row][ report_attribute.report_attribute.id][css_class])}} {{pass}} /tr {{pass}} This line is used to join list and br / is used as separator br / {{cell_value = br /.join(map(str, cell_value))}} The problem i have is that br / is escaped and in my browser i get result like 2013-04-04br /2013-05-31br /2013-05-16br /2013-06-01br /2013-05-01br /2013-05-03. I assume that this escaping is some security feature. Is there a way that i could print this without escaping? -- --- 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: Code changes not honored (by web2py?)
Chr_M chr.mntn@... writes: No, I am not using Ajax callbacks. I have done some more research, but I could be a Python thing as well.http://stackoverflow.com/questions/437589/how-do-i-unload-reload-a- python-modulehttp://stackoverflow.com/questions/2918898/prevent-python-from- caching-the-imported-modulesThe common most reliable answer seems to be to restart the python interpreter, thus to restart web2py webserver.Or is there a way web2py's webserver can automatically reload when code changes in modules (it seems Django does it that way)? Or has web2py solved this in another way?Regards, ChrisOn Monday, December 10, 2012 10:03:43 AM UTC+1, Lazarof wrote: Hi! Are you using Ajax callback funcion?понедельник, 10 декабря 2012 г., 1:34:09 UTC+4 пользователь Chr_M написал:Sometimes the changes in the code of a module (in the modules directory) are not working when requesting the url that uses these modules. in the modules directory I have a subdirectory with python files that form a package (__init__.py file in this subdirectory). I have added from gluon.custom_import import track_changestrack_changes()in the first model that gets called, but still sometimes code changes are not working. I noticed that the py-files in the modules dir get compiled to pyc-files. But at one point (it looks to be randomly) these are not compiled anymore when I change code in the py-files. But even when I remove these pyc-files, the code changes are still not working when requesting the url. Am I missing something? Is there a cache I can clear or something? I now have to restart web2py to make the code changes work...Thanks.Regards, Chris i had the same problem that code changes were not seen by the web2py, maybe the problem is like my problem which is there are more than one web2py instance are working at the same time, better check out for the processes list. -- --- 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: changing the flash message, inside the onaccept / onvalidation function
No, the outcome changes as a result of the onvalidatoion / onaccept operation. Is there any other way, or I'll just use SQLFORM and forget about it? On Monday, June 3, 2013 6:36:29 PM UTC+3, Anthony wrote: Is it possible to determine the message before calling crud.create()? If so, you can either set crud.messages.record_created or use the message argument to crud.create(). Otherwise, you'll have to use an onaccept function instead of onvalidation to change the message -- and you should set response.flash rather than session.flash (crud.create() will automatically copy the message to session.flash in case of a redirect). Anthony On Monday, June 3, 2013 5:25:08 AM UTC-4, guruyaya wrote: Say I'm using this crud function form = crud.create(db.some_table, next=URL()+'?id=[id]', onvalidation=do_stuff) def do_stuff(bla): session.flash = I've just changed the flash message Well, I've tried this one. It doesn't change the flash message (I get the usual Record created), wether I'm using onaccept or onvalidation. Is there any way I can change the flash message, that I miss? Thanks in advance Yair -- --- 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] Avoiding extra quries when using DAL
Lets examine this code for a sec: db.define_table('table1',Field('name')) db.define_table('table2',Field('table1', db.table1), Field('name2')) Now, if I need a list of all table2 entries, but not the table1 entries, I'll do something like this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.name2 BUT As you well know, web2py acctuall did ask for table1 info, just in case I'll do this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name On a normal hosting, it doesn't matter that much, but on GAE, it does an extra query to the datastore, and that's just a waste. Is there a way to avoid that? Thanks in advance Yair -- --- 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: Scheduler task in GAE
Hi Niphlod, Do you have any example about how use GAE tash queue from web2py?, can I use it inside my main controller without problem? something like this: # Add the task to the default queue. taskqueue.add(url='/worker', params={'key': key}) I've see this example: https://developers.google.com/appengine/docs/python/taskqueue/overview-pushbut I'm lost about how to use it from my controller and Web2Py. Thanks! On Monday, June 3, 2013 9:12:14 PM UTC+2, Niphlod wrote: ehmm.. scheduler is NOT meant to be run on GAE. They have task queue for that. On Monday, June 3, 2013 7:59:45 PM UTC+2, José Manuel López wrote: Hi Massimo, this is my Web2Py version: Version 2.4.6-stable+timestamp.2013.04.06.17.37.38 And I'm running on 2.5 Python version, maybe I've to switch to 2.7?. On Monday, June 3, 2013 6:56:16 PM UTC+2, Massimo Di Pierro wrote: Which web2py version? Which Python version? You may be on an early Python version that does include multiprocessing. On Monday, 3 June 2013 11:01:38 UTC-5, José Manuel López wrote: Hi, I've a function call SendReport that send an email to every user in my system every day (morning), something like a newsletter. Now, I've to make this task with the scheduler but I'm not sure how to do it. I've see the video (thanks Massimo), but I'm not sure where I've to do it. This is my code: Scheduler(db, dict(sendReport=sendReport())) I've done it in a file task.py inside models and inside my main controller... but it's not working it throws me this trace: ImportError: Cannot import module 'multiprocessing' What I'm doing wrong?. Thank you for your help! -- --- 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: Setting SELECT to request.vars with value/_value?
Very strange. What is the the generated HTML after submit? On Tuesday, 4 June 2013 00:33:36 UTC-5, rppowell wrote: Hello; I am using SELECT in a FORM and I noticed this behavior. Using the following in a controller, such as default.py: def selector_test(): items = [ OPTION('One', _value=1), OPTION('Two', _value=2), OPTION('Three', _value=3), ] form = FORM( SELECT(_name='first', *items, value=request.vars['first'] or None), SELECT(_name='second', *items, value=request.vars['second'] or None), SELECT(_name='third', *items, value=request.vars['third'] or None), INPUT(_type='submit') ) if form.accepts(request, session): response.flash = 'form processed' elif form.errors: response.flash = 'error!' else: response.flash = 'enter form' return dict(form=form, vars=form.vars) When I go to that page, I see the following selectors: [ One ] [ One ] [ One ] When I set the value to so: [ One ] [ Two ] [ Three ] And click submit, I observe the following: The vars in the request is: vars:first:1second:2third:3 But, the SELECT display: [ Three ] [ Three ] [ Three ] I observe the same behavior is I use value or _value, on Chrome 26 and Firefox 19 / Mac OSX. What can I do to have the SELECT display the value from the form.vars? Thank you for your time; -Rob Powell -- --- 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: Avoiding extra quries when using DAL
for entity in db(db.table2.id 0).select(): retVal += entity.table1.name No, web2py does not retrieve entity.table1.name when the first line above is executed. Rather, it does a separate select when the second line is executed. entity.table1 is a DAL Reference object -- when you access one of its attbibutes (i.e., the name of a field in the referenced table), it does a database select to get the associated value. So, there are no extra queries with the initial select, but if you run that for loop, you will get an extra query for each iteration. This is mentioned in the book section on recursive selects http://web2py.com/books/default/chapter/29/06#Recursive-selects, where it is recommended to use a join rather than doing recursive selects over a large number of records (on GAE you couldn't do a join, but you could use .belongs() to minimize the number of queries). Anthony -- --- 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: Grouping more than two fields in the same column of a smartgrid
I found a solution: db.protocol.region.represent = lambda v,r: str(r.protocol.region) + '-' + str(r.protocol.sequence) + '/' + str(r.protocol.year) In the controller, you must also set readable to false for db.protocol.sequence and db.protocol.year , and they must be present in the grid´s field parameter (and only db.protocol.region must be present in the grid´s headers parameter) Fred On Wednesday, May 29, 2013 11:44:45 AM UTC-3, Fred Guedes Pereira wrote: Hi, Is there a way to group two or more table fields in the same column of a SQLFORM.smartgrid? Consider this model, as an example: db.define_table(protocol, Field(region, integer), Field(sequence, integer), Field(year, integer), Field(details, string)) The fields region + sequence + year should get together in the same column of the smartgrid (formated as region-sequence/year, p.e.). I tryed with VirtualFields, but they do not appear in smartgrids. One more doubt: is it possible to hide that link (with the table name in plural) that smartgrids generate above the search panel? thank you, Fred -- --- 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.
Re: [web2py] Avoiding extra quries when using DAL
Maybe something like that. You could do the query and save it as a dict and work on it. result = db(db.table2.id 0).select().as_dict() retVal = [entity.name for entity in result] 2013/6/4 guruyaya guruy...@gmail.com Lets examine this code for a sec: db.define_table('table1',Field('name')) db.define_table('table2',Field('table1', db.table1), Field('name2')) Now, if I need a list of all table2 entries, but not the table1 entries, I'll do something like this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.name2 BUT As you well know, web2py acctuall did ask for table1 info, just in case I'll do this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name On a normal hosting, it doesn't matter that much, but on GAE, it does an extra query to the datastore, and that's just a waste. Is there a way to avoid that? Thanks in advance Yair -- --- 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. -- Att. Carlos J. Costa Cientista da Computação Esp. Gestão em Telecom EL MELECH NEEMAN! אָמֵן -- --- 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] Help us check new cool features!
Conditional fields in forms: https://groups.google.com/forum/?fromgroups=#!topic/web2py/A-St4TX1xls Virtual fields in grids: https://groups.google.com/forum/?fromgroups=#!topic/web2py-developers/DvHvwYYi_Kc New appadmin interface (to manage groups, permissions, tables) that can be exposed to app managers: https://groups.google.com/d/msg/web2py-developers/e0BaYjlHsO0/YAdefdALNr4J Do it work for you? Is it easy to use? Is it useful? Should be done differently? -- --- 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: Avoiding extra quries when using DAL
I would replace retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name with table1_map = db(db.table2 http://db.table2.id/).select().as_dict() retVal = [table1_map[entity.table1].name http://entity.table1.name/ for entity in db(db.table2 http://db.table2.id/).select()] It will loads all records from table1 in ram but your code does it too. Two queries instead of many. select().as_dict() creates a dict where the key is the id and the value is the record. On Tuesday, 4 June 2013 04:25:06 UTC-5, guruyaya wrote: Lets examine this code for a sec: db.define_table('table1',Field('name')) db.define_table('table2',Field('table1', db.table1), Field('name2')) Now, if I need a list of all table2 entries, but not the table1 entries, I'll do something like this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.name2 BUT As you well know, web2py acctuall did ask for table1 info, just in case I'll do this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name On a normal hosting, it doesn't matter that much, but on GAE, it does an extra query to the datastore, and that's just a waste. Is there a way to avoid that? Thanks in advance Yair -- --- 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: Grouping more than two fields in the same column of a smartgrid
You can also do: db.protocol.region.represent = lambda v,r: %(region)s-%(sequence)s/%(year)s % r.protocol On Tuesday, 4 June 2013 07:19:07 UTC-5, Fred Guedes Pereira wrote: I found a solution: db.protocol.region.represent = lambda v,r: str(r.protocol.region) + '-' + str(r.protocol.sequence) + '/' + str(r.protocol.year) In the controller, you must also set readable to false for db.protocol.sequence and db.protocol.year , and they must be present in the grid´s field parameter (and only db.protocol.region must be present in the grid´s headers parameter) Fred On Wednesday, May 29, 2013 11:44:45 AM UTC-3, Fred Guedes Pereira wrote: Hi, Is there a way to group two or more table fields in the same column of a SQLFORM.smartgrid? Consider this model, as an example: db.define_table(protocol, Field(region, integer), Field(sequence, integer), Field(year, integer), Field(details, string)) The fields region + sequence + year should get together in the same column of the smartgrid (formated as region-sequence/year, p.e.). I tryed with VirtualFields, but they do not appear in smartgrids. One more doubt: is it possible to hide that link (with the table name in plural) that smartgrids generate above the search panel? thank you, Fred -- --- 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.
Re: [web2py] Re: Avoiding extra quries when using DAL
Hum, I forgot the problem has two tables. Nice! 2013/6/4 Massimo Di Pierro massimo.dipie...@gmail.com I would replace retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name with table1_map = db(db.table2 http://db.table2.id/).select().as_dict() retVal = [table1_map[entity.table1].name http://entity.table1.name/ for entity in db(db.table2 http://db.table2.id/).select()] It will loads all records from table1 in ram but your code does it too. Two queries instead of many. select().as_dict() creates a dict where the key is the id and the value is the record. On Tuesday, 4 June 2013 04:25:06 UTC-5, guruyaya wrote: Lets examine this code for a sec: db.define_table('table1',**Field('name')) db.define_table('table2',**Field('table1', db.table1), Field('name2')) Now, if I need a list of all table2 entries, but not the table1 entries, I'll do something like this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.name2 BUT As you well know, web2py acctuall did ask for table1 info, just in case I'll do this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name On a normal hosting, it doesn't matter that much, but on GAE, it does an extra query to the datastore, and that's just a waste. Is there a way to avoid that? Thanks in advance Yair -- --- 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. -- Att. Carlos J. Costa Cientista da Computação Esp. Gestão em Telecom EL MELECH NEEMAN! אָמֵן -- --- 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] current.session
Hi, In one of my modules I'm trying to create a local socket connection that persists across a single session (one socket per one user logged into the system from a given browser), and thought that current.session would give me the info I needed. Specifically, we use a lot of REST calls in our frontend code to populate data for certain elements on the screen and this creates a new session hash for the current.session each time, but the actual session is the same. The only way I've been able to get a key that identifies the session is to run: cookies = current.request[cookies] session = cookies[session_id_appname].value Shouldn't some identifier (or even this cookie itself) be available in current.session? Perhaps I misunderstand the point of current.session. Matt -- --- 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: Setting SELECT to request.vars with value/_value?
When you set the value attribute of a SELECT, it then sets the _selected attribute of the associated OPTION to selected (and the _selected attribute of all other OPTIONs to None). In this case, you have passed the same list of OPTIONs to each SELECT. The list of OPTIONs is mutable, and the attributes of each OPTION are mutable as well, so each call to SELECT iterates over the same three OPTION objects and mutates their attributes (changing the values of the _selected attributes each time). So, all three SELECTs end up with the same selected option as the third (and final) SELECT. To get this to work, you need to deepcopy the list of OPTIONs (so it copies not only the OPTION objects, but also the attributes within each OPTION): from copy import deepcopy form = FORM( SELECT(_name='first', *deepcopy(items), value=request.vars[ 'first'] or None), SELECT(_name='second', *deepcopy(items), value=request.vars[ 'second'] or None), SELECT(_name='third', *deepcopy(items), value=request.vars[ 'third'] or None), INPUT(_type='submit') ) Or you can use some other means to generate separate lists of items, such as writing a function that returns a new list each time it is called. In general, you have to be careful when you re-use mutable objects. In this case, the problem is that the mutation (i.e., setting the _selected attribute of each OPTION) happens for all three SELECTs before each SELECT is serialized into HTML -- so when the form is serialized, all three SELECTS are serialized with the final set of mutations. Anthony On Tuesday, June 4, 2013 1:33:36 AM UTC-4, rppowell wrote: Hello; I am using SELECT in a FORM and I noticed this behavior. Using the following in a controller, such as default.py: def selector_test(): items = [ OPTION('One', _value=1), OPTION('Two', _value=2), OPTION('Three', _value=3), ] form = FORM( SELECT(_name='first', *items, value=request.vars['first'] or None), SELECT(_name='second', *items, value=request.vars['second'] or None), SELECT(_name='third', *items, value=request.vars['third'] or None), INPUT(_type='submit') ) if form.accepts(request, session): response.flash = 'form processed' elif form.errors: response.flash = 'error!' else: response.flash = 'enter form' return dict(form=form, vars=form.vars) When I go to that page, I see the following selectors: [ One ] [ One ] [ One ] When I set the value to so: [ One ] [ Two ] [ Three ] And click submit, I observe the following: The vars in the request is: vars:first:1second:2third:3 But, the SELECT display: [ Three ] [ Three ] [ Three ] I observe the same behavior is I use value or _value, on Chrome 26 and Firefox 19 / Mac OSX. What can I do to have the SELECT display the value from the form.vars? Thank you for your time; -Rob Powell -- --- 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: Disable button in /admin
Just a comment, this wasn't obvious to me, but is now. I found this, which helped * http://www.web2py.com/book/default/chapter/03#Startup enable/disable* each application. When an application is disabled it cannot be called remotely but it is not disabled form localhost. This means disabled applications can still be accessed behind a proxy. An application is disabled by creating a file called DISABLED in the application folder. Users who try to access a disabled application will receive a 503 HTTP error. You can use routes_onerror to customize the error page. When I disable my app ON the internet (not locally)... I get web page saying... Temporarily down for maintenance Rob https://lh3.googleusercontent.com/-mOVBuzqlWm0/Ua3oH8X6VGI/AWQ/8IR0PPPkvig/s1600/Screen+Shot+2013-06-04+at+9.12.32+AM.png On Monday, January 30, 2012 7:45:10 AM UTC-5, Alexandre Andrade wrote: While it can be a little obvious what it can do, the button 'Disable' in /admin/site has no documentation at book. The main doubt is what happens if i disable, if I will be able to enable easily again. So its interesting append it to the book. -- Atenciosamente Alexandre Andrade Hipercenter.com Classificados Gratuitos -- --- 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: Few controllers in the same basic layout
Yes, the direct including works like charm. On Monday, June 3, 2013 7:09:10 PM UTC+2, Anthony wrote: If you don't want to do an Ajax request on every page to fetch the login form, you might consider either (a) retrieving the form via Ajax only when the user clicks on a link/button, or (b) including the form directly in the layout (which will require changing the action attribute so the form posts to the login action): {{=auth.login().update(_action=auth.settings.login_url) if not auth.user else ''}} If you include the above in layout.html, it will show the login form if the user is not logged in, and when submitted, the form will post to the login action. Anthony On Monday, June 3, 2013 4:35:50 AM UTC-4, lesssugar wrote: All clear. Thank you. On Monday, June 3, 2013 5:34:55 AM UTC+2, Massimo Di Pierro wrote: On Sunday, 2 June 2013 17:15:55 UTC-5, lesssugar wrote: OK, this might be a silly one. My app uses one main view (layout.html), which is extended by every other one. layout.html has a login form included, created in default.py controller (the form is supposed to be at hand until user signs in). Now, whenever I use any other controller, I get an error saying that name login_form is not defined. Example: I'm on default/index page (the login form's included). I click on a link to go to [other controller]/index (which of course extends layout.html). The page throws the mentioned error. Do all the functions in controllers other than default.py need to return login_form to get it working? Yes. web2py is a push framework, like Rails and Django, not a pull framework. You have the option of defining the login form in a model (nor recommended) or handle the login form via ajax. I believe not but I'm not sure how to do it properly. -- --- 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: changing the flash message, inside the onaccept / onvalidation function
The other way is to do something in onaccept: def do_stuff(bla): session.flash = I've just changed the flash message def set_flash(form): if session.flash: response.flash = session.flash orm = crud.create(db.some_table, next=URL()+'?id=[id]', onvalidation= do_stuff, onaccept=set_flash) Anthony On Tuesday, June 4, 2013 4:57:42 AM UTC-4, guruyaya wrote: No, the outcome changes as a result of the onvalidatoion / onaccept operation. Is there any other way, or I'll just use SQLFORM and forget about it? On Monday, June 3, 2013 6:36:29 PM UTC+3, Anthony wrote: Is it possible to determine the message before calling crud.create()? If so, you can either set crud.messages.record_created or use the message argument to crud.create(). Otherwise, you'll have to use an onaccept function instead of onvalidation to change the message -- and you should set response.flash rather than session.flash (crud.create() will automatically copy the message to session.flash in case of a redirect). Anthony On Monday, June 3, 2013 5:25:08 AM UTC-4, guruyaya wrote: Say I'm using this crud function form = crud.create(db.some_table, next=URL()+'?id=[id]', onvalidation=do_stuff) def do_stuff(bla): session.flash = I've just changed the flash message Well, I've tried this one. It doesn't change the flash message (I get the usual Record created), wether I'm using onaccept or onvalidation. Is there any way I can change the flash message, that I miss? Thanks in advance Yair -- --- 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: Setting SELECT to request.vars with value/_value?
Very interesting explanation, but it still seems obscure and not the kind of thing the average user would consider. Isn't there an easier way to make this work as expected? For example, shouldn't differently named SELECTs be parsed independently from each other? On Tuesday, 4 June 2013 14:19:28 UTC+1, Anthony wrote: When you set the value attribute of a SELECT, it then sets the _selected attribute of the associated OPTION to selected (and the _selected attribute of all other OPTIONs to None). In this case, you have passed the same list of OPTIONs to each SELECT. The list of OPTIONs is mutable, and the attributes of each OPTION are mutable as well, so each call to SELECT iterates over the same three OPTION objects and mutates their attributes (changing the values of the _selected attributes each time). So, all three SELECTs end up with the same selected option as the third (and final) SELECT. To get this to work, you need to deepcopy the list of OPTIONs (so it copies not only the OPTION objects, but also the attributes within each OPTION): from copy import deepcopy form = FORM( SELECT(_name='first', *deepcopy(items), value=request.vars[ 'first'] or None), SELECT(_name='second', *deepcopy(items), value=request.vars[ 'second'] or None), SELECT(_name='third', *deepcopy(items), value=request.vars[ 'third'] or None), INPUT(_type='submit') ) Or you can use some other means to generate separate lists of items, such as writing a function that returns a new list each time it is called. In general, you have to be careful when you re-use mutable objects. In this case, the problem is that the mutation (i.e., setting the _selected attribute of each OPTION) happens for all three SELECTs before each SELECT is serialized into HTML -- so when the form is serialized, all three SELECTS are serialized with the final set of mutations. Anthony On Tuesday, June 4, 2013 1:33:36 AM UTC-4, rppowell wrote: Hello; I am using SELECT in a FORM and I noticed this behavior. Using the following in a controller, such as default.py: def selector_test(): items = [ OPTION('One', _value=1), OPTION('Two', _value=2), OPTION('Three', _value=3), ] form = FORM( SELECT(_name='first', *items, value=request.vars['first'] or None), SELECT(_name='second', *items, value=request.vars['second'] or None), SELECT(_name='third', *items, value=request.vars['third'] or None), INPUT(_type='submit') ) if form.accepts(request, session): response.flash = 'form processed' elif form.errors: response.flash = 'error!' else: response.flash = 'enter form' return dict(form=form, vars=form.vars) When I go to that page, I see the following selectors: [ One ] [ One ] [ One ] When I set the value to so: [ One ] [ Two ] [ Three ] And click submit, I observe the following: The vars in the request is: vars:first:1second:2third:3 But, the SELECT display: [ Three ] [ Three ] [ Three ] I observe the same behavior is I use value or _value, on Chrome 26 and Firefox 19 / Mac OSX. What can I do to have the SELECT display the value from the form.vars? Thank you for your time; -Rob Powell -- --- 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: Avoiding extra quries when using DAL
OK, so I could be wrong about this. Is there a way to get the number of GAE datastore reads per request? On Tuesday, June 4, 2013 12:25:06 PM UTC+3, guruyaya wrote: Lets examine this code for a sec: db.define_table('table1',Field('name')) db.define_table('table2',Field('table1', db.table1), Field('name2')) Now, if I need a list of all table2 entries, but not the table1 entries, I'll do something like this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.name2 BUT As you well know, web2py acctuall did ask for table1 info, just in case I'll do this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name On a normal hosting, it doesn't matter that much, but on GAE, it does an extra query to the datastore, and that's just a waste. Is there a way to avoid that? Thanks in advance Yair -- --- 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: Setting SELECT to request.vars with value/_value?
I agree it should. The price to pay is copying the tree all times even when not necessary. Another solution would be to move to the new helpers (web3py). hopefully we will backport them soon. On Tuesday, 4 June 2013 09:04:46 UTC-5, villas wrote: Very interesting explanation, but it still seems obscure and not the kind of thing the average user would consider. Isn't there an easier way to make this work as expected? For example, shouldn't differently named SELECTs be parsed independently from each other? On Tuesday, 4 June 2013 14:19:28 UTC+1, Anthony wrote: When you set the value attribute of a SELECT, it then sets the _selected attribute of the associated OPTION to selected (and the _selected attribute of all other OPTIONs to None). In this case, you have passed the same list of OPTIONs to each SELECT. The list of OPTIONs is mutable, and the attributes of each OPTION are mutable as well, so each call to SELECT iterates over the same three OPTION objects and mutates their attributes (changing the values of the _selected attributes each time). So, all three SELECTs end up with the same selected option as the third (and final) SELECT. To get this to work, you need to deepcopy the list of OPTIONs (so it copies not only the OPTION objects, but also the attributes within each OPTION): from copy import deepcopy form = FORM( SELECT(_name='first', *deepcopy(items), value=request.vars[ 'first'] or None), SELECT(_name='second', *deepcopy(items), value=request.vars[ 'second'] or None), SELECT(_name='third', *deepcopy(items), value=request.vars[ 'third'] or None), INPUT(_type='submit') ) Or you can use some other means to generate separate lists of items, such as writing a function that returns a new list each time it is called. In general, you have to be careful when you re-use mutable objects. In this case, the problem is that the mutation (i.e., setting the _selected attribute of each OPTION) happens for all three SELECTs before each SELECT is serialized into HTML -- so when the form is serialized, all three SELECTS are serialized with the final set of mutations. Anthony On Tuesday, June 4, 2013 1:33:36 AM UTC-4, rppowell wrote: Hello; I am using SELECT in a FORM and I noticed this behavior. Using the following in a controller, such as default.py: def selector_test(): items = [ OPTION('One', _value=1), OPTION('Two', _value=2), OPTION('Three', _value=3), ] form = FORM( SELECT(_name='first', *items, value=request.vars['first'] or None), SELECT(_name='second', *items, value=request.vars['second'] or None), SELECT(_name='third', *items, value=request.vars['third'] or None), INPUT(_type='submit') ) if form.accepts(request, session): response.flash = 'form processed' elif form.errors: response.flash = 'error!' else: response.flash = 'enter form' return dict(form=form, vars=form.vars) When I go to that page, I see the following selectors: [ One ] [ One ] [ One ] When I set the value to so: [ One ] [ Two ] [ Three ] And click submit, I observe the following: The vars in the request is: vars:first:1second:2third:3 But, the SELECT display: [ Three ] [ Three ] [ Three ] I observe the same behavior is I use value or _value, on Chrome 26 and Firefox 19 / Mac OSX. What can I do to have the SELECT display the value from the form.vars? Thank you for your time; -Rob Powell -- --- 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: AD LDAP manage_user problem
It's like you do not have a db DAL object. Where is your db connection settings? 2013. június 3., hétfő 23:22:30 UTC+2 időpontban mrendon a következőt írta: Thanks! Is this it? Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/www-data/web2py/applications/alcolholedu/controllers/default.py, line 14, in module File /home/www-data/web2py/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/www-data/web2py/applications/alcolholedu/controllers/default.py, line 3, in user def user(): return dict(form=auth()) File /home/www-data/web2py/gluon/tools.py, line 1285, in __call__ return getattr(self, args[0])() File /home/www-data/web2py/gluon/tools.py, line 2143, in login request.vars[passfield]): File /home/www-data/web2py/gluon/contrib/login_methods/ldap_auth.py, line 421, in ldap_auth_aux user_in_db = db(db.auth_user.email == username) AttributeError: 'NoneType' object has no attribute 'auth_user' On Monday, June 3, 2013 3:08:29 PM UTC-6, Derek wrote: We need to see the whole traceback. On Monday, June 3, 2013 9:21:51 AM UTC-7, mrendon wrote: Hi. I'm trying to get email address and name attributes imported into my database. I'm using Active Directory and version web2py 2.4.7-stable+timestamp.2013.05.24.17.48.47. I think I've followed the instructions in the ldap_auth.py file under gluon/contrib/login_methods. Relevant part of db.py: ## create all tables needed by auth if not custom tables auth.define_tables(username=True) auth.settings.create_user_groups=False ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True # all we need is login auth.settings.actions_disabled=['register','change_password', 'request_reset_password','retrieve_username','profile'] # you don't have to remember me auth.settings.remember_me_form = False from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth(mode='ad', server='xxx..xxx', base_dn='OU=,DC=,DC=xx', bind_dn='CN=xxx,CN=x,DC=xx,DC=x', bind_pw='xx', manage_user=True, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail' )) I'm able to login without manage_user=True. But when I try to use it I get the following error: type 'exceptions.AttributeError'('NoneType' object has no attribute 'auth_user') Any ideas? -- --- 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] css help
I would like help with two css issues: 1) In layout.html if there is no response.title, the page content slides up and may disappear under the menu banner. Can we prevent this? 2) In web2py_bootstrap.css I would like to have example code to change the colors without changing the bootstrap.css (specifically color of links, headers, menu banner, and add a page wide image under the menu banner. These seems to be recurrent needs. -- --- 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.
Re: [web2py] css help
For 1, I do that : /* -- */ /* In order to allow footer to stick at the bottom even if the page core is empty Main design come from this tutorial : http://fvsch.com/code/page-hauteur-100/ Other help may be find here : http://stackoverflow.com/questions/11677886/twitter-bootstrap-div-in-container-with-100-height http://jsfiddle.net/S3Gvf/ */ html, body { height: 100%; font-size: 13px; /* Suggested by Fannie */ line-height: 19px; /* Suggested by Fannie */ } .fill { position: relative; width: 90%; margin: 0 auto; min-height: 100%; } div#footer_row { position: absolute; bottom: 0; left: 0; width: 103%; height: 7em; } div#first_page_element_outside_of_footer { margin-top: 60px; /* Required to make sure the header block don't slip below the fixed-top navbar */ } div#last_page_element_outside_of_footer { margin-bottom: 0; padding-bottom: 8em; /* ATTENTION : The amount should contain the footer! */ } /* -- */ But I had change many other thing to allow footer to stick at bottom too... Richard On Tue, Jun 4, 2013 at 10:20 AM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I would like help with two css issues: 1) In layout.html if there is no response.title, the page content slides up and may disappear under the menu banner. Can we prevent this? 2) In web2py_bootstrap.css I would like to have example code to change the colors without changing the bootstrap.css (specifically color of links, headers, menu banner, and add a page wide image under the menu banner. These seems to be recurrent needs. -- --- 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. -- --- 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] More Manual Issues
Still working through the manual, however puzzling and unexplained things do still occur. For instance: why does this code (cut and pasted from P.233) - placed in a view of course - always generate a syntax error? {{=DIV(B(I(hello , world))), _class=myclass)}} Well, first I thought it was because there was an unmatched right parentheses at the end but, when you remove it the syntax error remains, so, I beseech The Collective: Is this a manual error or my own error of understanding? Why, indeed, is there an unmatched right parentheses? Many sincere thanks for assisting my future comprehension... -- --- 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: Setting SELECT to request.vars with value/_value?
On Tuesday, June 4, 2013 10:04:46 AM UTC-4, villas wrote: Very interesting explanation, but it still seems obscure and not the kind of thing the average user would consider. Isn't there an easier way to make this work as expected? For example, shouldn't differently named SELECTs be parsed independently from each other? In this specific case, that would certainly make sense, but perhaps not in the general case. Sometimes when you re-use a mutable object, you do want changes made in one place to affect the other contexts. Suppose instead you need to dynamically change the value/label of the third option and you want that change in all of the SELECTs -- in that case, you just change the items object once. The problem here is that it is not transparent that when you set the value argument of SELECT, it is actually changing the attributes of the OPTION objects nested within the SELECT. I'm not sure what the best approach would be. Anthony -- --- 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: Avoiding extra quries when using DAL
{{=response.toolbar()}} includes a button for all the queries and their execution times (this is also available as a list of 2-tuples in db._timings). Anthony On Tuesday, June 4, 2013 10:05:49 AM UTC-4, guruyaya wrote: OK, so I could be wrong about this. Is there a way to get the number of GAE datastore reads per request? On Tuesday, June 4, 2013 12:25:06 PM UTC+3, guruyaya wrote: Lets examine this code for a sec: db.define_table('table1',Field('name')) db.define_table('table2',Field('table1', db.table1), Field('name2')) Now, if I need a list of all table2 entries, but not the table1 entries, I'll do something like this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.name2 BUT As you well know, web2py acctuall did ask for table1 info, just in case I'll do this: retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name On a normal hosting, it doesn't matter that much, but on GAE, it does an extra query to the datastore, and that's just a waste. Is there a way to avoid that? Thanks in advance Yair -- --- 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: More Manual Issues
This works for me: {{=DIV(B(I(hello , world)), _class=myclass)}} The extra ) was after world. Anthony On Tuesday, June 4, 2013 11:28:51 AM UTC-4, REM wrote: Still working through the manual, however puzzling and unexplained things do still occur. For instance: why does this code (cut and pasted from P.233) - placed in a view of course - always generate a syntax error? {{=DIV(B(I(hello , world))), _class=myclass)}} Well, first I thought it was because there was an unmatched right parentheses at the end but, when you remove it the syntax error remains, so, I beseech The Collective: Is this a manual error or my own error of understanding? Why, indeed, is there an unmatched right parentheses? Many sincere thanks for assisting my future comprehension... -- --- 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: Setting SELECT to request.vars with value/_value?
I verified that using 'deepcopy()' resolves issue in my example; Thanks! -Rob Powell -- --- 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.
Re: [web2py] Re: More Manual Issues
Yep, that's the first thing I tried - dinna work. Actually, I tried lots of variations before I devolved to begging for alms on the web - as one always should. On Tue, Jun 4, 2013 at 11:42 AM, Anthony abasta...@gmail.com wrote: This works for me: {{=DIV(B(I(hello , world)), _class=myclass)}} The extra ) was after world. Anthony On Tuesday, June 4, 2013 11:28:51 AM UTC-4, REM wrote: Still working through the manual, however puzzling and unexplained things do still occur. For instance: why does this code (cut and pasted from P.233) - placed in a view of course - always generate a syntax error? {{=DIV(B(I(hello , world))), _class=myclass)}} Well, first I thought it was because there was an unmatched right parentheses at the end but, when you remove it the syntax error remains, so, I beseech The Collective: Is this a manual error or my own error of understanding? Why, indeed, is there an unmatched right parentheses? Many sincere thanks for assisting my future comprehension... -- --- 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/YEIot0j5OKw/unsubscribe?hl=en. 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/groups/opt_out. -- --- 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: How can I get the SQLFORM in HTML example in book 5th Edition to work?
Dear Massimo, Yesterday, I should have said, Anthony's fix changed the first line [defining the form tag]. Sorry about that. was: form now: form action=# enctype=multipart/form-data method=post This fix made the example in the book work for me. However I am not sure there wasn't a greater point being made about GET vs POST methods. Thanks for the help, Massimo. Love and peace, Joe On Monday, June 3, 2013 3:51:37 PM UTC-7, JoeCodeswell wrote: Dear web2py-users, How can I get the SQLFORM in HTML example in book 5th Edition to work? As far as i can tell i have copied the example VERBATIM. In controllers/default.py : def display_manual_form(): form = SQLFORM(db.person) if form.process(session=None, formname='test').accepted: response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' # Note: no form instance is passed to the view return dict() In models/5_appointment.py : # for testing display_manual_form db.define_table('person', Field('name','string'), ) in default/display_manual_form.html : #default/display_manual_form.html {{extend 'layout.html'}} form ul liYour name is input name=name //li /ul input type=submit / input type=hidden name=_formname value=test / /form The behavior is the same as reported in this group herehttps://groups.google.com/forum/#%21searchin/web2py/%22sqlform$20in$20html%22/web2py/PBPf_B_J_8U/d64xohhcUW8J , even though the example adds session=None to the call to .process(), i.e. : Its not validating the form, just flashing fill the form message. Also, no entry gets added to the database. Thanks for the help in advance. Love and peace, Joe -- --- 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] Gateway time-out 504 error with enable_record_versioning
I've defined a new db to be used for archiving purposes with the following: db_archive = DAL(postgres://[address/authentication_info]/db_archive) Then, I attempt to enable archiving of a table by doing this: db.[table_name]._enable_record_versioning(db_archive) The app seems to be successfully connecting to the db, but attempting to enable record versioning causes nginx to produce a gateway time-out 504 error. Any ideas why it could be taking an inordinately long time to create the archive table? Thanks. -- --- 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: AD LDAP manage_user problem
In from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth(mode='ad', server='xxx..xxx', base_dn='OU=,DC=,DC=xx', bind_dn='CN=xxx,CN=x,DC=xx,DC=x', bind_pw='xx', manage_user=True, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail' )) you need to pass an extra db = db from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth(mode='ad', server='xxx..xxx', base_dn='OU=,DC=,DC=xx', bind_dn='CN=xxx,CN=x,DC=xx,DC=x', bind_pw='xx', manage_user=True, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail', db = db, # )) On Monday, 3 June 2013 16:22:30 UTC-5, mrendon wrote: Thanks! Is this it? Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/www-data/web2py/applications/alcolholedu/controllers/default.py, line 14, in module File /home/www-data/web2py/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/www-data/web2py/applications/alcolholedu/controllers/default.py, line 3, in user def user(): return dict(form=auth()) File /home/www-data/web2py/gluon/tools.py, line 1285, in __call__ return getattr(self, args[0])() File /home/www-data/web2py/gluon/tools.py, line 2143, in login request.vars[passfield]): File /home/www-data/web2py/gluon/contrib/login_methods/ldap_auth.py, line 421, in ldap_auth_aux user_in_db = db(db.auth_user.email == username) AttributeError: 'NoneType' object has no attribute 'auth_user' On Monday, June 3, 2013 3:08:29 PM UTC-6, Derek wrote: We need to see the whole traceback. On Monday, June 3, 2013 9:21:51 AM UTC-7, mrendon wrote: Hi. I'm trying to get email address and name attributes imported into my database. I'm using Active Directory and version web2py 2.4.7-stable+timestamp.2013.05.24.17.48.47. I think I've followed the instructions in the ldap_auth.py file under gluon/contrib/login_methods. Relevant part of db.py: ## create all tables needed by auth if not custom tables auth.define_tables(username=True) auth.settings.create_user_groups=False ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True # all we need is login auth.settings.actions_disabled=['register','change_password', 'request_reset_password','retrieve_username','profile'] # you don't have to remember me auth.settings.remember_me_form = False from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth(mode='ad', server='xxx..xxx', base_dn='OU=,DC=,DC=xx', bind_dn='CN=xxx,CN=x,DC=xx,DC=x', bind_pw='xx', manage_user=True, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail' )) I'm able to login without manage_user=True. But when I try to use it I get the following error: type 'exceptions.AttributeError'('NoneType' object has no attribute 'auth_user') Any ideas? -- --- 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: Setting SELECT to request.vars with value/_value?
Anthony, Yes I see, and Massimo's suggestion to backport the superior helpers from Web3py is probably better than making changes to the existing code. However, thanks very much for explaining this effect. D On Tuesday, 4 June 2013 16:36:42 UTC+1, Anthony wrote: On Tuesday, June 4, 2013 10:04:46 AM UTC-4, villas wrote: Very interesting explanation, but it still seems obscure and not the kind of thing the average user would consider. Isn't there an easier way to make this work as expected? For example, shouldn't differently named SELECTs be parsed independently from each other? In this specific case, that would certainly make sense, but perhaps not in the general case. Sometimes when you re-use a mutable object, you do want changes made in one place to affect the other contexts. Suppose instead you need to dynamically change the value/label of the third option and you want that change in all of the SELECTs -- in that case, you just change the items object once. The problem here is that it is not transparent that when you set the value argument of SELECT, it is actually changing the attributes of the OPTION objects nested within the SELECT. I'm not sure what the best approach would be. Anthony -- --- 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.
Re: [web2py] Re: More Manual Issues
OK, not sure what to say -- it definitely works for me. Can you show the full traceback you are getting? Anthony On Tuesday, June 4, 2013 11:45:05 AM UTC-4, REM wrote: Yep, that's the first thing I tried - dinna work. Actually, I tried lots of variations before I devolved to begging for alms on the web - as one always should. On Tue, Jun 4, 2013 at 11:42 AM, Anthony abas...@gmail.com javascript:wrote: This works for me: {{=DIV(B(I(hello , world)), _class=myclass)}} The extra ) was after world. Anthony On Tuesday, June 4, 2013 11:28:51 AM UTC-4, REM wrote: Still working through the manual, however puzzling and unexplained things do still occur. For instance: why does this code (cut and pasted from P.233) - placed in a view of course - always generate a syntax error? {{=DIV(B(I(hello , world))), _class=myclass)}} Well, first I thought it was because there was an unmatched right parentheses at the end but, when you remove it the syntax error remains, so, I beseech The Collective: Is this a manual error or my own error of understanding? Why, indeed, is there an unmatched right parentheses? Many sincere thanks for assisting my future comprehension... -- --- 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/YEIot0j5OKw/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- 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.
Re: [web2py] Re: More Manual Issues
Ok, I made this problem go away: Beneath this code was some earlier stuff which had been commented out. That, as well as the extra unmatched parentheses was together apparently the source of the problem - though the trace didn't show any problems related to the commented-out stuff and said nothing about anything but the syntax error (or I would have tried deleting it earlier). Meanwhile, the original page has been trashed all to heck so I couldn't get back the original trace anyway So, in the future I have learned to exercise even more than normal caution. Sincere thanks for your assistance. I do appreciate it very much! On Tuesday, June 4, 2013 12:22:09 PM UTC-4, Anthony wrote: OK, not sure what to say -- it definitely works for me. Can you show the full traceback you are getting? Anthony On Tuesday, June 4, 2013 11:45:05 AM UTC-4, REM wrote: Yep, that's the first thing I tried - dinna work. Actually, I tried lots of variations before I devolved to begging for alms on the web - as one always should. On Tue, Jun 4, 2013 at 11:42 AM, Anthony abas...@gmail.com wrote: This works for me: {{=DIV(B(I(hello , world)), _class=myclass)}} The extra ) was after world. Anthony On Tuesday, June 4, 2013 11:28:51 AM UTC-4, REM wrote: Still working through the manual, however puzzling and unexplained things do still occur. For instance: why does this code (cut and pasted from P.233) - placed in a view of course - always generate a syntax error? {{=DIV(B(I(hello , world))), _class=myclass)}} Well, first I thought it was because there was an unmatched right parentheses at the end but, when you remove it the syntax error remains, so, I beseech The Collective: Is this a manual error or my own error of understanding? Why, indeed, is there an unmatched right parentheses? Many sincere thanks for assisting my future comprehension... -- --- 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/YEIot0j5OKw/unsubscribe?hl=en. To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- 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: app about page
Negative numbers would indicate lines deleted? Anyway, I think the graph is fine, it should be thought of like a heartbeat - if it's flatline, it's no good. On Sunday, June 2, 2013 2:47:49 AM UTC-7, BlueShadow wrote: https://lh6.googleusercontent.com/-oDE7O7Yvqgk/UasTv8GH5TI/AAk/lB1eTk0eIcw/s1600/project+progress.gif I stumbled apon the about page and this graph so I searched the forums and found this post. seeing the number of lines written is pretty interesting but I can't figure this graph out. why are there negative numbers and spikes in the graph? I my opinion it should progress more or less linear with flat lines for the breaks I took. On Friday, January 4, 2013 11:36:28 AM UTC+1, Ramos wrote: hello. what does it mean the graph in the about page under Project progress? Thank you António -- --- 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: Gateway time-out 504 error with enable_record_versioning
Nevermind - sorted it out. Seems that a bunch of my tables had a dependency on auth_user, and since a new db was created, with table names set to [original_table_name]_archive by default, there was no auth_user table, and the dependency was not being satisfied. If using auth.enable_record_versioning (given that a separate db is used for archiving), one way to solve the issue is by setting the archive_names parameter to '%(tablename)s'. -- --- 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] [newbie] example authorization
In my layoyt.html I have the following code {{=auth.login().update(_action=URL('default', 'login'), _name='global_login' )}} The login form takes user email and password. It generates correctly. Let's assume there are test users in db.auth_user. I would be grateful if someone provided a short example of further login implementation: 1. validate the login data (is email in db? is password correct?) 2. if data OK: redirect to a specific user profile -- --- 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: Web Development Introduction Based On Web2py
I'm guessing you're aware that it's down today.. On Tuesday, December 20, 2011 10:33:21 AM UTC-8, ma...@rockiger.com wrote: I published the first 3 chapters of my web development tutorial at http://killer-web-development.com It's aimed at total web development beginners and uses web2py as framework. The idea was to write a web development tutorial based on web2py, because web2py is the easiest to use web development solution - maybe I can rescue a few people from starting with PHP. The book aims to be an mixture of railstutorial.org and the Head First series. Lots of images and very low level subject matter. A the end readers will develop a full microblogging service. I would appreciate any feedback. Best marco -- --- 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] MongoDB and list:reference?
I am having a problem using a list:reference field with a MongoDB database, like so: db.define_table('page', ... Field('id_moderator','list:reference auth_user',default=auth.user_id), ... ) When I insert a record into this table with a list for the id_moderator field, like so: db.page.insert(...,id_moderator=[id_owner],...) I get the error: object_id argument must be of type ObjectId or an objectid representable integer because the MongoDBAdapter is not expecting the field's value to be a list. Is this not the correct way to set list:reference type fields? By the way, I can get around this by changing this line in MongoDBAdapter's insert function in dal.py: values[fieldname] = self.object_id(v) to this: if isinstance(v,list): values[fieldname] = [self.object_id(x) for x in v] else: values[fieldname] = self.object_id(v) -- --- 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: [newbie] example authorization
The auth.login() action automatically verifies the login and logs the user in (which involves adding the user record to the user's session) -- you don't have to do any of that explicitly. If you want to redirect to a specific URL after login, you can set auth.settings.login_next to the desired URL. Another option is to use auth.settings.login_onaccept, which is a function that takes the login form object (after it has been processed). Anthony On Tuesday, June 4, 2013 1:13:47 PM UTC-4, lesssugar wrote: In my layoyt.html I have the following code {{=auth.login().update(_action=URL('default', 'login'), _name= 'global_login')}} The login form takes user email and password. It generates correctly. Let's assume there are test users in db.auth_user. I would be grateful if someone provided a short example of further login implementation: 1. validate the login data (is email in db? is password correct?) 2. if data OK: redirect to a specific user profile -- --- 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: MongoDB and list:reference?
By the way, I can get around this by changing this line in MongoDBAdapter's insert function in dal.py: values[fieldname] = self.object_id(v) to this: if isinstance(v,list): values[fieldname] = [self.object_id(x) for x in v] else: values[fieldname] = self.object_id(v) I think there's no working implementation available for list:reference types and MongoDB yet, but your patch looks fine. BTW: Have you tried calling table.update instead of insert with list:reference? Also the insert and update methods could support other types of iterables as input. -- --- 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: AD LDAP manage_user problem
Thank you! It works now! On Tuesday, June 4, 2013 9:56:39 AM UTC-6, Massimo Di Pierro wrote: In from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth(mode='ad', server='xxx..xxx', base_dn='OU=,DC=,DC=xx', bind_dn='CN=xxx,CN=x,DC=xx,DC=x', bind_pw='xx', manage_user=True, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail' )) you need to pass an extra db = db from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth(mode='ad', server='xxx..xxx', base_dn='OU=,DC=,DC=xx', bind_dn='CN=xxx,CN=x,DC=xx,DC=x', bind_pw='xx', manage_user=True, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail', db = db, # )) On Monday, 3 June 2013 16:22:30 UTC-5, mrendon wrote: Thanks! Is this it? Traceback (most recent call last): File /home/www-data/web2py/gluon/restricted.py, line 212, in restricted exec ccode in environment File /home/www-data/web2py/applications/alcolholedu/controllers/default.py, line 14, in module File /home/www-data/web2py/gluon/globals.py, line 194, in lambda self._caller = lambda f: f() File /home/www-data/web2py/applications/alcolholedu/controllers/default.py, line 3, in user def user(): return dict(form=auth()) File /home/www-data/web2py/gluon/tools.py, line 1285, in __call__ return getattr(self, args[0])() File /home/www-data/web2py/gluon/tools.py, line 2143, in login request.vars[passfield]): File /home/www-data/web2py/gluon/contrib/login_methods/ldap_auth.py, line 421, in ldap_auth_aux user_in_db = db(db.auth_user.email == username) AttributeError: 'NoneType' object has no attribute 'auth_user' On Monday, June 3, 2013 3:08:29 PM UTC-6, Derek wrote: We need to see the whole traceback. On Monday, June 3, 2013 9:21:51 AM UTC-7, mrendon wrote: Hi. I'm trying to get email address and name attributes imported into my database. I'm using Active Directory and version web2py 2.4.7-stable+timestamp.2013.05.24.17.48.47. I think I've followed the instructions in the ldap_auth.py file under gluon/contrib/login_methods. Relevant part of db.py: ## create all tables needed by auth if not custom tables auth.define_tables(username=True) auth.settings.create_user_groups=False ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True # all we need is login auth.settings.actions_disabled=['register','change_password', 'request_reset_password','retrieve_username','profile'] # you don't have to remember me auth.settings.remember_me_form = False from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth(mode='ad', server='xxx..xxx', base_dn='OU=,DC=,DC=xx', bind_dn='CN=xxx,CN=x,DC=xx,DC=x', bind_pw='xx', manage_user=True, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail' )) I'm able to login without manage_user=True. But when I try to use it I get the following error: type 'exceptions.AttributeError'('NoneType' object has no attribute 'auth_user') Any ideas? -- --- 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] scheduler - looping queueing task
Hi, I use scheduler from few months with - basically - no big issues. In the last days I saw a strange behaviour: tasks queued multiple time when in my shceduler.py I have only one scheduler.queue_task instruction. At first I thougth of multiple scheduler instances thrown by cron jobs (I even don't know if this is possible), but I checked and I have only one scheduler instance running. So I tested this: db.py: db = DAL('postgres://user:passw...@web394.webfaction.com/oadb',pool_size=1,check_reserved=['all'], migrate=True) scheduler.py: db.define_table('testtable',Field('field1','integer'),migrate=True) def test_insert(tablename,value): db[tablename].insert(field1=value) db.commit() return True from gluon.scheduler import Scheduler scheduler = Scheduler(db) scheduler.queue_task('test_insert', pargs=[testtable,1], task_name='insert test', group_name='main', application_name='scrapers' ) When I run from the shell prompt this: /usr/local/bin/python $HOME/webapps/oawa/web2py/web2py.py --password='recycle' --scheduler=scrapers -D 0 I got this log: web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2013 Version 2.4.7-stable+timestamp.2013.05.24.17.48.47 Database drivers available: SQLite(sqlite3), MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib) starting single-scheduler for scrapers... DEBUG:web2py.dal:Your database version does not support the JSON data type (using TEXT instead) DEBUG:web2py.scheduler.web394.webfaction.com#385289:defining tables (migrate=True) DEBUG:web2py.scheduler.web394.webfaction.com#385289:thread building own DAL object DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... DEBUG:web2py.dal:Your database version does not support the JSON data type (using TEXT instead) DEBUG:web2py.scheduler.web394.webfaction.com#385289:defining tables (migrate=False) DEBUG:web2py.scheduler.web394.webfaction.com#385289:freeing workers that have not sent heartbeat INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: I'm a ticker INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recording heartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recording heartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recording heartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recording heartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recording heartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:freeing workers that have not sent heartbeat INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: I'm a ticker DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:Assigning tasks... INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: workers are 1 INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: tasks are 50 DEBUG:web2py.scheduler.web394.webfaction.com#385289:Tasks assigned... DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recording heartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... DEBUG:web2py.scheduler.web394.webfaction.com#385289: work to do 165100 DEBUG:web2py.scheduler.web394.webfaction.com#385289:new scheduler_run record INFO:web2py.scheduler.web394.webfaction.com#385289:new task 165100 insert test scrapers.test_insert DEBUG:web2py.scheduler.web394.webfaction.com#385289: new task allocated: scrapers.test_insert DEBUG:web2py.scheduler.web394.webfaction.com#385289: task starting DEBUG:web2py.scheduler.web394.webfaction.com#385289:task started DEBUG:web2py.scheduler.web394.webfaction.com#385289:new task report: COMPLETED DEBUG:web2py.scheduler.web394.webfaction.com#385289: result: true
[web2py] Re: scheduler - looping queueing task
that's probably because your code queueing the task is inside models, that are executed for every request. Of course, models are executed also in the fake environment that executes the task (so you have at hand, e.g., the database). Move the queue_task() to a controller and queue it only one time, it'll work fine. On Tuesday, June 4, 2013 8:59:45 PM UTC+2, operE Aperte wrote: Hi, I use scheduler from few months with - basically - no big issues. In the last days I saw a strange behaviour: tasks queued multiple time when in my shceduler.py I have only one scheduler.queue_task instruction. At first I thougth of multiple scheduler instances thrown by cron jobs (I even don't know if this is possible), but I checked and I have only one scheduler instance running. So I tested this: db.py: db = DAL('postgres://user:passw...@web394.webfaction.com/oadb',pool_size=1,check_reserved=['all'], migrate=True) scheduler.py: db.define_table('testtable',Field('field1','integer'),migrate=True) def test_insert(tablename,value): db[tablename].insert(field1=value) db.commit() return True from gluon.scheduler import Scheduler scheduler = Scheduler(db) scheduler.queue_task('test_insert', pargs=[testtable,1], task_name='insert test', group_name='main', application_name='scrapers' ) When I run from the shell prompt this: /usr/local/bin/python $HOME/webapps/oawa/web2py/web2py.py --password='recycle' --scheduler=scrapers -D 0 I got this log: web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2013 Version 2.4.7-stable+timestamp.2013.05.24.17.48.47 Database drivers available: SQLite(sqlite3), MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib) starting single-scheduler for scrapers... DEBUG:web2py.dal:Your database version does not support the JSON data type (using TEXT instead) DEBUG:web2py.scheduler.web394.webfaction.com#385289:defining tables (migrate=True) DEBUG:web2py.scheduler.web394.webfaction.com#385289:thread building own DAL object DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... DEBUG:web2py.dal:Your database version does not support the JSON data type (using TEXT instead) DEBUG:web2py.scheduler.web394.webfaction.com#385289:defining tables (migrate=False) DEBUG:web2py.scheduler.web394.webfaction.com#385289:freeing workers that have not sent heartbeat INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: I'm a ticker INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:freeing workers that have not sent heartbeat INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: I'm a ticker DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:Assigning tasks... INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: workers are 1 INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: tasks are 50 DEBUG:web2py.scheduler.web394.webfaction.com#385289:Tasks assigned... DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... DEBUG:web2py.scheduler.web394.webfaction.com#385289: work to do 165100 DEBUG:web2py.scheduler.web394.webfaction.com#385289:new scheduler_run record
[web2py] Re: scheduler - looping queueing task
I'll move queue_task() in controller, but the fact is that (till now) I always used queue_task() in model with no issues, and actually there is no request other then the ones I trigger visiting my site (site is demo, no audience)... On Tuesday, June 4, 2013 9:13:54 PM UTC+2, Niphlod wrote: that's probably because your code queueing the task is inside models, that are executed for every request. Of course, models are executed also in the fake environment that executes the task (so you have at hand, e.g., the database). Move the queue_task() to a controller and queue it only one time, it'll work fine. On Tuesday, June 4, 2013 8:59:45 PM UTC+2, operE Aperte wrote: Hi, I use scheduler from few months with - basically - no big issues. In the last days I saw a strange behaviour: tasks queued multiple time when in my shceduler.py I have only one scheduler.queue_task instruction. At first I thougth of multiple scheduler instances thrown by cron jobs (I even don't know if this is possible), but I checked and I have only one scheduler instance running. So I tested this: db.py: db = DAL('postgres://user:passw...@web394.webfaction.com/oadb',pool_size=1,check_reserved=['all'], migrate=True) scheduler.py: db.define_table('testtable',Field('field1','integer'),migrate=True) def test_insert(tablename,value): db[tablename].insert(field1=value) db.commit() return True from gluon.scheduler import Scheduler scheduler = Scheduler(db) scheduler.queue_task('test_insert', pargs=[testtable,1], task_name='insert test', group_name='main', application_name='scrapers' ) When I run from the shell prompt this: /usr/local/bin/python $HOME/webapps/oawa/web2py/web2py.py --password='recycle' --scheduler=scrapers -D 0 I got this log: web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2013 Version 2.4.7-stable+timestamp.2013.05.24.17.48.47 Database drivers available: SQLite(sqlite3), MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib) starting single-scheduler for scrapers... DEBUG:web2py.dal:Your database version does not support the JSON data type (using TEXT instead) DEBUG:web2py.scheduler.web394.webfaction.com#385289:defining tables (migrate=True) DEBUG:web2py.scheduler.web394.webfaction.com#385289:thread building own DAL object DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... DEBUG:web2py.dal:Your database version does not support the JSON data type (using TEXT instead) DEBUG:web2py.scheduler.web394.webfaction.com#385289:defining tables (migrate=False) DEBUG:web2py.scheduler.web394.webfaction.com#385289:freeing workers that have not sent heartbeat INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: I'm a ticker INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... INFO:web2py.scheduler.web394.webfaction.com#385289:nothing to do DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:recordingheartbeat (ACTIVE) DEBUG:web2py.scheduler.web394.webfaction.com#385289:freeing workers that have not sent heartbeat INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: I'm a ticker DEBUG:web2py.scheduler.web394.webfaction.com#385289:looping... DEBUG:web2py.scheduler.web394.webfaction.com#385289:Assigning tasks... INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: workers are 1 INFO:web2py.scheduler.web394.webfaction.com#385289:TICKER: tasks are 50 DEBUG:web2py.scheduler.web394.webfaction.com#385289:Tasks assigned... DEBUG:web2py.scheduler.web394.webfaction.com#385289:sleeping...
[web2py] Re: scheduler - looping queueing task
yep, but every time a scheduler task starts, it executes models to recreate the environment. given that you commit() in your task, the queueing gets committed too (that's probably the reason why it worked for you until now) You can use the uuid column to specify a unique name for your task, in that case when you try to insert a task that is already there the scheduler will refuse to insert a new one (because of the constraint on that column). However, it's silly to have models queueing tasks, cause the queueing should happen on-demand, not on every possible request ^_^ -- --- 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: New feature in trunk conditional fields RFC
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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: New feature in trunk conditional fields RFC
Show if =visible when No dia 04/06/2013 21:51, Niphlod niph...@gmail.com 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- --- 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] Use newly inserted row after form.process().accepted
I'm trying to use the newly created record after submitting a form. I get the error from myFunc, telling me row is a NoneType. How can I fetch the newly created record? *form = SQLFORM(db.mytable) * *if form.process().accepted: * *row = db.mytable( request.args(0) ) # **request.args(0) should be the id of the newly created record, if I'm not mistaken* *myFunc( row )* -- --- 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] what is step to access to MSSQL
I am trying to access remote mssql My working env is ubuntu and mssql 2008 Do I need any additional installs? Thank you. -- --- 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: Use newly inserted row after form.process().accepted
you are mistaken. request.args(0) is just the first arg of the url /appname/controller/function/this_is_request_args(0). try form.vars.id instead ^_^ On Tuesday, June 4, 2013 10:57:36 PM UTC+2, Robin Manoli wrote: I'm trying to use the newly created record after submitting a form. I get the error from myFunc, telling me row is a NoneType. How can I fetch the newly created record? *form = SQLFORM(db.mytable) * *if form.process().accepted: * *row = db.mytable( request.args(0) ) # **request.args(0) should be the id of the newly created record, if I'm not mistaken* *myFunc( row )* -- --- 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.
Re: [web2py] Re: New feature in trunk conditional fields RFC
yep. BTW: this just hides the field. if someone fills the bb field, it gets sent with the form anyway. On Tuesday, June 4, 2013 10:55:31 PM UTC+2, Ramos wrote: Show if =visible when No dia 04/06/2013 21:51, Niphlod nip...@gmail.com javascript: 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 javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- --- 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.
Re: [web2py] Re: New feature in trunk conditional fields RFC
BTW2: doesn't work on LOADed forms. -- --- 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: MongoDB and list:reference?
update seems to work fine with list:reference as long as the field's value is actually an iterable. I'll do some more testing and make a pull request later. Thanks! On Tuesday, June 4, 2013 2:17:37 PM UTC-4, Alan Etkin wrote: By the way, I can get around this by changing this line in MongoDBAdapter's insert function in dal.py: values[fieldname] = self.object_id(v) to this: if isinstance(v,list): values[fieldname] = [self.object_id(x) for x in v] else: values[fieldname] = self.object_id(v) I think there's no working implementation available for list:reference types and MongoDB yet, but your patch looks fine. BTW: Have you tried calling table.update instead of insert with list:reference? Also the insert and update methods could support other types of iterables as input. -- --- 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: web2py 2.4.7 is Out
Hi Massimo, If you don't mind, could you elaborate on what these bugfixes are? We've just upgraded our system to use v2.4.6 and trying to assess if it's worth it to do the upgrade to v2.4.7 before our launch. Specifically, we've noticed a possible memory leak with our deployment and currently investigating if this might have been due to our upgrade to v2.4.6 and if so, if this bug has been fixed in the latest version. Thanks, Aurelio On Friday, May 24, 2013 10:56:11 AM UTC-7, Massimo Di Pierro wrote: I posted web2py 2.4.7. Includes mostly bug fixes. -- --- 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.
Re: [web2py] Re: New feature in trunk conditional fields RFC
fix for that. function web2py_show_if(target) { var triggers = {}; var show_if = function () { var t = jQuery(this); var id = t.attr('id'); t.attr('value', t.val()); for(var k = 0; k triggers[id].length; k++) { var dep = jQuery('#' + triggers[id][k], target); var tr = jQuery('#' + triggers[id][k] + '__row', target); if(t.is(dep.attr('data-show-if'))) tr.slideDown(); else tr.hide(); } }; jQuery('[data-show-trigger]', target).each(function () { var name = jQuery(this).attr('data-show-trigger'); if(!triggers[name]) triggers[name] = []; triggers[name].push(jQuery(this).attr('id')); }); for(var name in triggers) { jQuery('#' + name, target).change(show_if).keyup(show_if); show_if.call(jQuery('#' + name, target)); }; } and then move the instantiation to the web2py_ajax_init(target) function. On Tuesday, June 4, 2013 11:15:24 PM UTC+2, Niphlod wrote: BTW2: doesn't work on LOADed forms. -- --- 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: what is step to access to MSSQL
You need odbc installed. On Tuesday, June 4, 2013 2:01:13 PM UTC-7, Nam Soo In wrote: I am trying to access remote mssql My working env is ubuntu and mssql 2008 Do I need any additional installs? Thank you. -- --- 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.
Re: [web2py] Re: New feature in trunk conditional fields RFC
Uploading to trunk. Please check it. On Tuesday, 4 June 2013 16:25:15 UTC-5, Niphlod wrote: fix for that. function web2py_show_if(target) { var triggers = {}; var show_if = function () { var t = jQuery(this); var id = t.attr('id'); t.attr('value', t.val()); for(var k = 0; k triggers[id].length; k++) { var dep = jQuery('#' + triggers[id][k], target); var tr = jQuery('#' + triggers[id][k] + '__row', target); if(t.is(dep.attr('data-show-if'))) tr.slideDown(); else tr.hide(); } }; jQuery('[data-show-trigger]', target).each(function () { var name = jQuery(this).attr('data-show-trigger'); if(!triggers[name]) triggers[name] = []; triggers[name].push(jQuery(this).attr('id')); }); for(var name in triggers) { jQuery('#' + name, target).change(show_if).keyup(show_if); show_if.call(jQuery('#' + name, target)); }; } and then move the instantiation to the web2py_ajax_init(target) function. On Tuesday, June 4, 2013 11:15:24 PM UTC+2, Niphlod wrote: BTW2: doesn't work on LOADed forms. -- --- 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: what is step to access to MSSQL
and freedts too. https://gist.github.com/rduplain/1293636 forget about the sqlalchemy part, but the requirements are the same. On Tuesday, June 4, 2013 11:27:49 PM UTC+2, Derek wrote: You need odbc installed. On Tuesday, June 4, 2013 2:01:13 PM UTC-7, Nam Soo In wrote: I am trying to access remote mssql My working env is ubuntu and mssql 2008 Do I need any additional installs? Thank you. -- --- 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: web2py 2.4.7 is Out
The only memory leak I am aware of is when one use the TAG helper. It is fixed in trunk and will be foxed in 2.4.8 but it is not fixed in 2.4.6. I am not aware of other memory leaks. On Tuesday, 4 June 2013 16:22:10 UTC-5, Aurelio Tinio wrote: Hi Massimo, If you don't mind, could you elaborate on what these bugfixes are? We've just upgraded our system to use v2.4.6 and trying to assess if it's worth it to do the upgrade to v2.4.7 before our launch. Specifically, we've noticed a possible memory leak with our deployment and currently investigating if this might have been due to our upgrade to v2.4.6 and if so, if this bug has been fixed in the latest version. Thanks, Aurelio On Friday, May 24, 2013 10:56:11 AM UTC-7, Massimo Di Pierro wrote: I posted web2py 2.4.7. Includes mostly bug fixes. -- --- 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] previous url
Hello I need to know what the last url visited (not the current url). I did this, but it seems ugly. There a better way to do what I need. def previous_url(): if not session.previous_url: session.previous_url = [] session.previous_url.insert(0, request.url) session.previous_url.insert(0, request.url) if len(session.previous_url) == 3: session.previous_url.pop() return session.previous_url[1] José -- --- 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: Web Development Introduction Based On Web2py
unreachable. it return : 502 Bad Gateway -- nginx/1.4.0best regard -- --- 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: web2py 2.4.7 is Out
Thanks for the prompt response Massimo. It doesn't look like we are using the TAG helper for our application but good to know nonetheless. Cheers. On Tuesday, June 4, 2013 2:42:09 PM UTC-7, Massimo Di Pierro wrote: The only memory leak I am aware of is when one use the TAG helper. It is fixed in trunk and will be foxed in 2.4.8 but it is not fixed in 2.4.6. I am not aware of other memory leaks. On Tuesday, 4 June 2013 16:22:10 UTC-5, Aurelio Tinio wrote: Hi Massimo, If you don't mind, could you elaborate on what these bugfixes are? We've just upgraded our system to use v2.4.6 and trying to assess if it's worth it to do the upgrade to v2.4.7 before our launch. Specifically, we've noticed a possible memory leak with our deployment and currently investigating if this might have been due to our upgrade to v2.4.6 and if so, if this bug has been fixed in the latest version. Thanks, Aurelio On Friday, May 24, 2013 10:56:11 AM UTC-7, Massimo Di Pierro wrote: I posted web2py 2.4.7. Includes mostly bug fixes. -- --- 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: previous url
It may not be quite as reliable as recording the URL yourself, but you could also use request.env.http_referer. Anthony On Tuesday, June 4, 2013 5:48:20 PM UTC-4, Jose wrote: Hello I need to know what the last url visited (not the current url). I did this, but it seems ugly. There a better way to do what I need. def previous_url(): if not session.previous_url: session.previous_url = [] session.previous_url.insert(0, request.url) session.previous_url.insert(0, request.url) if len(session.previous_url) == 3: session.previous_url.pop() return session.previous_url[1] José -- --- 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: [newbie] example authorization
OK, I have this in my view: {{if not auth.user:}} {{auth.settings.login_next = URL('default', 'test')}} {{=auth.login().update(_name='global_login')}} a href=# id=pass_resetForgot password?/a {{else:}} a href={{=URL('default', 'user', args='logout')}} class=goldenLogout/a {{pass}} As you say, if login data are correct, user should be automatically logged in and [in this case] redirected to default/test. But when I put (just to test) im my default.py: @auth.requires_login() def test(): return dict(message='you are logged in') and then I try to log in with 100% correct data I am redirected to [appname]/# So no redirection is taking place, neither is logging in (checked it: auth.user is False after submitting the form). Any suggestions? I'm surely doing something wrong and it's supposed to be automatic and easy ;) On Tuesday, June 4, 2013 7:47:41 PM UTC+2, Anthony wrote: The auth.login() action automatically verifies the login and logs the user in (which involves adding the user record to the user's session) -- you don't have to do any of that explicitly. If you want to redirect to a specific URL after login, you can set auth.settings.login_next to the desired URL. Another option is to use auth.settings.login_onaccept, which is a function that takes the login form object (after it has been processed). Anthony On Tuesday, June 4, 2013 1:13:47 PM UTC-4, lesssugar wrote: In my layoyt.html I have the following code {{=auth.login().update(_action=URL('default', 'login'), _name= 'global_login')}} The login form takes user email and password. It generates correctly. Let's assume there are test users in db.auth_user. I would be grateful if someone provided a short example of further login implementation: 1. validate the login data (is email in db? is password correct?) 2. if data OK: redirect to a specific user profile -- --- 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: what is step to access to MSSQL
Microsoft also has a Linux driver as well: http://www.microsoft.com/en-us/download/details.aspx?id=28160. Says it's for Red Hat, but I've heard it works on Ubuntu as well. You'll have to Google for instructions on installation. Anthony On Tuesday, June 4, 2013 5:33:18 PM UTC-4, Niphlod wrote: and freedts too. https://gist.github.com/rduplain/1293636 forget about the sqlalchemy part, but the requirements are the same. On Tuesday, June 4, 2013 11:27:49 PM UTC+2, Derek wrote: You need odbc installed. On Tuesday, June 4, 2013 2:01:13 PM UTC-7, Nam Soo In wrote: I am trying to access remote mssql My working env is ubuntu and mssql 2008 Do I need any additional installs? Thank you. -- --- 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: previous url
or, a perfect usecase for a deque if you put this at the top of your controller, every controller function can access session.previous_url[0] as the last url visited. from collections import deque if session.previous_url is None: session.previous_url = deque([request.url], maxlen=2) else: session.previous_url.append(request.url) On Wednesday, June 5, 2013 12:32:43 AM UTC+2, Anthony wrote: It may not be quite as reliable as recording the URL yourself, but you could also use request.env.http_referer. Anthony On Tuesday, June 4, 2013 5:48:20 PM UTC-4, Jose wrote: Hello I need to know what the last url visited (not the current url). I did this, but it seems ugly. There a better way to do what I need. def previous_url(): if not session.previous_url: session.previous_url = [] session.previous_url.insert(0, request.url) session.previous_url.insert(0, request.url) if len(session.previous_url) == 3: session.previous_url.pop() return session.previous_url[1] José -- --- 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] Checking if db query was successful
Hi, If I set up a query like so, q1 = auth.accessible_query('read', db.stuff) q2 = db.stuff.id==3 selected_record = db(q1q2).select().first() # how to check if this successfully got db record? selected_records = db(q1q2).select()# how to check if this successfully got db records? ...I want to check if my select() or select().first() was successful and contains record(s) before executing more code. These are some ways I thought of doing it, but they have all created problems in one way or another. 1) if selected_record in locals(): # if query successful, returns FALSE 2) if selected_record: # code below still executes even if 'selected_record' does not exist 3) if len(selected_record): # throws row object has no len attribute error Thanks for help, -JL -- --- 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: web2py Safety discussion
I have often wondered if changing the names admin and appadmin would be an easy and simple way to add another layer of security? In other words, add these as command-line arguments that can be set on startup? In this way www.mysite.com/admin could be changed to something like www.mysite.com/secretadmin123. After that access attempts to www.mysite.com/admin could either be handled using the normal invalid request methods or treated as a breach attempt. I see that admin and appadmin are pretty much hard-coded into web2py, so I'm not sure if it would be worth the effort? -- --- 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: css help
In order to eliminate the issue under point 1, we could modify slightly the interested code in layout.html in: !-- Masthead == -- header class=mastheader row id=header div class=span12 div class=page-header h1{{if response.title is not None:}} {{=response.title}} small{{=response.subtitle or ''}}/small{{pass}} /h1 /div /div /header About point 2, in order to change the color of the links it's enough to set the following rules in web2py_bootstrap.css (preferibly on top of the file below the first rule): a{color: magenta;} a:visited{color: pink;} a:hover{color: red;} a:focus{color: brown;} a:active{color: darkmagenta;} Of course please change the color value at your taste. The same for the color of headers: h1{color: green;} h2{color: lightgreen;} h3{} h4{} h5{} h6{} Finally, for the image under menu there are several ways in order to obtain the same result. Replace the title with a big image: !-- Masthead == -- header class=mastheader row id=header div class=span12 div class=page-header {{response.title = XML('img src=%s alt=web2py image /' % (URL('static','images/big_image.jpg'))) # this is only for example}} {{response.subtitle = None # this is only for example}} h1{{if response.title is not None:}} {{=response.title}} small{{=response.subtitle or ''}}/small{{pass}} /h1 /div /div /header In this case the image will not be as wide as the page width. To obtain the right result we have to add a new element in layout.html and some css rules to web2py_bootstrap.css. Here attached the patched files. Please note that the code has not been deeply tested, so please let me know if you'll find bugs. Il giorno martedì 4 giugno 2013 16:20:21 UTC+2, Massimo Di Pierro ha scritto: I would like help with two css issues: 1) In layout.html if there is no response.title, the page content slides up and may disappear under the menu banner. Can we prevent this? 2) In web2py_bootstrap.css I would like to have example code to change the colors without changing the bootstrap.css (specifically color of links, headers, menu banner, and add a page wide image under the menu banner. These seems to be recurrent needs. -- --- 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. Title: {{=response.title or request.application}} {{=response.flash or ''}} {{=response.logo or ''}} {{='auth' in globals() and auth.navbar(mode="dropdown") or ''}} {{is_mobile=request.user_agent().is_mobile}} {{if response.menu:}} {{=MENU(response.menu, _class='mobile-menu nav' if is_mobile else 'nav',mobile=is_mobile,li_class='dropdown',ul_class='dropdown-menu')}} {{pass}} {{#response.title = XML('' % (URL('static','images/bootstrap_idea2.png'))) # this is only for example}} {{#response.subtitle = None # this is only for example}} {{if response.title is not None:}} {{=response.title}} {{=response.subtitle or ''}}{{pass}} {{if left_sidebar_enabled:}} {{block left_sidebar}} Left Sidebar {{end}} {{pass}} {{block center}} {{include}} {{end}} {{if right_sidebar_enabled:}} {{block right_sidebar}} Right Sidebar {{end}} {{pass}} {{block footer}} {{=T('Copyright')}} {{=request.now.year}} {{=T('Powered by')}} web2py {{end}} {{if response.google_analytics_id:}} {{pass}} /*= CUSTOM RULES ==*/ body{height:auto;} /* to avoid vertical scroll bar */ a{} a:visited{} a:hover{} a:focus{} a:active{} h1{} h2{} h3{} h4{} h5{} h6{} div.flash.flash-center{left:25%;right:25%;}
[web2py] Re: previous url
Thanks Niphlod,Anthony was written this way: def previous_url(): from collections import deque if session.previous_url is None: session.previous_url = deque([request.url, request.url], maxlen=2) if session.previous_url[1] != request.url: session.previous_url.append(request.url) return session.previous_url[0] -- --- 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: what is step to access to MSSQL
El martes, 4 de junio de 2013 18:01:13 UTC-3, Nam Soo In escribió: I am trying to access remote mssql My working env is ubuntu and mssql 2008 Do I need any additional installs? Thank you. connection: DAL - pyodbc - unixODBC - FreeTDS - SQLServer José -- --- 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] Custom reset-password email message, with username- Plain text, not html
Hey.. I want to customize the reset-password message, to in include the username, I get this error: cannot concatenate 'str' and 'Field' objects What am I missing? File: db.py auth.messages.reset_password = 'Hey ' + db.auth_user.username + ' click on the link http://'+request.env.http_host+URL('default','user',args=[ 'reset_password'])+'/%(key)s to reset your password' Thanks Rob -- --- 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: web2py 2.4.7 is Out
Let me know if you can isolate the reason for your memory leak. There are two known potential causes for leaks. 1) you use cache too much in ram without clearing the cache; 2) you create instances of objects with a __del__ method (this may create circular references which cannot be garbage collected). None of the web2py classes have a __del__ method but third party libraries may. On Tuesday, 4 June 2013 17:08:50 UTC-5, Aurelio Tinio wrote: Thanks for the prompt response Massimo. It doesn't look like we are using the TAG helper for our application but good to know nonetheless. Cheers. On Tuesday, June 4, 2013 2:42:09 PM UTC-7, Massimo Di Pierro wrote: The only memory leak I am aware of is when one use the TAG helper. It is fixed in trunk and will be foxed in 2.4.8 but it is not fixed in 2.4.6. I am not aware of other memory leaks. On Tuesday, 4 June 2013 16:22:10 UTC-5, Aurelio Tinio wrote: Hi Massimo, If you don't mind, could you elaborate on what these bugfixes are? We've just upgraded our system to use v2.4.6 and trying to assess if it's worth it to do the upgrade to v2.4.7 before our launch. Specifically, we've noticed a possible memory leak with our deployment and currently investigating if this might have been due to our upgrade to v2.4.6 and if so, if this bug has been fixed in the latest version. Thanks, Aurelio On Friday, May 24, 2013 10:56:11 AM UTC-7, Massimo Di Pierro wrote: I posted web2py 2.4.7. Includes mostly bug fixes. -- --- 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: css help
Thank you Paolo! On Tuesday, 4 June 2013 19:14:18 UTC-5, Paolo Caruccio wrote: In order to eliminate the issue under point 1, we could modify slightly the interested code in layout.html in: !-- Masthead == -- header class=mastheader row id=header div class=span12 div class=page-header h1{{if response.title is not None:}} {{=response.title}} small{{=response.subtitle or ''}}/small{{pass}} /h1 /div /div /header About point 2, in order to change the color of the links it's enough to set the following rules in web2py_bootstrap.css (preferibly on top of the file below the first rule): a{color: magenta;} a:visited{color: pink;} a:hover{color: red;} a:focus{color: brown;} a:active{color: darkmagenta;} Of course please change the color value at your taste. The same for the color of headers: h1{color: green;} h2{color: lightgreen;} h3{} h4{} h5{} h6{} Finally, for the image under menu there are several ways in order to obtain the same result. Replace the title with a big image: !-- Masthead == -- header class=mastheader row id=header div class=span12 div class=page-header {{response.title = XML('img src=%s alt=web2py image /' % (URL('static','images/big_image.jpg'))) # this is only for example}} {{response.subtitle = None # this is only for example}} h1{{if response.title is not None:}} {{=response.title}} small{{=response.subtitle or ''}}/small{{pass}} /h1 /div /div /header In this case the image will not be as wide as the page width. To obtain the right result we have to add a new element in layout.html and some css rules to web2py_bootstrap.css. Here attached the patched files. Please note that the code has not been deeply tested, so please let me know if you'll find bugs. Il giorno martedì 4 giugno 2013 16:20:21 UTC+2, Massimo Di Pierro ha scritto: I would like help with two css issues: 1) In layout.html if there is no response.title, the page content slides up and may disappear under the menu banner. Can we prevent this? 2) In web2py_bootstrap.css I would like to have example code to change the colors without changing the bootstrap.css (specifically color of links, headers, menu banner, and add a page wide image under the menu banner. These seems to be recurrent needs. -- --- 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: Custom reset-password email message, with username- Plain text, not html
replace auth.messages.reset_password = 'Hey ' + db.auth_user.username + ' click on the link ...' with auth.messages.reset_password = 'Hey %s click on the link ...' % db. auth_user.username On Tuesday, 4 June 2013 22:01:28 UTC-5, Rob_McC wrote: Hey.. I want to customize the reset-password message, to in include the username, I get this error: cannot concatenate 'str' and 'Field' objects What am I missing? File: db.py auth.messages.reset_password = 'Hey ' + db.auth_user.username + ' click on the link http://'+request.env.http_host+URL('default','user',args=[ 'reset_password'])+'/%(key)s to reset your password' Thanks Rob -- --- 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: Custom reset-password email message, with username- Plain text, not html
Or replace db.auth_user.username with db.auth_user.username.name On Tuesday, 4 June 2013 22:01:28 UTC-5, Rob_McC wrote: Hey.. I want to customize the reset-password message, to in include the username, I get this error: cannot concatenate 'str' and 'Field' objects What am I missing? File: db.py auth.messages.reset_password = 'Hey ' + db.auth_user.username + ' click on the link http://'+request.env.http_host+URL('default','user',args=[ 'reset_password'])+'/%(key)s to reset your password' Thanks Rob -- --- 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: [newbie] example authorization
You didn't update the action of the login form, so it's trying to post to the URL of the page it is on. Should be: auth.login().update(_action=URL('default', 'user', args='login'), ...) or whatever your login URL is. Anthony On Tuesday, June 4, 2013 6:33:28 PM UTC-4, lesssugar wrote: OK, I have this in my view: {{if not auth.user:}} {{auth.settings.login_next = URL('default', 'test')}} {{=auth.login().update(_name='global_login')}} a href=# id=pass_resetForgot password?/a {{else:}} a href={{=URL('default', 'user', args='logout')}} class=goldenLogout/a {{pass}} As you say, if login data are correct, user should be automatically logged in and [in this case] redirected to default/test. But when I put (just to test) im my default.py: @auth.requires_login() def test(): return dict(message='you are logged in') and then I try to log in with 100% correct data I am redirected to [appname]/# So no redirection is taking place, neither is logging in (checked it: auth.user is False after submitting the form). Any suggestions? I'm surely doing something wrong and it's supposed to be automatic and easy ;) On Tuesday, June 4, 2013 7:47:41 PM UTC+2, Anthony wrote: The auth.login() action automatically verifies the login and logs the user in (which involves adding the user record to the user's session) -- you don't have to do any of that explicitly. If you want to redirect to a specific URL after login, you can set auth.settings.login_next to the desired URL. Another option is to use auth.settings.login_onaccept, which is a function that takes the login form object (after it has been processed). Anthony On Tuesday, June 4, 2013 1:13:47 PM UTC-4, lesssugar wrote: In my layoyt.html I have the following code {{=auth.login().update(_action=URL('default', 'login'), _name= 'global_login')}} The login form takes user email and password. It generates correctly. Let's assume there are test users in db.auth_user. I would be grateful if someone provided a short example of further login implementation: 1. validate the login data (is email in db? is password correct?) 2. if data OK: redirect to a specific user profile -- --- 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: Checking if db query was successful
db(q1q2).select().first() will return None if no records are returned, so you should be able to do: if selected_record: [code to execute when a record is returned] If that's not working, let's see some more code. Anthony On Tuesday, June 4, 2013 7:43:27 PM UTC-4, Jordan Ladora wrote: Hi, If I set up a query like so, q1 = auth.accessible_query('read', db.stuff) q2 = db.stuff.id==3 selected_record = db(q1q2).select().first() # how to check if this successfully got db record? selected_records = db(q1q2).select()# how to check if this successfully got db records? ...I want to check if my select() or select().first() was successful and contains record(s) before executing more code. These are some ways I thought of doing it, but they have all created problems in one way or another. 1) if selected_record in locals(): # if query successful, returns FALSE 2) if selected_record: # code below still executes even if 'selected_record' does not exist 3) if len(selected_record): # throws row object has no len attribute error Thanks for help, -JL -- --- 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.