[web2py] When i JOIN something it goes ok, but if there is no join i got an error..
Hi all, Just starting with Web2py and i feel like a kid in a play garden. ;) Ok my problem, i am trying to make a simple JOIN but when i do that i have a problem with my views. My controlle looks like this: def read(): thispage = db.topics[request.args(0)] if not thispage: redirect(URL(r=request, f='read')) if auth.user_id: form = form = SQLFORM(db.replys) form.vars.topic_id = request.args(0) form.vars.user_id = auth.user_id if form.accepts(request.vars, session): response.flash = 'Topic created!' else: form = 'need to login to reply' db(db.topics.id==request.args(0)).select()[0] #topics = db(db.topics.id==request.args(0)).select(db.topics.id== db.replys.topic_id) #replys = db(db.replys.topic_id==request.args(0)).select(db.replys.ALL, orderby=~db.replys.posted) #query = (db.topics.id==db.replys.topic_id)&(db.topics.id == request.args(0)) rows= db(db.topics.id== request.args(0)).select(db.topics.title, db.topics.content, db.replys.content, left=db.topics.on(db.topics.id==db.replys.topic_id)) return dict(rows=rows,form=form) My view looks like this: {{extend 'layout.html'}} {{for row in rows:}} {{=row.topics.title}} {{=row.topics.content}} {{pass}} {{for row in rows:}} {{=row.replys.content}} {{pass}} {{=form}} When i have a few reply's then i have row.topics.titles and row.topics.content as the same amount as the row.replys.content. When i don't have a reply, then i don get the record back from topics. Now my question: How do i get one time the topics record back, and when there is none replys just the the record of the topic? What am i missing at this point? Thanks for the help. regards, Bart
[web2py] Re: Upload file using the LOAD (....., ajax = True)
Hi Anthony, This solution you mention is, with some minor changes, still working in the current version. I've managed to get the change working in the 2.12.3 version of web2py.js: Change function trap_form to: trap_form: function(action, target) { /* traps any LOADed form */ $('#' + target + ' form').each(function(i) { var form = $(this); if(form.hasClass('no_trap')) { return; } form.attr('data-w2p_target', target); var url = form.attr('action'); if((url === "") || (url === "#") || (typeof url === 'undefined')) { /* form has no action. Use component url. */ url = action; } /* begin change */ if(form.find('.upload').length>0) { form.ajaxForm({ url: url, success: function(data, statusText, xhr) { jQuery('#'+target).html(xhr.responseText); web2py.trap_form(action, target); web2py.ajax_init(); } }); } else { /* end change */ form.submit(function(e) { web2py.disableElement(form.find(web2py.formInputClickSelector)); web2py.hide_flash(); web2py.ajax_page('post', url, form.serialize(), target, form); e.preventDefault(); }); }; form.on('click', web2py.formInputClickSelector, function(e) { e.preventDefault(); var input_name = $(this).attr('name'); if(input_name != undefined) { $('').attr('name', input_name) .attr('value', $(this).val()).appendTo(form) } form.trigger('submit'); }); }); }, Regards, Bart Op dinsdag 7 augustus 2012 06:43:36 UTC+2 schreef Anthony: > > At the end of this section > <http://web2py.com/books/default/chapter/29/12#Components> in the book it > says: > > *Please note:* Because Ajax post does not support multipart forms, i.e. >> file uploads, upload fields will not work with the LOAD component. You >> could be fooled into thinking it would work because upload fields will >> function normally if POST is done from the individual component's .load >> view. Instead, uploads are done with ajax-compatible 3rd-party widgets and >> web2py manual upload store commands. > > > In the web2py cookbook > <http://www.packtpub.com/web2py-application-development-recipes-to-master-python-web-framework-cookbook/book>, > > there is a recipe for this. The app associated with that recipe can be > downloaded here: > https://github.com/mdipierro/web2py-recipes-source/blob/master/apps/04_advanced_forms/web2py.app.upload.w2p. > > It uses the jquery.form.js plugin: > http://jquery.malsup.com/form/#file-upload. The app includes a customized > web2py_ajax.js (which is named web2py.js in more recent versions of web2py) > with a custom version of web2py_trap_form(): > > function web2py_trap_form(action,target) { >jQuery('#'+target+' form').each(function(i){ > var form=jQuery(this); > if(!form.hasClass('no_trap')) >if(form.find('.upload').length>0) { > form.ajaxForm({ >url: action, >success: function(data, statusText, xhr) { > jQuery('#'+target).html(xhr.responseText); > web2py_trap_form(action,target); > web2py_ajax_init(); >} > }); >} else { > form.submit(function(e){ > jQuery('.flash').hide().html(''); > web2py_ajax_page('post',action,form.serialize(),target); > e.preventDefault(); > }); >} >}); > } > > Anthony > > On Monday, August 6, 2012 11:49:27 PM UTC-4, Picheth wrote: >> >> I have a problem with the upload file using the LOAD (., ajax = True) >> >> >> please .. any help, cues or snippets of codes to accomplish this ... will >> be greatly appreciated >> >> Picheth. >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] error starting scheduler: error retreiving status
I am trying to start web2py scheduler with python web2py.py -K myapp on a Ubuntu 16.04 server with web2py 2.14.6-stable+timestamp.2016.05.10.00.21.47 (running on nginx/1.10.0, Python 2.7.11+) db connector is psycopg2 myapp is using a remote postgres database over ssl In the app every is working fine, the database connection string is ok. When starting the scheduler in debug mode, i get: $ python web2py.py -K skarp -D 0 web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2016 Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Database drivers available: sqlite3, psycopg2, pg8000, pymysql, imaplib starting single-scheduler for "skarp"... DEBUG:web2py.scheduler.web02#51073:defining tables (migrate=True) DEBUG:web2py.scheduler.web02#51073:thread building own DAL object DEBUG:web2py.scheduler.web02#51073:looping... INFO:web2py.scheduler.web02#51073:nothing to do DEBUG:web2py.scheduler.web02#51073:sleeping... DEBUG:web2py.scheduler.web02#51073:defining tables (migrate=False) ERROR:web2py.scheduler.web02#51073:Error retrieving status DEBUG:web2py.scheduler.web02#51073:looping... INFO:web2py.scheduler.web02#51073:nothing to do DEBUG:web2py.scheduler.web02#51073:sleeping... ERROR:web2py.scheduler.web02#51073:Error retrieving status etc.etc. setiing migrate to False or True makes no difference. Has anyone a clue what is going wrong? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: error starting scheduler: error retreiving status
Addition: I am using several schema's in the postgres database. The scheduler tables are in schema 'scheduler' Schema 'public' does not exist. Can this cause the problem? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: error starting scheduler: error retreiving status
Hi Niphlod, Normally i just put a record in the scheduler_task table with appadmin. That works fine (no errors), but nothing happens because the scheduler worker is not running. In db.py the database schema is set via db.executesql("set search_path to auth,scheduler, ... ;") In case migrate is True, the search_path is set to scheduler, auth, ... just before the scheduler = Scheduler(db) statement. Op vrijdag 3 juni 2016 18:35:07 UTC+2 schreef Niphlod: > > what happens when you try to queue a task from the app ? AFAIK I'd be > eager to know how can it work if there is no "public" schema, unless you > tinkered with scheduler's table definitions > > On Friday, June 3, 2016 at 4:57:23 PM UTC+2, Bart wrote: >> >> Addition: >> >> I am using several schema's in the postgres database. >> >> The scheduler tables are in schema 'scheduler' >> >> Schema 'public' does not exist. >> >> Can this cause the problem? >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: error starting scheduler: error retreiving status
Thanks Niphlod, It works! I added self.db_thread.executesql("set search_path to scheduler, auth, ... ;") in gluon/scheduler.py after the self.db_thread = DAL( line and before the self.define_tables( ... line I am aware of the fact that it is not supported, but the database uses a strict schema policy so i don't have a choice really. I am wondering how worker startup works when the python web2py.py -K myapp statement is executed. How does the scheduler get the database uri, if the models aren't executed at scheduler worker startup? Does scheduler only search for de db - DAL(... statement, omitting the other code? Op vrijdag 3 juni 2016 20:24:01 UTC+2 schreef Niphlod: > > the scheduler though doesn't know anything about the search path when it > rebuilds its own model... that's why setting search_path is undocumented ^_^ > > you can try fiddling with the source of the scheduler (along these lines > https://github.com/web2py/web2py/blob/master/gluon/scheduler.py#L948) to > set the same search path. > > Please be aware that even if it seems to work, support for it is not > assured (so use at your own risk) > > On Friday, June 3, 2016 at 7:19:02 PM UTC+2, Bart wrote: >> >> Hi Niphlod, >> >> Normally i just put a record in the scheduler_task table with appadmin. >> That works fine (no errors), but nothing happens because the scheduler >> worker is not running. >> >> In db.py the database schema is set via db.executesql("set search_path >> to auth,scheduler, ... ;") >> >> In case migrate is True, the search_path is set to scheduler, auth, ... >> just before the scheduler = Scheduler(db) statement. >> >> >> >> Op vrijdag 3 juni 2016 18:35:07 UTC+2 schreef Niphlod: >>> >>> what happens when you try to queue a task from the app ? AFAIK I'd be >>> eager to know how can it work if there is no "public" schema, unless you >>> tinkered with scheduler's table definitions >>> >>> On Friday, June 3, 2016 at 4:57:23 PM UTC+2, Bart wrote: >>>> >>>> Addition: >>>> >>>> I am using several schema's in the postgres database. >>>> >>>> The scheduler tables are in schema 'scheduler' >>>> >>>> Schema 'public' does not exist. >>>> >>>> Can this cause the problem? >>>> >>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Scheduler error using python3.6 and psycopg2
For a new application, i have installed web2py 2.16.1 under python 3.6 and using psycopg2 2.7.4 for postgresql access. Everything is working okay, except the web2py scheduler. After successfull execution of the first task, the scheduler gives an error in the send_heartbeat function. The task output is correctly stored in the database, with status COMPLETED. The transaction is committed. But then in the first heartbeat after completion, the error below is thrown: Looks like the database connection is lost unexpected. The strange thing is that this is only happening with psycopg2. When the PG8000 connector is used, everything is working fine. I have tested this on my development system (MacBook) On my production system under Ubuntu 16.04, the same thing is happening. Does anyone have a clue? The error: ERROR:web2py.scheduler.MyMac.local#21060:Error retrieving status Exception in thread Thread-30: Traceback (most recent call last): File "/Users/me/PycharmProjects/myapp/web2py/gluon/scheduler.py", line 1168, in send_heartbeat mybackedstatus = db(sw.worker_name == self.worker_name).select().first() File "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/objects.py", line 2250, in select return adapter.select(self.query, fields, attributes) File "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", line 762, in select return self._select_aux(sql, fields, attributes, colnames) File "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", line 718, in _select_aux rows = self._select_aux_execute(sql) File "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", line 712, in _select_aux_execute self.execute(sql) File "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/__init__.py", line 67, in wrap return f(*args, **kwargs) File "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", line 412, in execute rv = self.cursor.execute(command, *args[1:], **kwargs) psycopg2.OperationalError: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/Users/me/PycharmProjects/myapp/web2py/gluon/scheduler.py", line 637, in run self.send_heartbeat(counter) File "/Users/me/PycharmProjects/myapp/web2py/gluon/scheduler.py", line 1239, in send_heartbeat db.rollback() File "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/base.py", line 704, in rollback self._adapter.rollback() File "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/__init__.py", line 56, in wrap return f(*args, **kwargs) File "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", line 865, in rollback return self.connection.rollback() psycopg2.InterfaceError: connection already closed -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Scheduler error using python3.6 and psycopg2
I have found a workaround for this issue. The root cause is probably something in the pyDal connector or psycopg2 or threading. I leave the finding of that to the experts. The workaround is to add code to gluon/scheduler.py to test the connection before the rest of the Scheduler.send_heartbeat() function is executed. If the connection-test fails, a new one is set up: Insert this code at the top of the Scheduler.send_heartbeat() function if self.db_thread: # BKR 20180612 check if connection still works, if not -> throw away self.db_thread and force reconnect try: x = self.db_thread(self.db_thread.scheduler_worker.worker_name == self.worker_name).select() except self.db_thread._adapter.connection.OperationalError: self.db_thread = None With this addition, the scheduler works okay. Op woensdag 6 juni 2018 21:26:40 UTC+2 schreef Bart: > > For a new application, i have installed web2py 2.16.1 under python 3.6 and > using psycopg2 2.7.4 for postgresql access. > > Everything is working okay, except the web2py scheduler. > > After successfull execution of the first task, the scheduler gives an > error in the send_heartbeat function. > The task output is correctly stored in the database, with status > COMPLETED. The transaction is committed. > > But then in the first heartbeat after completion, the error below is > thrown: > > Looks like the database connection is lost unexpected. > > The strange thing is that this is only happening with psycopg2. When the > PG8000 connector is used, everything is working fine. > I have tested this on my development system (MacBook) > > On my production system under Ubuntu 16.04, the same thing is happening. > > Does anyone have a clue? > > The error: > > ERROR:web2py.scheduler.MyMac.local#21060:Error retrieving status > Exception in thread Thread-30: > Traceback (most recent call last): > File "/Users/me/PycharmProjects/myapp/web2py/gluon/scheduler.py", line > 1168, in send_heartbeat > mybackedstatus = db(sw.worker_name == > self.worker_name).select().first() > File > "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/objects.py", > > line 2250, in select > return adapter.select(self.query, fields, attributes) > File > "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", > > line 762, in select > return self._select_aux(sql, fields, attributes, colnames) > File > "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", > > line 718, in _select_aux > rows = self._select_aux_execute(sql) > File > "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", > > line 712, in _select_aux_execute > self.execute(sql) > File > "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/__init__.py", > > line 67, in wrap > return f(*args, **kwargs) > File > "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", > > line 412, in execute > rv = self.cursor.execute(command, *args[1:], **kwargs) > psycopg2.OperationalError: server closed the connection unexpectedly > This probably means the server terminated abnormally > before or while processing the request. > > > During handling of the above exception, another exception occurred: > > Traceback (most recent call last): > File > "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", > > line 916, in _bootstrap_inner > self.run() > File "/Users/me/PycharmProjects/myapp/web2py/gluon/scheduler.py", line > 637, in run > self.send_heartbeat(counter) > File "/Users/me/PycharmProjects/myapp/web2py/gluon/scheduler.py", line > 1239, in send_heartbeat > db.rollback() > File > "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/base.py", > > line 704, in rollback > self._adapter.rollback() > File > "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/__init__.py", > > line 56, in wrap > return f(*args, **kwargs) > File > "/Users/me/PycharmProjects/myapp/venv/lib/python3.6/site-packages/pydal/adapters/base.py", > > line 865, in rollback > return self.connection.rollback() > psycopg2.InterfaceError: connection already closed > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] web2py RESTful timeout
I have a python script that posts data to my web2py/application/projects database using RESTful services. Everything works fine for an hour or two, but then all future posts will timeout. If, using a web browser, I reload the web2py application's main page then the RESTful services start working again for another hour or two. Any ideas why I cant run a script 24/7 to GET/POST data to my web2py application's RESTful services? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: web2py RESTful timeout
My python script is getting a stock price from google finance and then posting (using RESTful api) to my web2py application every 15 minutes. When I look at the log files everything works for awhile, but after a couple hours every POST will timeout. If I load the application's default/index page from a web browser then the RESTful POST works for another hour or two and then it times out again. I've run the web2py server on pythonanywhere and on a local computer with the same results. r = requests.post(url, headers=headers, data=json.dumps(payload), timeout=360) def POST(table_name,**vars): if table_name == 'VEXMX': row = db(db.VEXMX.date==vars['date']).select().first() if row: result = {'exists':1, 'id':row.id, 'errors': {}} result = dict(result=result) else: result = dict(db.VEXMX.validate_and_insert(**vars)) result['exists'] = 0 result = dict(result=result) return result On Friday, November 21, 2014 3:55:31 PM UTC-7, Massimo Di Pierro wrote: > > We need more details. How often do you post? How long does it take to get > a response? > > On Friday, 21 November 2014 09:36:36 UTC-6, Bart wrote: >> >> I have a python script that posts data to my web2py/application/projects >> database using RESTful services. Everything works fine for an hour or two, >> but then all future posts will timeout. If, using a web browser, I reload >> the web2py application's main page then the RESTful services start working >> again for another hour or two. Any ideas why I cant run a script 24/7 to >> GET/POST data to my web2py application's RESTful services? >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: web2py RESTful timeout
Thanks I'm testing this now. I'll let you know if it works. On Monday, November 24, 2014 10:04:56 AM UTC-7, Derek wrote: > > If you don't need sessions for those requests, you should disable sessions > first and see if that works better. Sessions kills concurrency. > > On Friday, November 21, 2014 8:36:36 AM UTC-7, Bart wrote: >> >> I have a python script that posts data to my web2py/application/projects >> database using RESTful services. Everything works fine for an hour or two, >> but then all future posts will timeout. If, using a web browser, I reload >> the web2py application's main page then the RESTful services start working >> again for another hour or two. Any ideas why I cant run a script 24/7 to >> GET/POST data to my web2py application's RESTful services? >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: web2py RESTful timeout
I'm using MySQL, but I've also used SQLite. Yes I've verified that the POST is timing out. I ran another test and the script ran for 2 days until the error showed up again. I reloaded the default/index webpage in my browser and now its working again. I'll try disabling sessions as Derek suggests. Thanks. On Monday, November 24, 2014 12:15:23 PM UTC-7, Leonel Câmara wrote: > Are you sure it's the POSTs to web2py that are timing out and not the > fetching of the stock quotes? > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: web2py RESTful timeout
This didn't fix my problem. It worked for several days, but now I cant communicate to my server using RESTful services. I'm sure if I load the website from a browser it will start working again. This is very frustrating! It sure seems like the RESTful service goes into some type of sleep mode. On Wednesday, November 26, 2014 9:55:47 PM UTC-7, Bart wrote: > > Thanks I'm testing this now. I'll let you know if it works. > > On Monday, November 24, 2014 10:04:56 AM UTC-7, Derek wrote: >> >> If you don't need sessions for those requests, you should disable >> sessions first and see if that works better. Sessions kills concurrency. >> >> On Friday, November 21, 2014 8:36:36 AM UTC-7, Bart wrote: >>> >>> I have a python script that posts data to my web2py/application/projects >>> database using RESTful services. Everything works fine for an hour or two, >>> but then all future posts will timeout. If, using a web browser, I reload >>> the web2py application's main page then the RESTful services start working >>> again for another hour or two. Any ideas why I cant run a script 24/7 to >>> GET/POST data to my web2py application's RESTful services? >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: web2py RESTful timeout
Adding exception handling inside my RESTful api fixed my problem. Sometimes my RESTful posts contained corrupted data and this would cause an exception and hang future posts. Adding try/except solved my issue. Thanks, Bart On Friday, November 21, 2014 8:36:36 AM UTC-7, Bart wrote: > > I have a python script that posts data to my web2py/application/projects > database using RESTful services. Everything works fine for an hour or two, > but then all future posts will timeout. If, using a web browser, I reload > the web2py application's main page then the RESTful services start working > again for another hour or two. Any ideas why I cant run a script 24/7 to > GET/POST data to my web2py application's RESTful services? > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Web2py sessions table does not exist?
Recently after some updates to some of my models, I got this error in web2py. Traceback (most recent call last): File "/Users/acbart/web2py/gluon/main.py", line 457, in wsgibase session._try_store_in_db(request, response) File "/Users/acbart/web2py/gluon/globals.py", line 1116, in _try_store_in_db record_id = table.insert(**dd) File "/Users/acbart/web2py/gluon/dal.py", line 9114, in insert ret = self._db._adapter.insert(self, self._listify(fields)) File "/Users/acbart/web2py/gluon/dal.py", line 1360, in insert raise eProgrammingError: (1146, u"Table 'runestone_dev.web2py_session_runestone' doesn't exist") My web2py application is named runestone, and the database is named runestone_dev. I've checked the MySQL database and the table doesn't exist. But it is my understanding that this is a table that should be automatically generated for me. Anyone know what gives? It doesn't appear to be a problem with my code... -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Web2py sessions table does not exist?
Migrations should be on. I have it enabled through my DAL: db = DAL(settings.database_uri, migrate_enabled=True) And through each individual table: db.define_table('courses', ... migrate='runestone_courses.table') I've emptied the entire databases/ folder of all the .table files. This seems to have made the situation worst, since now I can't read error tickets - clicking the link opens a new ticket. I've tried getting into my application's errors/ files, and I see that this line is still in there: Table \'runestone_dev.web2py_session_runestone\' doesn\'t exist The latest error in the admin application's errors/ folder has this line: can't pickle function objects ~Cory On Thursday, July 3, 2014 4:37:22 AM UTC-4, Niphlod wrote: > > did you turn migrations on ? > if yes, please check that there isn't a *web2py_session_runestone*.table > file into the database/ folder. If there is, delete it and web2py will > recreate it. > > On Thursday, July 3, 2014 1:44:38 AM UTC+2, Austin Bart wrote: >> >> Recently after some updates to some of my models, I got this error in >> web2py. >> >> Traceback (most recent call last): >> File "/Users/acbart/web2py/gluon/main.py", line 457, in wsgibase >> session._try_store_in_db(request, response) >> File "/Users/acbart/web2py/gluon/globals.py", line 1116, in >> _try_store_in_db >> record_id = table.insert(**dd) >> File "/Users/acbart/web2py/gluon/dal.py", line 9114, in insert >> ret = self._db._adapter.insert(self, self._listify(fields)) >> File "/Users/acbart/web2py/gluon/dal.py", line 1360, in insert >> raise eProgrammingError: (1146, u"Table >> 'runestone_dev.web2py_session_runestone' doesn't exist") >> >> My web2py application is named runestone, and the database is named >> runestone_dev. I've checked the MySQL database and the table doesn't >> exist. But it is my understanding that this is a table that should be >> automatically generated for me. Anyone know what gives? It doesn't appear >> to be a problem with my code... >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Web2py sessions table does not exist?
Ah, apologies. I was a little over-enthusiastic with my deletions. So I did fake_migrate_all=True, let web2py create the tables, and then turned off fake_migrations. However, web2py did not create a web2py_session_runestone table file. All the other tables are there, just no web2py_session_runestone.table. The sql.log file doesn't refer to it at all. ~Cory On Thursday, July 3, 2014 11:06:59 AM UTC-4, Niphlod wrote: > > who said "delete everything" ? :P > > now, do a fake_migrate_all=True, let web2py recreate table files, then > turn off fake_migrations, then delete ONLY webp2y_session_runestone and > retry. > > Simone > > On Thursday, July 3, 2014 11:30:35 AM UTC+2, Austin Bart wrote: >> >> Migrations should be on. I have it enabled through my DAL: >> db = DAL(settings.database_uri, migrate_enabled=True) >> And through each individual table: >> db.define_table('courses', ... migrate='runestone_courses.table') >> I've emptied the entire databases/ folder of all the .table files. >> >> This seems to have made the situation worst, since now I can't read error >> tickets - clicking the link opens a new ticket. I've tried getting into my >> application's errors/ files, and I see that this line is still in there: >> Table \'runestone_dev.web2py_session_runestone\' doesn\'t exist >> The latest error in the admin application's errors/ folder has this line: >> can't pickle function objects >> >> ~Cory >> >> On Thursday, July 3, 2014 4:37:22 AM UTC-4, Niphlod wrote: >>> >>> did you turn migrations on ? >>> if yes, please check that there isn't a *web2py_session_runestone*.table >>> file into the database/ folder. If there is, delete it and web2py will >>> recreate it. >>> >>> On Thursday, July 3, 2014 1:44:38 AM UTC+2, Austin Bart wrote: >>>> >>>> Recently after some updates to some of my models, I got this error in >>>> web2py. >>>> >>>> Traceback (most recent call last): >>>> File "/Users/acbart/web2py/gluon/main.py", line 457, in wsgibase >>>> session._try_store_in_db(request, response) >>>> File "/Users/acbart/web2py/gluon/globals.py", line 1116, in >>>> _try_store_in_db >>>> record_id = table.insert(**dd) >>>> File "/Users/acbart/web2py/gluon/dal.py", line 9114, in insert >>>> ret = self._db._adapter.insert(self, self._listify(fields)) >>>> File "/Users/acbart/web2py/gluon/dal.py", line 1360, in insert >>>> raise eProgrammingError: (1146, u"Table >>>> 'runestone_dev.web2py_session_runestone' doesn't exist") >>>> >>>> My web2py application is named runestone, and the database is named >>>> runestone_dev. I've checked the MySQL database and the table doesn't >>>> exist. But it is my understanding that this is a table that should be >>>> automatically generated for me. Anyone know what gives? It doesn't appear >>>> to be a problem with my code... >>>> >>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: When i JOIN something it goes ok, but if there is no join i got an error..
Hi villas, Thnx for your reply. I am only playing for a couple of day's with web2py and python. I have more experience in php. ;) As what i see now is that the JOIN is not correct i think.. going to give it another try. speak to you later. regards Bart On 8 feb, 19:00, villas wrote: > Hi Bart > > I'd take a look at whether you are producing the correct SQL. Try > placing an underscore in front of your select to expose in the > commandline console whether the SQL is what you want. See the > underscore here: > > print db(db.topics.id== request.args(0))._select(db.topics.title, > db.topics.content,db.replys.content,left=db.topics.on(db.topics.id==db.replys.topic_id)) > > You can then play around with the query until you get it right. Sorry > I'm not answering your question directly but it's often better to show > a man how to fish :-) > > -D > > On Feb 8, 8:55 am, Bart wrote: > > > Hi all, > > > Just starting with Web2py and i feel like a kid in a play garden. ;) > > > Ok my problem, i am trying to make a simple JOIN but when i do that i > > have a problem with my views. > > My controlle looks like this: > > > def read(): > > > thispage = db.topics[request.args(0)] > > > if not thispage: > > redirect(URL(r=request, f='read')) > > > if auth.user_id: > > form = form = SQLFORM(db.replys) > > form.vars.topic_id = request.args(0) > > form.vars.user_id = auth.user_id > > if form.accepts(request.vars, session): > > response.flash = 'Topic created!' > > else: > > form = 'need to login to reply' > > > db(db.topics.id==request.args(0)).select()[0] > > #topics = db(db.topics.id==request.args(0)).select(db.topics.id== > > db.replys.topic_id) > > #replys = > > db(db.replys.topic_id==request.args(0)).select(db.replys.ALL, > > orderby=~db.replys.posted) > > #query = (db.topics.id==db.replys.topic_id)&(db.topics.id == > > request.args(0)) > > rows= db(db.topics.id== request.args(0)).select(db.topics.title, > > db.topics.content, > > db.replys.content, > > left=db.topics.on(db.topics.id==db.replys.topic_id)) > > > return dict(rows=rows,form=form) > > > My view looks like this: > > > {{extend 'layout.html'}} > > > {{for row in rows:}} > > {{=row.topics.title}} > > {{=row.topics.content}} > > {{pass}} > > > {{for row in rows:}} > > > > {{=row.replys.content}} > > {{pass}} > > > {{=form}} > > When i have a few reply's then i have row.topics.titles and > > row.topics.content as the same amount as the row.replys.content. > > When i don't have a reply, then i don get the record back from topics. > > > Now my question: How do i get one time the topics record back, and > > when there is none replys just the the record of the topic? > > > What am i missing at this point? > > > Thanks for the help. > > regards, Bart > >
[web2py] Re: Field set the default value +1 on insert
Hello my friends, Thanks for the inspiration. The answer from Craig, looks to me a good idea how i can do it. many thanks, Bart -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Field set the default value +1 on insert
Hello web2py freaks, In my first try to make an application with web2py i have a little struggle how to accomplish as what is would like to see. In db1.py i created a field like this: db.define_table('jobticket', Field('ticket', 'integer', default = +1) # ticket needs to be ticket +1 when inserted ) I need to have something called "ticket" what represent a number where my other tables are linked to. I know that the default id is auto increment, and i can reference it, so that's not the point. The ticket is a number what i needs to be set like : 15001. And that needs to be inserted +1 if there is a new job. 15 is a year, the rest is just a number. So, i have 2 problems: - if there is a new year like 1 january 2016, the first two numbers needs to be changed from 15 to 16? - And how can i get the max number out of the database and insert that with a new value( +1) Does anybody have a good insperation or an good idea to get me on the right track? Many thanks. Bart -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Routes problem?
Dit you also press the button reload routes after the change? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.