[web2py] Sending an email on CRUD complete...
I am reading in the book: crud.settings.create_onvalidation = StorageList() But I just don't get it. I wanted to send an email when the form submits successfully, and I have created a method for that. send_email(to_email, subject, message) How would I do this? BR, Jason Brower
[web2py] GAE error (INSERT INTO auth_event fails)
Hello, I'm receiving this error when trying to log in to my application: ValueError: INSERT INTO auth_event(origin,user_id,description,time_stamp,client_ip) VALUES ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb', '2012-07-12 06:20:04','95.190.89.149'); has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. Can you help me understand what's going on here? What's the description that is being inserted? Here's the whole traceback: 1. /user/login?_next=/ui 500 7153ms 0kb Mozilla/5.0 (Windows NT 6.2; rv:13.0) Gecko/20100101 Firefox/13.0.1 95.190.89.149 - - [11/Jul/2012:23:20:11 -0700] POST /user/login?_next=/ui HTTP/1.1 500 245 http://www.vocabilis-net.appspot.com/user/login?_next=/ui; Mozilla/5.0 (Windows NT 6.2; rv:13.0) Gecko/20100101 Firefox/13.0.1 www.vocabilis-net.appspot.com ms=7153 cpu_ms=2438 api_cpu_ms=0 cpm_usd=0.067897 instance=00c61b117ca46127ca9599783f07c494292f2e https://appengine.google.com/instances?app_id=s%7Evocabilis-netversion_id=1.360260160184278425key=00c61b117ca46127ca9599783f07c494292f2e#00c61b117ca46127ca9599783f07c494292f2e 2. D 2012-07-11 23:20:04.807 select application=vocabilis 3. D 2012-07-11 23:20:04.808 route: controller=default 4. D 2012-07-11 23:20:04.808 route: function.ext=user.html 5. E 2012-07-11 23:20:11.821 Traceback (most recent call last): File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/restricted.py, line 205, in restricted exec ccode in environment File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py, line 131, in module File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py, line 49, in user return dict(form=auth()) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py, line 1161, in __call__ return getattr(self,args[0])() File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py, line 1814, in login self.log_event(log, user) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py, line 1461, in log_event origin=origin, user_id=user_id) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py, line 6829, in insert return self._db._adapter.insert(self,self._listify(fields)) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py, line 928, in insert raise e ValueError: INSERT INTO auth_event(origin,user_id,description,time_stamp,client_ip) VALUES ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb','2012-07-12 06:20:04','95.190.89.149'); has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. 6. I 2012-07-11 23:20:11.862 Saved; key: __appstats__:004800, part: 134 bytes, full: 52828 bytes, overhead: 0.003 + 0.014; link: http://www.vocabilis-net.appspot.com/_ah/stats/details?time=1342074004806 -- Alexei Vinidiktov
[web2py] Re: GAE error (INSERT INTO auth_event fails)
Sorry, forgot to mention that I'm using Python 2.7 and web2py 1.99.7 on GAE . On Thu, Jul 12, 2012 at 1:41 PM, Alexei Vinidiktov alexei.vinidik...@gmail.com wrote: Hello, I'm receiving this error when trying to log in to my application: ValueError: INSERT INTO auth_event(origin,user_id,description,time_stamp,client_ip) VALUES ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb', '2012-07-12 06:20:04','95.190.89.149'); has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. Can you help me understand what's going on here? What's the description that is being inserted? Here's the whole traceback: 1. /user/login?_next=/ui 500 7153ms 0kb Mozilla/5.0 (Windows NT 6.2; rv:13.0) Gecko/20100101 Firefox/13.0.1 95.190.89.149 - - [11/Jul/2012:23:20:11 -0700] POST /user/login?_next=/ui HTTP/1.1 500 245 http://www.vocabilis-net.appspot.com/user/login?_next=/ui; Mozilla/5.0 (Windows NT 6.2; rv:13.0) Gecko/20100101 Firefox/13.0.1 www.vocabilis-net.appspot.com ms=7153 cpu_ms=2438 api_cpu_ms=0 cpm_usd=0.067897 instance=00c61b117ca46127ca9599783f07c494292f2e https://appengine.google.com/instances?app_id=s%7Evocabilis-netversion_id=1.360260160184278425key=00c61b117ca46127ca9599783f07c494292f2e#00c61b117ca46127ca9599783f07c494292f2e 2. D 2012-07-11 23:20:04.807 select application=vocabilis 3. D 2012-07-11 23:20:04.808 route: controller=default 4. D 2012-07-11 23:20:04.808 route: function.ext=user.html 5. E 2012-07-11 23:20:11.821 Traceback (most recent call last): File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/restricted.py, line 205, in restricted exec ccode in environment File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py, line 131, in module File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py, line 49, in user return dict(form=auth()) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py, line 1161, in __call__ return getattr(self,args[0])() File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py, line 1814, in login self.log_event(log, user) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py, line 1461, in log_event origin=origin, user_id=user_id) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py, line 6829, in insert return self._db._adapter.insert(self,self._listify(fields)) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py, line 928, in insert raise e ValueError: INSERT INTO auth_event(origin,user_id,description,time_stamp,client_ip) VALUES ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb','2012-07-12 06:20:04','95.190.89.149'); has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. 6. I 2012-07-11 23:20:11.862 Saved; key: __appstats__:004800, part: 134 bytes, full: 52828 bytes, overhead: 0.003 + 0.014; link: http://www.vocabilis-net.appspot.com/_ah/stats/details?time=1342074004806 -- Alexei Vinidiktov -- Alexei Vinidiktov
[web2py] Re: GAE error (INSERT INTO auth_event fails)
I now have some additional information. This error only occurs when using Firefox (I have version 13.0.1 on Windows) with Russian set as the preferred language in Firefox settings (I've also tested with English as preferred language and did't get this error). It doesn't occur when using any other browsers that I've tested (Chrome, Internet Explorer, Opera). On Thu, Jul 12, 2012 at 1:57 PM, Alexei Vinidiktov alexei.vinidik...@gmail.com wrote: Sorry, forgot to mention that I'm using Python 2.7 and web2py 1.99.7 on GAE . On Thu, Jul 12, 2012 at 1:41 PM, Alexei Vinidiktov alexei.vinidik...@gmail.com wrote: Hello, I'm receiving this error when trying to log in to my application: ValueError: INSERT INTO auth_event(origin,user_id,description,time_stamp,client_ip) VALUES ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb', '2012-07-12 06:20:04','95.190.89.149'); has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. Can you help me understand what's going on here? What's the description that is being inserted? [...] -- Alexei Vinidiktov
[web2py] Submitting Non-ASCII characters in GAE fails (was GAE error (INSERT INTO auth_event fails))
As it turns out submitting any Non-ASCII characters in any form from any browser (for example changing a user's name to contain Cyrillic characters) results in the same error on GAE with MySQL (haven't tried with data store). Any sql statement containing Non-ASCII characters returns the same error message: has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. This error seems to proceed from the Google Python protobuf library. http://code.google.com/p/protobuf/source/browse/trunk/python/google/protobuf/pyext/python-proto2.cc?r=395 Haven't found the same error message anywhere else. On Thu, Jul 12, 2012 at 2:57 PM, Alexei Vinidiktov alexei.vinidik...@gmail.com wrote: I now have some additional information. This error only occurs when using Firefox (I have version 13.0.1 on Windows) with Russian set as the preferred language in Firefox settings (I've also tested with English as preferred language and did't get this error). It doesn't occur when using any other browsers that I've tested (Chrome, Internet Explorer, Opera). On Thu, Jul 12, 2012 at 1:57 PM, Alexei Vinidiktov alexei.vinidik...@gmail.com wrote: Sorry, forgot to mention that I'm using Python 2.7 and web2py 1.99.7 on GAE . On Thu, Jul 12, 2012 at 1:41 PM, Alexei Vinidiktov alexei.vinidik...@gmail.com wrote: Hello, I'm receiving this error when trying to log in to my application: ValueError: INSERT INTO auth_event(origin,user_id,description,time_stamp,client_ip) VALUES ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb', '2012-07-12 06:20:04','95.190.89.149'); has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. Can you help me understand what's going on here? What's the description that is being inserted? [...] -- Alexei Vinidiktov -- Alexei Vinidiktov
Re: [web2py] Getting drop-down value names from grandparent record
I am glad you solved it! Enjoy your day. Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: A database design dillema
I plan to have homeworks also, which would have different data model than content course. I would like to put everything in the same timeline, whether is a course content (text, video) or course homework (questionnaires, uploads etc.). Let say steps 1-5 are course contents and than step 6 is homework, than steps 7-12 are contents, step 13 homework etc. On Thursday, 12 July 2012 04:59:18 UTC+2, pbreit wrote: I don't see any reason to have more than one table course at this point. Just add a course_type=video|text (I don't think you can name a field type).
[web2py] Re: A database design dillema
If you don't want to use a union query, how about using separate queries and adding the rows together? On Thursday, July 12, 2012 10:13:57 AM UTC+1, Najtsirk wrote: I plan to have homeworks also, which would have different data model than content course. I would like to put everything in the same timeline, whether is a course content (text, video) or course homework (questionnaires, uploads etc.). Let say steps 1-5 are course contents and than step 6 is homework, than steps 7-12 are contents, step 13 homework etc. On Thursday, 12 July 2012 04:59:18 UTC+2, pbreit wrote: I don't see any reason to have more than one table course at this point. Just add a course_type=video|text (I don't think you can name a field type).
[web2py] Re: A database design dillema
I was trying to do that, but i just can't figure out how to put rows from separate queries together. On Thursday, 12 July 2012 12:18:12 UTC+2, villas wrote: If you don't want to use a union query, how about using separate queries and adding the rows together? On Thursday, July 12, 2012 10:13:57 AM UTC+1, Najtsirk wrote: I plan to have homeworks also, which would have different data model than content course. I would like to put everything in the same timeline, whether is a course content (text, video) or course homework (questionnaires, uploads etc.). Let say steps 1-5 are course contents and than step 6 is homework, than steps 7-12 are contents, step 13 homework etc. On Thursday, 12 July 2012 04:59:18 UTC+2, pbreit wrote: I don't see any reason to have more than one table course at this point. Just add a course_type=video|text (I don't think you can name a field type).
[web2py] Re: A database design dillema
Try something like this: r1 = db(db.auth_user.id==1).select() r2 = db(db.auth_user.id==2).select() rows_all = r1 r2 print len(rows_all) 2 Regards, David
[web2py] Re: A database design dillema
I forgot that you need to add different tables, try something like this instead... a=db.auth_user.with_alias('a') r1 = db(a.id==1).select(a.id) a=db.auth_group.with_alias('a') r2 = db(a.id==1).select(a.id) rows_all = r1 r2
Re: [web2py] Re: Website/Sqlite Backup
Regarding use with Apache wsgi and Sqlite. Does anyone know whether it is safe to copy a Sqlite DB file after Apache has been stopped. I mean, would stopping Apache leave the DB file in a good state for copying?
[web2py] Re: A database design dillema
I did manage to do this on my own. But the problem is ordering. I cannot get the records in the right order. I did manage to get the rows like: Table 1 - Record 1 Table 1 - Record 2 Table 1 - Record 3 Table 2 - Record 1 Table 2 - Record 2 Table 2 - Record 3 But how can i get output orderd by weight (which is a integer field in both tables), like: Table 1 - Record 2 - Weight 1 Table 2 - Record 3 - Weight 2 Table 2 - Record 1 - Weight 3 Table 1 - Record 3 - Weight 4 Table 2 - Record 2 - Weight 5 Table 1 - Record 1 - Weight 6 On Thursday, 12 July 2012 13:31:49 UTC+2, villas wrote: I forgot that you need to add different tables, try something like this instead... a=db.auth_user.with_alias('a') r1 = db(a.id==1).select(a.id) a=db.auth_group.with_alias('a') r2 = db(a.id==1).select(a.id) rows_all = r1 r2
Re: [web2py] Re: A database design dillema
I read that you can replace most of the time UNION with subquery for better performance. I can try to write the sql request, but to make sure I would need DDL and a reduced set of data. Richard On Thu, Jul 12, 2012 at 7:31 AM, villas villa...@gmail.com wrote: I forgot that you need to add different tables, try something like this instead... a=db.auth_user.with_alias('a') r1 = db(a.id==1).select(a.id) a=db.auth_group.with_alias('a') r2 = db(a.id==1).select(a.id) rows_all = r1 r2
[web2py] Re: A database design dillema
This should work. No guarantees that it will be fast. Also, limit_by would be problematic. Maybe you could cache the row set and just update the cache when there is a change. Otherwise there is a discussion here about processing the results of executesql. with_alias() and as_list() are well documented in the Web2py manual. For sorting, Google Python sorting list of dictionaries. ## use aliases so all the fields have the same name foo = db.table.field.with_alias('bar') fee = db.table.otherfield.with_alias('baz') ## get some data rows = db(some_arbitrary_query).select(foo, fee).as_list() ## reset the aliases foo = db.other_table.other_field.with_alias('bar') fee = db.other_table.yet_another_field.with_alias('baz') ## extend the list with rows from the other table rows.extend(db(otherquery)select(foo, fee).as_list()) ## loop through the result for row in rows: print row['bar'] print row['baz'] On Wednesday, July 11, 2012 6:47:06 PM UTC-4, Najtsirk wrote: Hello, I have a database design dilema. I want to do a e-learning system for a course. The course soould have severeal lessons, each lesson can be of different type. Let's say we have following model: #for definiton of each course db.define_table('course', Field('title', 'string')) #for the video lesson db.define_table('video', Field('title', 'string'), Field('video_url', 'string'), Field('course_id', db.course), Field('weight', 'integer')) #for the tekst lesson db.define_table('text', Field('title', 'string'), Field('content', 'text'), Field('course_id', db.course), Field('weight', 'integer')) I know how to do this with a raw sql using UNION, like: db.executesql('SELECT title, course_id, weight FROM video UNION SELECT title, course_id, weight FROM text WHERE course_id = *some_value* ORDER BY weight') But i wondering if there is any way I can achieve that with DAL? Maybe I should design the database model in a different way? Thank you for your replies, ideas, thoughts.. Kristjan
[web2py] Re: A database design dillema
http://web2py.com/books/default/chapter/29/6#find,-exclude,-sort On Thursday, July 12, 2012 8:16:20 AM UTC-4, Najtsirk wrote: I did manage to do this on my own. But the problem is ordering. I cannot get the records in the right order. I did manage to get the rows like: Table 1 - Record 1 Table 1 - Record 2 Table 1 - Record 3 Table 2 - Record 1 Table 2 - Record 2 Table 2 - Record 3 But how can i get output orderd by weight (which is a integer field in both tables), like: Table 1 - Record 2 - Weight 1 Table 2 - Record 3 - Weight 2 Table 2 - Record 1 - Weight 3 Table 1 - Record 3 - Weight 4 Table 2 - Record 2 - Weight 5 Table 1 - Record 1 - Weight 6 On Thursday, 12 July 2012 13:31:49 UTC+2, villas wrote: I forgot that you need to add different tables, try something like this instead... a=db.auth_user.with_alias('a') r1 = db(a.id==1).select(a.id) a=db.auth_group.with_alias('a') r2 = db(a.id==1).select(a.id) rows_all = r1 r2
Re: [web2py] Submitting Non-ASCII characters in GAE fails (was GAE error (INSERT INTO auth_event fails))
On 12 Jul 2012, at 1:54 AM, Alexei Vinidiktov wrote: As it turns out submitting any Non-ASCII characters in any form from any browser (for example changing a user's name to contain Cyrillic characters) results in the same error on GAE with MySQL (haven't tried with data store). Your strings appear to be encoded as utf-8. The complaining function wants either unicode or 7-bit ascii, so you'll need to decode your strings accordingly. u = '\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c'.decode('utf-8') print u Пользователь u = '\xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb'.decode('utf-8') print u вошёл Just *why* you can't use utf-8 directly I don't know. Any sql statement containing Non-ASCII characters returns the same error message: has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. This error seems to proceed from the Google Python protobuf library. http://code.google.com/p/protobuf/source/browse/trunk/python/google/protobuf/pyext/python-proto2.cc?r=395 Haven't found the same error message anywhere else. On Thu, Jul 12, 2012 at 2:57 PM, Alexei Vinidiktov alexei.vinidik...@gmail.com wrote: I now have some additional information. This error only occurs when using Firefox (I have version 13.0.1 on Windows) with Russian set as the preferred language in Firefox settings (I've also tested with English as preferred language and did't get this error). It doesn't occur when using any other browsers that I've tested (Chrome, Internet Explorer, Opera). On Thu, Jul 12, 2012 at 1:57 PM, Alexei Vinidiktov alexei.vinidik...@gmail.com wrote: Sorry, forgot to mention that I'm using Python 2.7 and web2py 1.99.7 on GAE . On Thu, Jul 12, 2012 at 1:41 PM, Alexei Vinidiktov alexei.vinidik...@gmail.com wrote: Hello, I'm receiving this error when trying to log in to my application: ValueError: INSERT INTO auth_event(origin,user_id,description,time_stamp,client_ip) VALUES ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb', '2012-07-12 06:20:04','95.190.89.149'); has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. Can you help me understand what's going on here? What's the description that is being inserted?
[web2py] Re: Jeditable and SQLTables
Have a rephrased/ simplified controller, and while almost got it working, running out of ideas/ talent. The problem is in posting parameters to the controller and passing a value back to the edited field (its just not seeing them). Any ideas would be welcome, but failing that, would anyone be interested in taking it on as a paid job to get it working? Controller def style(v,s1): if v==0: s1=background-color:#CFECEC elif v==2: s1=background-color:#EA else: s1=background-color:#00 s1=s1+; text-align:center return s1 def update(): if request.args: loc = request.args[0].split['.'] id = loc[0] column = loc[1] value = request.args[1] db(db.Stats.id==id).update(column=value) return value def measure(): s1 = [] db.Measure.FP.represent = lambda value, row: DIV(value, _class=EDit, _style=style(value,s1), _id=str(row.id)+'.FP') table = SQLFORM.grid(db.Measure) return dict(form=table, paginate=3) View {{response.files.append(URL('static','js/jquery.jeditable.js'))}} {{extend 'layout.html'}} script jQuery(document).ready(function(){ jQuery('.EDit').editable({{=URL('update')}},{ id: 'elementid', name: 'value', tooltip: Click to edit..., submit: 'OK', indicator : 'static\images\indicator.gif', });}) /script {{=form}} TIA,
Re: [web2py] Re: Website/Sqlite Backup
On 12 Jul 2012, at 4:56 AM, villas wrote: Regarding use with Apache wsgi and Sqlite. Does anyone know whether it is safe to copy a Sqlite DB file after Apache has been stopped. I mean, would stopping Apache leave the DB file in a good state for copying? This issue is not so much Apache as any clients of the database potentially doing a write during your copy. Stopping Apache will stop your web2py app from writing on behalf of incoming requests, but not from (say) system cron, if you happened to be using that, or perhaps the scheduler. An alternative is to copying the file is to use the command-line interface (sqlite3) and its .backup command. There's also a backup API that you can use.
[web2py] Re: building site menu from database
got this all working now: response.ttt = db((db.page.showinmenu==1)(db.page.active==1)).select(db.page.id, db.page.menutext, db.page.pageurl, db.page.parent, orderby=db.page.parent|db.page.sort|db.page.menutext) response.tttmenu = [dict(),dict()] for subpage in response.ttt: response.tttmenu[0][str(subpage.id)] = [subpage.menutext, subpage.pageurl, subpage.parent] if str(subpage.parent) in response.tttmenu[1]: response.tttmenu[1][str(subpage.parent)].append(subpage.id) else: response.tttmenu[1][str(subpage.parent)] = [subpage.id] def buildmenu(parent, menu): html = [] if menu[1][str(parent)]: for itemid in menu[1][str(parent)]: if str(itemid) in menu[1]: #children pageurlarg=str(menu[0][str(itemid)][1]) html.append((str(menu[0][str(itemid)][0]), False, URL('aptcms', 'pages', 'index', args=pageurlarg.split(/)), buildmenu(itemid, menu))) else: #no children pageurlarg=str(menu[0][str(itemid)][1]) html.append((str(menu[0][str(itemid)][0]), False, URL('aptcms', 'pages', 'index', args=pageurlarg.split(/ return html response.menu = buildmenu(0, response.tttmenu)
[web2py] Re: ldap login method bug - Allows any user to log in with blank password (AD)
Alright, I used the pep8 tool: http://pypi.python.org/pypi/pep8/ to do cleanup on the file. I fixed all the errors given by the tool except lines being over 79 characters when it didn't make sense to shorten them. This was mainly fixing indentation, but I fixed some typos, and a few code things (changing None type checking to isinstance for example.) I'm fairly certain the code all works correctly and I went over it several times, but I only have AD to test against. File attached. Any idea when the next stable release will come out? It seems to me this was a security error, and there may be vulnerable installations out there. Thanks, Kory On Wednesday, July 11, 2012 6:11:48 PM UTC-5, Massimo Di Pierro wrote: Thanks, in trunk. Any chance you could fix the indentation a little to follow pep8 I did some of it but it needs more work. This is not your fault. The pep8 was badly broken in the original file. Massimo On Wednesday, 11 July 2012 17:45:04 UTC-5, Kory Prince wrote: I did some digging and turned up this: http://docs.oracle.com/javase/jndi/tutorial/ldap/security/simple.html Which says a blank password causes the protocol to be changed to none. More specifically http://tools.ietf.org/html/rfc4513#section-5.1.2 tells us Clients SHOULD disallow an empty password input to a Name/Password Authentication user interface. Therefore I submit this patch that simply performs a check for a blank password. If you think there is a better way, please let me know, but I think it would be best to follow protocol. Thanks, Kory # -*- coding: utf-8 -*- # # last tinkered with by korylprince at gmail.com on 2012-07-12 # import sys import logging try: import ldap import ldap.filter ldap.set_option(ldap.OPT_REFERRALS, 0) except Exception, e: logging.error('missing ldap, try easy_install python-ldap') raise e def ldap_auth(server='ldap', port=None, base_dn='ou=users,dc=domain,dc=com', mode='uid', secure=False, cert_path=None, cert_file=None, bind_dn=None, bind_pw=None, filterstr='objectClass=*', username_attrib='uid', custom_scope='subtree', allowed_groups=None, manage_user=False, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail', manage_groups=False, db=None, group_dn=None, group_name_attrib='cn', group_member_attrib='memberUid', group_filterstr='objectClass=*', logging_level='error'): to use ldap login with MS Active Directory: from gluon.contrib.login_methods.ldap_auth import ldap_auth auth.settings.login_methods.append(ldap_auth( mode='ad', server='my.domain.controller', base_dn='ou=Users,dc=domain,dc=com')) to use ldap login with Notes Domino: auth.settings.login_methods.append(ldap_auth( mode='domino',server='my.domino.server')) to use ldap login with OpenLDAP: auth.settings.login_methods.append(ldap_auth( server='my.ldap.server', base_dn='ou=Users,dc=domain,dc=com')) to use ldap login with OpenLDAP and subtree search and (optionally) multiple DNs: auth.settings.login_methods.append(ldap_auth( mode='uid_r', server='my.ldap.server', base_dn=['ou=Users,dc=domain,dc=com','ou=Staff,dc=domain,dc=com'])) or (if using CN): auth.settings.login_methods.append(ldap_auth( mode='cn', server='my.ldap.server', base_dn='ou=Users,dc=domain,dc=com')) or you can full customize the search for user: auth.settings.login_methods.append(ldap_auth( mode='custom', server='my.ldap.server', base_dn='ou=Users,dc=domain,dc=com', username_attrib='uid', custom_scope='subtree')) the custom_scope can be: base, onelevel, subtree. If using secure ldaps:// pass secure=True and cert_path=... If ldap is using GnuTLS then you need cert_file=... instead cert_path because cert_path isn't implemented in GnuTLS :( If you need to bind to the directory with an admin account in order to search it then specify bind_dn bind_pw to use for this. - currently only implemented for Active Directory If you need to restrict the set of allowed users (e.g. to members of a department) then specify an rfc4515 search filter string. - currently only implemented for mode in ['ad', 'company', 'uid_r'] You can manage user attributes first name, last name, email from ldap: auth.settings.login_methods.append(ldap_auth(...as usual..., manage_user=True, user_firstname_attrib='cn:1', user_lastname_attrib='cn:2', user_mail_attrib='mail' )) Where: manage_user - let web2py handle user data from
Re: [web2py] Re: Website/Sqlite Backup
Jonathan, Thanks for your comments. I believe there would only be my web apps writing to the DB, so from what you say it's probably OK to do the copy after I stop Apache although this is still not the favoured solution. For the record, the other (better) solutions are: 1. Use Sqlite commandline interface and use the backup command. 2. Use python with the built-in iterdump() method. 3. You mentioned the backup API but this seems to be for C, so I will discount that. With regards 1, it seems that this has to be installed separately and I did not wish to add another dependency of something which has to be installed. Therefore, for the moment, I am favouring 2 because, from what I have read, iterdump() is good and reliable enough. However, I imagine the commandline tool would be the most reliable of all. It would be nice to find a couple of scripts to schedule, gzip versions with date suffixes, and restore etc. If anyone knows a script like that, please post here for future reference. Backup is important for us all, so it is nice to have all these ideas to hand. Thanks. On Thursday, July 12, 2012 3:00:12 PM UTC+1, Jonathan Lundell wrote: On 12 Jul 2012, at 4:56 AM, villas wrote: Regarding use with Apache wsgi and Sqlite. Does anyone know whether it is safe to copy a Sqlite DB file after Apache has been stopped. I mean, would stopping Apache leave the DB file in a good state for copying? This issue is not so much Apache as any clients of the database potentially doing a write during your copy. Stopping Apache will stop your web2py app from writing on behalf of incoming requests, but not from (say) system cron, if you happened to be using that, or perhaps the scheduler. An alternative is to copying the file is to use the command-line interface (sqlite3) and its .backup command. There's also a backup API that you can use.
[web2py] Re: Jeditable and SQLTables
Simon, Instead of using the default operation of jeditable, I just past in a function and used jquery.post to send the data to the controller. In Javascript I just do: jQuery(.EDIT).editable(function(value,settings){ //Grab the id you want the value of the field is stored in value jQuery.post(//URL to controller,function.json, postdata, callback if required) return(value); //This takes the new value typed in the editable area and replaces the old value. },{ tooltip:'Click to edit in place...' //Add other settings here }); HTH, Brent On Friday, 22 June 2012 05:36:58 UTC-6, Simon Ashley wrote: Does anyone have any native python/ web2py code for a jeditable call in a table that they are willing to share i.e. a web2py version of save.php?
[web2py] Re: [web2py-dev] Asyncronous Application Sync
Hi, Well, i need to work with that, so i will try to develop some features to support this! Saludos, Alfonso de la Guarda Twitter: @alfonsodg Redes sociales: alfonsodg Telef. 991935157 1024D/B23B24A4 5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4 On Wed, Jul 11, 2012 at 5:26 PM, Massimo DiPierro massimo.dipie...@gmail.com wrote: There are two issue: 1) protocol for transferring data; 2) exporting and importing from database. rabbitmq etc. only address 1 and you do not need any. Web2py already has a web server a many RPC systems you can use. The real issue is 2. If your tables have a uuid field, db.export_to_csv_field and db.import_from_csv_file should do what you ask. I am planning to improve this functionality but it would help to know if it works for you as it is and what problems you encounter with it. On Jul 11, 2012, at 12:06 PM, Alfonso de la Guarda wrote: Hi, I have a web2py app in 2 places: - City location - Rainforest location The app is the same for both cases, however the city app is the main. I need to synchronize the information entered in the location of the jungle to the city but not bi-directionally due to low bandwidth, in addition should be automatic as soon as there is availability of connectivity (ie queue management / messaging). Has anyone had experiences like this with web2py specifically? ( I can surely work with rabbitmq, hornetmq, etc. but there is an approach for web2py?) Saludos, Alfonso de la Guarda Twitter: @alfonsodg Redes sociales: alfonsodg Telef. 991935157 1024D/B23B24A4 5469 ED92 75A3 BBDB FD6B 58A5 54A1 851D B23B 24A4 -- mail from:GoogleGroups web2py-developers mailing list make speech: web2py-develop...@googlegroups.com unsubscribe: web2py-developers+unsubscr...@googlegroups.com details: http://groups.google.com/group/web2py-developers the project: http://code.google.com/p/web2py/ official: http://www.web2py.com/ -- mail from:GoogleGroups web2py-developers mailing list make speech: web2py-develop...@googlegroups.com unsubscribe: web2py-developers+unsubscr...@googlegroups.com details: http://groups.google.com/group/web2py-developers the project: http://code.google.com/p/web2py/ official: http://www.web2py.com/
[web2py] Re: A database design dillema
Thanks guys for your help. I went with Villas/Anthony's idea. On Thursday, 12 July 2012 00:47:06 UTC+2, Najtsirk wrote: Hello, I have a database design dilema. I want to do a e-learning system for a course. The course soould have severeal lessons, each lesson can be of different type. Let's say we have following model: #for definiton of each course db.define_table('course', Field('title', 'string')) #for the video lesson db.define_table('video', Field('title', 'string'), Field('video_url', 'string'), Field('course_id', db.course), Field('weight', 'integer')) #for the tekst lesson db.define_table('text', Field('title', 'string'), Field('content', 'text'), Field('course_id', db.course), Field('weight', 'integer')) I know how to do this with a raw sql using UNION, like: db.executesql('SELECT title, course_id, weight FROM video UNION SELECT title, course_id, weight FROM text WHERE course_id = *some_value* ORDER BY weight') But i wondering if there is any way I can achieve that with DAL? Maybe I should design the database model in a different way? Thank you for your replies, ideas, thoughts.. Kristjan
[web2py] Re: Sending an email on CRUD complete...
crud.settings.create_onvalidation = lambda form: send_email(form.vars.email, subject, message) but I'd recommend you do not use crud and use SQLFROM instead. form = SQLFORM() if form.process().accepted: send_mail(form.vars.email, subject, message) On Thursday, 12 July 2012 01:14:41 UTC-5, encompass wrote: I am reading in the book: crud.settings.create_onvalidation = StorageList() But I just don't get it. I wanted to send an email when the form submits successfully, and I have created a method for that. send_email(to_email, subject, message) How would I do this? BR, Jason Brower
[web2py] Re: GAE error (INSERT INTO auth_event fails)
Please open a ticket about this. On Thursday, 12 July 2012 01:41:31 UTC-5, Alexei Vinidiktov wrote: Hello, I'm receiving this error when trying to log in to my application: ValueError: INSERT INTO auth_event(origin,user_id,description,time_stamp,client_ip) VALUES ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb', '2012-07-12 06:20:04','95.190.89.149'); has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. Can you help me understand what's going on here? What's the description that is being inserted? Here's the whole traceback: 1. /user/login?_next=/ui 500 7153ms 0kb Mozilla/5.0 (Windows NT 6.2; rv:13.0) Gecko/20100101 Firefox/13.0.1 95.190.89.149 - - [11/Jul/2012:23:20:11 -0700] POST /user/login?_next=/ui HTTP/1.1 500 245 http://www.vocabilis-net.appspot.com/user/login?_next=/ui; Mozilla/5.0 (Windows NT 6.2; rv:13.0) Gecko/20100101 Firefox/13.0.1 www.vocabilis-net.appspot.com ms=7153 cpu_ms=2438 api_cpu_ms=0 cpm_usd=0.067897 instance=00c61b117ca46127ca9599783f07c494292f2e https://appengine.google.com/instances?app_id=s%7Evocabilis-netversion_id=1.360260160184278425key=00c61b117ca46127ca9599783f07c494292f2e#00c61b117ca46127ca9599783f07c494292f2e 2. D 2012-07-11 23:20:04.807 select application=vocabilis 3. D 2012-07-11 23:20:04.808 route: controller=default 4. D 2012-07-11 23:20:04.808 route: function.ext=user.html 5. E 2012-07-11 23:20:11.821 Traceback (most recent call last): File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/restricted.py, line 205, in restricted exec ccode in environment File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py, line 131, in module File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/globals.py, line 173, in lambda self._caller = lambda f: f() File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/applications/vocabilis/controllers/default.py, line 49, in user return dict(form=auth()) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py, line 1161, in __call__ return getattr(self,args[0])() File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py, line 1814, in login self.log_event(log, user) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/tools.py, line 1461, in log_event origin=origin, user_id=user_id) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py, line 6829, in insert return self._db._adapter.insert(self,self._listify(fields)) File /base/data/home/apps/s~vocabilis-net/1.360260160184278425/gluon/dal.py, line 928, in insert raise e ValueError: INSERT INTO auth_event(origin,user_id,description,time_stamp,client_ip) VALUES ('auth',2,'\xd0\x9f\xd0\xbe\xd0\xbb\xd1\x8c\xd0\xb7\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c 2 \xd0\xb2\xd0\xbe\xd1\x88\xd1\x91\xd0\xbb','2012-07-12 06:20:04','95.190.89.149'); has type str, but isn't in 7-bit ASCII encoding. Non-ASCII strings must be converted to unicode objects before being added. 6. I 2012-07-11 23:20:11.862 Saved; key: __appstats__:004800, part: 134 bytes, full: 52828 bytes, overhead: 0.003 + 0.014; link: http://www.vocabilis-net.appspot.com/_ah/stats/details?time=1342074004806 -- Alexei Vinidiktov
[web2py] displaying errors for list:string types
Hello, i recently tried the following: def test4(): form = SQLFORM.factory( Field(name, length=25), Field(opts, list:string, requires=IS_IN_SET(['one', 'two','three'], multiple=True), widget=SQLFORM.widgets.checkboxes.widget), ) if form.accepts(request, session, onvalidation=is_valid): return splendid # Use generic HTML views response.generic_patterns = ['html'] return dict(form=form) def is_valid(form): if 'two' not in form.vars.opts: form.errors.opts = Must select option two return and found that with web2py trunk (and the latest release) i don't see the error if i don't select option two. form.errors has the error... i did some digging, and found that for some reason when using a SQLFORM if the field type is list: it chooses not to display the error. i don't know why this check was in there, but in the attached patch (against trunk) i remove that check. can anyone remember why that check is there and what i might be breaking by suggesting that we remove it? thanks! christian list-validation-patch.out Description: Binary data
[web2py] en to en - Can I do this with T?
I need something like this. h1 {{=T(Here I will put the awesome title)}} /h1 So I will create files for languages: en.py {Here I will put the awesome title: My Title} pt-br.py {Here I will put the awesome title: Meu título} an so.. Should it works?
[web2py] Re: Any jquery gurus out there?
You know, with IE, I have had problems if my script tags didn't have type='text/javascript. On Tuesday, July 10, 2012 3:54:14 PM UTC-7, RKS wrote: I know this is probably not the right place to ask, but I am using w2p and post here pretty frequently so I figured what the heck. I'm also in a rush and not finding out what I need on stackoverflow. I have some jquery and it works in every browser except any version of IE. If you happen to notice anything right off the bat that will cause this not to work, please let me know. I'm desperate. Thanks. script src= https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js /script script $(function () { // hide all the steps on document load $(div.step).addClass(hidden); // show the one step that is identified by the current hash (if any) $(document.location.hash).removeClass(hidden); $(a.reveal).click(function (event) { var idToReveal = $(this).attr(href); // store the ID to show in the URL for bookmarking document.location.hash = idToReveal; // hide every step that is currently visible $(div.step).not(.hidden).addClass(hidden); // reveal the next div (as identified by the current link's href) $(idToReveal).removeClass(hidden); // prevent the default click behavior (i.e. prevent navigation) event.preventDefault(); }); }); /script Quick recap, this hides divs and shows them via anchors on the page. It also saves the hash so on reload it opens to the current hash instead of going back to 1. Thanks
Re: [web2py] Re: Routing broke between 2012-06-18 and 2012-07-10
*bump* On Wed, Jul 11, 2012 at 2:02 AM, Alec Taylor alec.tayl...@gmail.com wrote: On Wed, Jul 11, 2012 at 1:40 AM, Anthony abasta...@gmail.com wrote: We just made a change to auth.navbar() so the login link is now treated like the other links. By default, the URL of the current page the user is on is added as a referrer to the query string of the login link (as well as all the other navbar links, except logout). After login, the user is automatically redirected back to the referring page. This was done to make login consistent with the other actions (register, profile, forgot password, etc.), as it wasn't clear why it should behave differently. You can also now override the referrer behavior for any or all of the navbar links. To limit the referrer behavior to a subset of links, just list them in the new referrer_actions argument: auth.navbar(referrer_actions=['register', 'profile', ...]) To disable the referrers entirely, just set referrer_actions to None. If you exclude login from the referrer_actions list, then auth.settings.login_next will take effect. Anyway, why do you always want to redirect users to the profile page every time they log in? Are they expected to change their profile regularly? Anthony Hmm, I added that line (`auth.navbar(referrer_actions=['register', 'profile', 'login'])`) below `auth.settings.login_next = URL(f='profile')` in db.py, and it changed the way the problem occurs. Now #_=_ is no longer appended, /profile/ still works when typed explicitly, but it doesn't redirect to /profile/. When I add that line above the `auth.settings.login_next = URL(f='profile')` line it also doesn't redirect to /profile/, but now #_=_ is appended. I want the user to be sent to their profile page because: 1. Initially they will need to fill in fields not taken from Facebook 2. From then on it will show them which events they have RSVP'd to; and groups they are a member of 3. From then on it will also show recommended events and groups FYI: I'll be open-sourcing this entire system and pushing it to Bitbucket when it's a little more polished; i.e.: on or before August 2 How can I get an automatic redirect to the /profile/ page? Thanks for all sugestions, Alec Taylor
[web2py] Re: en to en - Can I do this with T?
I think so, but to force translation for all languages, you might need to do something like: T.current_languages = [] By default, T.current_languages = ['en'], which means it doesn't bother translating when the accepted language is 'en'. Anthony On Thursday, July 12, 2012 1:37:16 PM UTC-4, rochacbruno wrote: I need something like this. h1 {{=T(Here I will put the awesome title)}} /h1 So I will create files for languages: en.py {Here I will put the awesome title: My Title} pt-br.py {Here I will put the awesome title: Meu título} an so.. Should it works?
Re: [web2py] Re: Routing broke between 2012-06-18 and 2012-07-10
Hmm, I added that line (`auth.navbar(referrer_actions=['register', 'profile', 'login'])`) below `auth.settings.login_next = URL(f='profile')` in db.py, and it changed the way the problem occurs. No, you don't want 'login' to be one of the referrer_actions -- that will cause it to redirect to the referring page rather than the auth.settings.login_next URL. Anthony
[web2py] Re: displaying errors for list:string types
Please open a ticket about this and include a link to the patch. I need to check the reason for that code. On Thursday, 12 July 2012 12:33:27 UTC-5, howesc wrote: Hello, i recently tried the following: def test4(): form = SQLFORM.factory( Field(name, length=25), Field(opts, list:string, requires=IS_IN_SET(['one', 'two','three'], multiple=True), widget=SQLFORM.widgets.checkboxes.widget), ) if form.accepts(request, session, onvalidation=is_valid): return splendid # Use generic HTML views response.generic_patterns = ['html'] return dict(form=form) def is_valid(form): if 'two' not in form.vars.opts: form.errors.opts = Must select option two return and found that with web2py trunk (and the latest release) i don't see the error if i don't select option two. form.errors has the error... i did some digging, and found that for some reason when using a SQLFORM if the field type is list: it chooses not to display the error. i don't know why this check was in there, but in the attached patch (against trunk) i remove that check. can anyone remember why that check is there and what i might be breaking by suggesting that we remove it? thanks! christian
[web2py] Re: Alternative to Janrain: in pure Python
Thank you Sakesh for the offer. We will work on intergation asap and we may ask for help with your api. massimo On Monday, 9 July 2012 12:34:28 UTC-5, Rakesh Soni wrote: Great project. Let me know if you guys need some contribution from LoginRadius http://www.loginradius.com Team. We also offer social authentication, social sharing, user profile data and social analytics for Python websites through our SDKhttps://www.loginradius.com/plugins/pythonsdk . Thanks, Rakesh Soni On Saturday, July 7, 2012 3:47:19 AM UTC-6, David Marko wrote: That would be great having something like this integrated into web2py . David
[web2py] Re: displaying errors for list:string types
issue 886: http://code.google.com/p/web2py/issues/detail?id=886 thanks! cfh On Thursday, July 12, 2012 11:53:22 AM UTC-7, Massimo Di Pierro wrote: Please open a ticket about this and include a link to the patch. I need to check the reason for that code. On Thursday, 12 July 2012 12:33:27 UTC-5, howesc wrote: Hello, i recently tried the following: def test4(): form = SQLFORM.factory( Field(name, length=25), Field(opts, list:string, requires=IS_IN_SET(['one', 'two','three'], multiple=True), widget=SQLFORM.widgets.checkboxes.widget), ) if form.accepts(request, session, onvalidation=is_valid): return splendid # Use generic HTML views response.generic_patterns = ['html'] return dict(form=form) def is_valid(form): if 'two' not in form.vars.opts: form.errors.opts = Must select option two return and found that with web2py trunk (and the latest release) i don't see the error if i don't select option two. form.errors has the error... i did some digging, and found that for some reason when using a SQLFORM if the field type is list: it chooses not to display the error. i don't know why this check was in there, but in the attached patch (against trunk) i remove that check. can anyone remember why that check is there and what i might be breaking by suggesting that we remove it? thanks! christian
[web2py] Connection timed out - mysql
Hello, I'm having Connection timed out to mysql server. I'm creating a sheet from some queries. The function is in a module, and running it from console. Sometimes, it goes OK, but sometimes I get the error (see below). I'm using EC2 and the database is in RDS. Thanks for any help... Marcello - Traceback (most recent call last): File /home/tecno2/web2py/gluon/shell.py, line 206, in run execfile(startfile, _env) File applications/segundarj/private/diario.py, line 2, in module planilha.roda(True) File applications/segundarj/modules/planilha.py, line 64, in roda print aba: %s, total: %s % (aba,processos.count()) File /home/tecno2/web2py/gluon/dal.py, line 7573, in count return self.db._adapter.count(self.query,distinct) File /home/tecno2/web2py/gluon/dal.py, line 1339, in count self.execute(self._count(query, distinct)) File /home/tecno2/web2py/gluon/dal.py, line 1392, in execute return self.log_execute(*a, **b) File /home/tecno2/web2py/gluon/dal.py, line 1386, in log_execute ret = self.cursor.execute(*a, **b) File /home/tecno2/web2py/gluon/contrib/pymysql/cursors.py, line 108, in execute self.errorhandler(self, exc, value) File /home/tecno2/web2py/gluon/contrib/pymysql/connections.py, line 182, in defaulterrorhandler raise Error(errorclass, errorvalue) Error: (class 'socket.error', error(110, 'Connection timed out')) Traceback (most recent call last): File web2py.py, line 20, in module gluon.widget.start(cron=True) File /home/tecno2/web2py/gluon/widget.py, line 868, in start import_models=options.import_models, startfile=options.run) File /home/tecno2/web2py/gluon/shell.py, line 210, in run if import_models: BaseAdapter.close_all_instances('rollback') File /home/tecno2/web2py/gluon/dal.py, line 432, in close_all_instances getattr(instance, action)() File /home/tecno2/web2py/gluon/dal.py, line 1357, in rollback return self.connection.rollback() File /home/tecno2/web2py/gluon/contrib/pymysql/connections.py, line 571, in rollback self.errorhandler(None, exc, value) File /home/tecno2/web2py/gluon/contrib/pymysql/connections.py, line 182, in defaulterrorhandler raise Error(errorclass, errorvalue) gluon.contrib.pymysql.err.Error: (class 'socket.error', error(32, 'Broken pipe'))
[web2py] Re: Apache wsgi virtualhost configuration for multiple web2py sites
Does anyone know how to use mod_wsgi with multiple virtualhosts? I have 2 domains: project1.uni.edu project2.uni.edu And I want to be able to omit the project names from the URL path, as such: http://project1.uni.edu/ - http://project1.uni.edu/project1/default/index http://project2.uni.edu/ - http://project2.uni.edu/project2/default/index It is IMPORTANT that the project name does not HAVE TO show up after in the URL path after the domain at all, because there are a lot of legacy links circulated before the web2py app was even written. Both domains are FQDNs -- I don't have access to uni.edu zones or any configuration like that. Both DNs point to the same server, where I have two virtualhosts (defined below). Also, just to make things fun, soon we will have sub1.project2.uni.edu, sub2.project2.uni.edu, etc. Project1 will not branch anymore. The thing is, for project1, I set web2py up to not have to include the app name, since it's called project1 as well. Furthermore, both projects must be able to use mod_user to show websites of users belonging to the projects (meaning they are different user directories). They also both have AWStats running (hence the WSGIScriptAliasMatch below). Now, my question (apologies to G. Dumpleton for my inability to understand) is about the WSGI ProcessGroup/ApplicationGroup settings. As I understand it, if I want to use two virtualhosts with one instance of web2py over mod_wsgi, I must define the WSGIDaemonProcess outside of the virtualhosts, and use WSGIProcessGroup with the name I defined in WSGIDaemonProcess. Or I could define two separate WSGIDaemonProcesses within the vhosts, but give them unique names. Does anyone know the ramifications of choosing 1 method over the other? My other question is about the WSGIApplicationGroup setting -- I see I can set it to %{GLOBAL}, %{SERVER}, %{RESOURCE} or %{ENV:var}. Does anyone know if setting both to %GLOBAL is ok? Or should I use %{RESOURCE} to keep them from executing in the same interpreter (or process? I'm admittedly ill-informed about these settings...). Is this setting affected by my choice of single vs multiple WSGIDaemonProcess definitions? Currently my conf files are as such: Virtualhost *:80 ServerName project1.uni.edu WSGIDaemonProcess web2py user=www-user group=www-group processes=3 threads=5 \ display-name=%{GROUP} WSGIProcessGroup web2py WSGIApplicationGroup %{GLOBAL} WSGIScriptAliasMatch ^(/([^~].*|awstats.*)?)$ /var/www/web2py/wsgihandler.py$1 #... more stuff including web2py-static via apache, locking admin, user_dirs, awstats conf, etc... /Virtualhost VirtualHost *:80 ServerName project2.uni.edu WSGIDaemonProcess project2 user=www-user group=www-group processes=3 threads=5 \ display-name=%{GROUP} WSGIProcessGroup project2 WSGIApplicationGroup %{RESOURCE} WSGIScriptAliasMatch ^(/([^~].*|awstats.*)?)$ /var/www/web2py/wsgihandler.py$1 #... more stuff including web2py-static via apache, locking admin, user_dirs, awstats conf, etc... /Virtualhost I want to change the project1 AppGroup to be RESOURCE as well to see if that has the desired effect, but I cannot do that at the moment since proejct1 is in production. LAST question: If I were to redo this configuration file to sit in a single vhost (forgetting about the mod_user/awstats for now), would the default_application = project1 setting totally screw me on project2 URLs? If so, are there any severe disadvantages to having two separate instances of web2py ... or even better, is it possible to specify the application based on the request host? perhaps in the app-specific routes file something like: routers = dict( BASE = dict(default_application='project1' if request.env.http_host == 'project1.uni.edu' else 'project2'), ) I guess I'm not sure if the routers can be set from within an application, or if that will royally hose things. well, thanks in advance to anyone who responds! -Abraham On Sunday, October 17, 2010 5:21:21 PM UTC-5, Tom A wrote: I know this has been asked before but I've been unable to find a clear answer. (Apologies to Graham Dumpleton who must have answered this kind of question many times for Django etc but I can't work out how to do it for web2py) I have a Debian server set up and running web2py with mod_wsgi using the instructions in the book. All works great. The file /etc/apache2/sites-available/default has the virtualhost directives as shown in the book. So at the moment any request to the server simply shows the welcome app. I have 3 domain names which resolve to the IP address of the server: - domain1.com - domain2.com - domain3.com I have a web2py application for each of these. They are in /var/www/web2py/applications/domain1 etc. So now I want to create 3 files in /etc/apache2/sites-available that will get apache to serve up the appropriate
Re: [web2py] Re: Apache wsgi virtualhost configuration for multiple web2py sites
perhaps this can help you http://martin.tecnodoc.com.ar/post/2012/02/08/14_setup-virtual-hosting-with-web2py-and-apache2-mod-wsgi-on-ubuntu-server-1110 2010/12/13 Vincent vincentdavis...@gmail.com I am interested in a little different setup, I would like *.example.com to go to the web2py app/folder but be able to specify other.example.com be served from /var/www/other/ I am having trouble figuring out how to configure Apache virtual host to do this. Thanks Vincent On Oct 18, 7:07 pm, VP vtp2...@gmail.com wrote: The way I did this is through Apache, by adding ServerName domain.com ServerAlias *.domain.com to the web2py configuration section in site-enabled/000-default Which one is more preferable? pros and cons? Thanks. -- http://www.tecnodoc.com.ar
Re: [web2py] Re: Apache wsgi virtualhost configuration for multiple web2py sites
Ah -- i had forgotten that you can have the domains dictionary in routers.BASE -- thanks! I think this will help indeed. Do you know if I can use ports in the domain dict key? I would like to test this out on another port so that the live site isn't affected and the placeholder site for project2 can remain a static HTML placeholder site (it does get hit occasionally). For others' reference, I think this is the solution I will go with -- using 1 installation of web2py, 1 Vhost with a single WSGIDaemonProcess definition, and I will put the following web2py-global routes.py file: routers = dict( # base router BASE = dict( default_application = 'welcome', domains = { 'project1.uni.edu': 'project1', 'www.project1.uni.edu': 'project1', 'project2.uni.edu' : 'project2', 'www.project2.uni.edu' : 'project2' } ) ) I'll post back here regarding the status of this next week, as I'll be testing this setup over the weekend. Thanks again! -Abe -- The trouble with quotes from the internet is that it's hard to verify their authenticity - Abraham Lincoln On Thursday, July 12, 2012 3:00:48 PM UTC-5, Martin.Mulone wrote: perhaps this can help you http://martin.tecnodoc.com.ar/post/2012/02/08/14_setup-virtual-hosting-with-web2py-and-apache2-mod-wsgi-on-ubuntu-server-1110 I am interested in a little different setup, I would like *.example.com to go to the web2py app/folder but be able to specify other.example.com be served from /var/www/other/ I am having trouble figuring out how to configure Apache virtual host to do this. Thanks Vincent On Oct 18, 7:07 pm, VP vtp2...@gmail.com wrote: The way I did this is through Apache, by adding ServerName domain.com ServerAlias *.domain.com to the web2py configuration section in site-enabled/000-default Which one is more preferable? pros and cons? Thanks. -- http://www.tecnodoc.com.ar
[web2py] Scheduler: help us test it while learning
Hello everybody, in the last month several changes were commited to the scheduler, in order to improve it. Table schemas were changed, to add some features that were missed by some users. On the verge of releasing web2py v.2.0.0, and seeing that the scheduler potential is often missed by regular web2py users, I created a test app with two main objectives: documenting the new scheduler and test the features. App is available on github (https://github.com/niphlod/w2p_scheduler_tests). All you need is download the trunk version of web2py, download the app and play with it. Current features: - one-time-only tasks - recurring tasks - possibility to schedule functions at a given time - possibility to schedule recurring tasks with a stop_time - can operate distributed among machines, given a database reachable for all workers - group_names to divide tasks among different workers - group_names can also influence the percentage of assigned tasks to similar workers - simple integration using modules for embedded tasks (i.e. you can use functions defined in modules directly in your app or have them processed in background) - configurable heartbeat to reduce latency: with sane defaults and not t many tasks queued normally a queued task doesn't exceed 5 seconds execution times - option to start it, process all available tasks and then die automatically - integrated tracebacks - monitorable as state is saved on the db - integrated app environment if started as web2py.py -K - stop processes immediately (set them to KILL) - stop processes gracefully (set them to TERMINATE) - disable processes (set them to DISABLED) - functions that doesn't return results do not generate a scheduler_run entry - added a discard_results parameter that doesn't store results no matter what - added a uuid record to tasks to simplify checkings of unique tasks - task_name is not required anymore - you can skip passing the function to the scheduler istantiation: functions can be dinamically retrieved in the app's environment So, your mission is: - test the scheduler with the app and familiarize with it Secondary mission is: - report any bug you find here or on github (https://github.com/niphlod/w2p_scheduler_tests/issues) - propose new examples to be embedded in the app, or correct the current docs (English is not my mother tongue) Once approved, docs will be probably embedded in the book (http://web2py.com/book) Feel free to propose features you'd like to see in the scheduler, I have some time to spend implementing it.
[web2py] Re: Connection timed out - mysql
I get these broken pipe errors almost daily now, usually in the wee hours of the morning (between 1-5am). I'll get one or two, or sometimes like 5, but probably not more than say 10/day (on one page that pulls four images from the DB, i will get 4 at once), and it doesn't happen every day. I am storing images (100KB) in the database, but I'm not sure if that's it. I'm also hosting this on VMs (one for web2py, one for mysql DB server), and a few months ago I had never seen this error. It might be something to do with the VM setup but I'm really not sure. From what I understand, broken pipe happens at the OS level and is something to do with transferring information from the DB server... sound right? Also, (separate issue, possibly related?) sometimes the website becomes unresponsive, and I get errors to do with base64 decoding and assertion errors: File /var/www/web2py/gluon/dal.py, line 5481, in select return self.db._adapter.select(self.query,fields,attributes) File /var/www/web2py/gluon/dal.py, line 1192, in select return self.parse(rows,self._colnames) File /var/www/web2py/gluon/dal.py, line 1421, in parse colset[fieldname] = base64.b64decode(str(value)) File /usr/lib64/python2.6/base64.py, line 76, in b64decode raise TypeError(msg) TypeError: Incorrect padding and : Error: (type 'exceptions.AssertionError', AssertionError('Result length not requested length:\nExpected=97. Actual=31. Position: 299. Data Length: 330',)) The odd thing is that I can do these queries via mysql command line, even when running mysql on the webserver to connect to the DB host, and they return instantly... although I guess I'm not sure if the assertion error comes from MySQL or is part of web2py's DB adapter? We used wireshark to determine that the TCP packets were being incessantly retransmitted ... but only sometimes. The Padding/Assertion Errors seem to be related to VMs since migrating the machine to a different physical host and back resolves the issue immediately. Also, restarting httpd tends to lessen the amount of Broken Pipe errors I see, so perhaps it's some sort of stale connection to the DB? -Abe On Thursday, July 12, 2012 2:02:01 PM UTC-5, Marcello wrote: Hello, I'm having Connection timed out to mysql server. I'm creating a sheet from some queries. The function is in a module, and running it from console. Sometimes, it goes OK, but sometimes I get the error (see below). I'm using EC2 and the database is in RDS. Thanks for any help... Marcello - Traceback (most recent call last): File /home/tecno2/web2py/gluon/shell.py, line 206, in run execfile(startfile, _env) File applications/segundarj/private/diario.py, line 2, in module planilha.roda(True) File applications/segundarj/modules/planilha.py, line 64, in roda print aba: %s, total: %s % (aba,processos.count()) File /home/tecno2/web2py/gluon/dal.py, line 7573, in count return self.db._adapter.count(self.query,distinct) File /home/tecno2/web2py/gluon/dal.py, line 1339, in count self.execute(self._count(query, distinct)) File /home/tecno2/web2py/gluon/dal.py, line 1392, in execute return self.log_execute(*a, **b) File /home/tecno2/web2py/gluon/dal.py, line 1386, in log_execute ret = self.cursor.execute(*a, **b) File /home/tecno2/web2py/gluon/contrib/pymysql/cursors.py, line 108, in execute self.errorhandler(self, exc, value) File /home/tecno2/web2py/gluon/contrib/pymysql/connections.py, line 182, in defaulterrorhandler raise Error(errorclass, errorvalue) Error: (class 'socket.error', error(110, 'Connection timed out')) Traceback (most recent call last): File web2py.py, line 20, in module gluon.widget.start(cron=True) File /home/tecno2/web2py/gluon/widget.py, line 868, in start import_models=options.import_models, startfile=options.run) File /home/tecno2/web2py/gluon/shell.py, line 210, in run if import_models: BaseAdapter.close_all_instances('rollback') File /home/tecno2/web2py/gluon/dal.py, line 432, in close_all_instances getattr(instance, action)() File /home/tecno2/web2py/gluon/dal.py, line 1357, in rollback return self.connection.rollback() File /home/tecno2/web2py/gluon/contrib/pymysql/connections.py, line 571, in rollback self.errorhandler(None, exc, value) File /home/tecno2/web2py/gluon/contrib/pymysql/connections.py, line 182, in defaulterrorhandler raise Error(errorclass, errorvalue) gluon.contrib.pymysql.err.Error: (class 'socket.error', error(32, 'Broken pipe'))
[web2py] DB query
I have these tables and I'd like to get every file which has no article referred to it so I can delete them. What's the simplest way of achieving this? db.define_table('articles', Field('created_on', 'datetime', default = datetime.today(),required = True, notnull = True, requires = [IS_NOT_EMPTY(), IS_DATETIME(format = T('%Y-%m-%d %H:%M:%S'))]), Field('article_teaser_hu', 'text', required = True, notnull = True, requires = IS_NOT_EMPTY()), Field('article_hu', 'text', required = True, notnull = True,requires = IS_NOT_EMPTY()), Field('article_teaser_en', 'text', required = True, notnull = True, requires = IS_NOT_EMPTY()), Field('article_en', 'text', required = True, notnull = True,requires = IS_NOT_EMPTY())) db.define_table('files', Field('original_filename', 'string', required = True,notnull = True), Field('uploaded_file', 'upload', uploadfield = 'uploaded_data', required = True, notnull = True, requires = IS_NOT_EMPTY ()), Field('uploaded_data', 'blob', notnull = True), Field('created_on', 'datetime', notnull = True)) db.define_table('articles_files', Field('articles', db.articles), Field('files', db.files))
[web2py] GIS in web2py
For the GIS enthusiasts here, in case you missed this, here's an interesting web app: http://madrona.ecotrust.org/technology/ It's written in Django.
[web2py] Web2Py on Raspberry Pi?
Raspberry Pi is an inexpensive $35 ARM based Linux board that has 256MB of RAM and Ethernet as network connectivity. They are shipping in volume, maybe a million by end of 2012. Anybody thinking about trying Web2Py on a Raspberry Pi? I don't have the chops myself. Debian is running fine on it, and that image includes a working Python. So... it needs a web server compiled for ARM, and a database. Anything else? And thoughts on whether 256MB of RAM might work for a lightly-loaded Web2Py server? --ron k jeffries
[web2py] URL helper not building good URL's
Hello, I'm starting in web2py and I can get past something really simple. I need to make a link for some css files on the static folder, however I don't seem to get the link right... I tryed the following: URL('static', 'css\style.css') /static/css/style.css URL(a=request.application, args='static/css/style.css') /default/static/css/style.css URL(r=request, args='static/css/style.css') /index/static/css/style.css URL('static/css/style.css/') /default/static/css/style.css URL(a=request.application, c='static/css/style.css', f='') /myapp/myapp/static/css/style.css I may even have tryed somemore, but nothing gave me the expected: /myapp/static/css/style.css I'm using myapp as application, default as controller and index as a function. All these calls were done from index.html on default folder on views folder. I'm deplying this code on GAE test server and real server, one of these works on local server, forgot which :/ Lastly I think this may have something to do with the routes.py file so here is the important part of it: routers = dict ( BASE = dict( applications = ['myapp','admin'], default_application = 'myapp', default_controller = 'default', default_function = 'index', map_static = true ) ) I hope you can help me, Gustavo
[web2py] hi
please anyone can tell me about the web2py and it's community and if i learn it can i find a job easily
[web2py] Re: Connection timed out - mysql
The Assertion error comes from pymysql which ships with web2py. I just upgraded trunk to a newer version. Give it a try. It may (or my not) resolve the problem. You may want to ask the pymysql mailing list for an explanations of the error. On Thursday, 12 July 2012 17:06:06 UTC-5, AbrahamLinksys wrote: I get these broken pipe errors almost daily now, usually in the wee hours of the morning (between 1-5am). I'll get one or two, or sometimes like 5, but probably not more than say 10/day (on one page that pulls four images from the DB, i will get 4 at once), and it doesn't happen every day. I am storing images (100KB) in the database, but I'm not sure if that's it. I'm also hosting this on VMs (one for web2py, one for mysql DB server), and a few months ago I had never seen this error. It might be something to do with the VM setup but I'm really not sure. From what I understand, broken pipe happens at the OS level and is something to do with transferring information from the DB server... sound right? Also, (separate issue, possibly related?) sometimes the website becomes unresponsive, and I get errors to do with base64 decoding and assertion errors: File /var/www/web2py/gluon/dal.py, line 5481, in select return self.db._adapter.select(self.query,fields,attributes) File /var/www/web2py/gluon/dal.py, line 1192, in select return self.parse(rows,self._colnames) File /var/www/web2py/gluon/dal.py, line 1421, in parse colset[fieldname] = base64.b64decode(str(value)) File /usr/lib64/python2.6/base64.py, line 76, in b64decode raise TypeError(msg) TypeError: Incorrect padding and : Error: (type 'exceptions.AssertionError', AssertionError('Result length not requested length:\nExpected=97. Actual=31. Position: 299. Data Length: 330',)) The odd thing is that I can do these queries via mysql command line, even when running mysql on the webserver to connect to the DB host, and they return instantly... although I guess I'm not sure if the assertion error comes from MySQL or is part of web2py's DB adapter? We used wireshark to determine that the TCP packets were being incessantly retransmitted ... but only sometimes. The Padding/Assertion Errors seem to be related to VMs since migrating the machine to a different physical host and back resolves the issue immediately. Also, restarting httpd tends to lessen the amount of Broken Pipe errors I see, so perhaps it's some sort of stale connection to the DB? -Abe On Thursday, July 12, 2012 2:02:01 PM UTC-5, Marcello wrote: Hello, I'm having Connection timed out to mysql server. I'm creating a sheet from some queries. The function is in a module, and running it from console. Sometimes, it goes OK, but sometimes I get the error (see below). I'm using EC2 and the database is in RDS. Thanks for any help... Marcello - Traceback (most recent call last): File /home/tecno2/web2py/gluon/shell.py, line 206, in run execfile(startfile, _env) File applications/segundarj/private/diario.py, line 2, in module planilha.roda(True) File applications/segundarj/modules/planilha.py, line 64, in roda print aba: %s, total: %s % (aba,processos.count()) File /home/tecno2/web2py/gluon/dal.py, line 7573, in count return self.db._adapter.count(self.query,distinct) File /home/tecno2/web2py/gluon/dal.py, line 1339, in count self.execute(self._count(query, distinct)) File /home/tecno2/web2py/gluon/dal.py, line 1392, in execute return self.log_execute(*a, **b) File /home/tecno2/web2py/gluon/dal.py, line 1386, in log_execute ret = self.cursor.execute(*a, **b) File /home/tecno2/web2py/gluon/contrib/pymysql/cursors.py, line 108, in execute self.errorhandler(self, exc, value) File /home/tecno2/web2py/gluon/contrib/pymysql/connections.py, line 182, in defaulterrorhandler raise Error(errorclass, errorvalue) Error: (class 'socket.error', error(110, 'Connection timed out')) Traceback (most recent call last): File web2py.py, line 20, in module gluon.widget.start(cron=True) File /home/tecno2/web2py/gluon/widget.py, line 868, in start import_models=options.import_models, startfile=options.run) File /home/tecno2/web2py/gluon/shell.py, line 210, in run if import_models: BaseAdapter.close_all_instances('rollback') File /home/tecno2/web2py/gluon/dal.py, line 432, in close_all_instances getattr(instance, action)() File /home/tecno2/web2py/gluon/dal.py, line 1357, in rollback return self.connection.rollback() File /home/tecno2/web2py/gluon/contrib/pymysql/connections.py, line 571, in rollback self.errorhandler(None, exc, value) File /home/tecno2/web2py/gluon/contrib/pymysql/connections.py, line 182, in defaulterrorhandler raise Error(errorclass, errorvalue) gluon.contrib.pymysql.err.Error: (class 'socket.error', error(32, 'Broken pipe'))
[web2py] Re: DB query
How about this? db(~db.file.id.belongs(db()._select(db.article_files.files,distinct=True)).delete() On Thursday, 12 July 2012 17:37:11 UTC-5, Athelionas wrote: I have these tables and I'd like to get every file which has no article referred to it so I can delete unused files. What's the simplest way of achieving this? db.define_table('articles', Field('created_on', 'datetime', default = datetime.today (), required = True, notnull = True, requires = [IS_NOT_EMPTY(),IS_DATETIME (format = T('%Y-%m-%d %H:%M:%S'))]), Field('article_teaser_hu', 'text', required = True,notnull = True, requires = IS_NOT_EMPTY()), Field('article_hu', 'text', required = True, notnull = True, requires = IS_NOT_EMPTY()), Field('article_teaser_en', 'text', required = True,notnull = True, requires = IS_NOT_EMPTY()), Field('article_en', 'text', required = True, notnull = True, requires = IS_NOT_EMPTY())) db.define_table('files', Field('original_filename', 'string', required = True,notnull = True), Field('uploaded_file', 'upload', uploadfield = 'uploaded_data', required = True, notnull = True, requires = IS_NOT_EMPTY ()), Field('uploaded_data', 'blob', notnull = True), Field('created_on', 'datetime', notnull = True)) db.define_table('articles_files', Field('articles', db.articles), Field('files', db.files))
Re: [web2py] Re: Web2Py on OpenShift
This is really fantastic! Just went to an OpenShift demo and the first thing I wondered was whether web2py was taking advantage of this service. Just tested it out and works great! Thanks, - Jake On Tue, Jul 3, 2012 at 10:15 PM, Massimo Di Pierro massimo.dipie...@gmail.com wrote: Thank you. This is great. On Friday, 8 June 2012 10:07:39 UTC-5, Andrew wrote: Just FYI to anyone interested, I've put together a web2py template for OpenShift (Red Hat's Opensource PaaS). You can find it here: - https://github.com/prelegalwonder/openshift_web2py I've also put together a basic openshift deployer from the admin page, and you can grab the changes from my fork of web2py - https://github.com/prelegalwonder/web2py It's just 3 files in the admin app: controllers/openshift.py views/openshift/deploy.html and a modification to views/default/site.html It's only requirement to work beyond having a local working openshift project is GitPython installed and accessible from the runtime that web2py is running in. So you can either run the admin app in the cloud and access it directly or run a local web2py instance and execute the deployer when you want to test out your changes. I'm working on a detailed blog that I intent to submit to the OpenShift team so they can put it on their site for getting started. Enjoy
Re: [web2py] Web2Py on Raspberry Pi?
For sure. You can probably run the embedded rocket webserver On Jul 12, 2012 7:29 PM, Ron K Jeffries rjeffr...@gmail.com wrote: Raspberry Pi is an inexpensive $35 ARM based Linux board that has 256MB of RAM and Ethernet as network connectivity. They are shipping in volume, maybe a million by end of 2012. Anybody thinking about trying Web2Py on a Raspberry Pi? I don't have the chops myself. Debian is running fine on it, and that image includes a working Python. So... it needs a web server compiled for ARM, and a database. Anything else? And thoughts on whether 256MB of RAM might work for a lightly-loaded Web2Py server? --ron k jeffries
[web2py] Re: [web2py-dev] Asyncronous Application Sync
On Wednesday, July 11, 2012 6:26:00 PM UTC-4, Massimo Di Pierro wrote: I am planning to improve this functionality but it would help to know if it works for you as it is and what problems you encounter with it. I originally used the export-to-csv, but a few months ago, I switched to just shipping the sqlite files (actually the whole databases directory with .table files); That handles everything like types, blobs, fractional seconds in the database, etc, without any conversion. It is also faster when processing the files at the other end - especially if you have indices and have a non-trivial import requirement. It should be opened with auto_import=True on the receiving end, of course. (you'd still need an export to a new .sqlite database, or use sqlite's backup command, to make sure you get the database in a consistent state -- unless you know that the database is in a fully committed state when you send it). If the connection is not reliable, the classic solution is a queuing system like MSMQ / MQSeries / RabbitMQ (which is often non-trivial to manage), but you could just export (csv, .sqlite, whatever) to a dropbox-or-similar synced directory (e.g. sparkleshare lets you own the repository and not rely on dropbox.com servers), and import it on the server side when the file has changed. much, much simpler and works just as well for one way communication that does not require the lowest possible latency.
[web2py] 'best' way to include a JavaScript file
I want to include a JavaScript file, but only for certain views. What's the best way to include it? Do I have the controller append it to the response.files property? Do I simply use the script with src=... somewhere in the view? Something else?
[web2py] Re: 'best' way to include a JavaScript file
Either method should be fine. Using response.files will result in it being loaded in the head, along with the other JS files. On Thursday, July 12, 2012 10:49:44 PM UTC-4, MichaelF wrote: I want to include a JavaScript file, but only for certain views. What's the best way to include it? Do I have the controller append it to the response.files property? Do I simply use the script with src=... somewhere in the view? Something else?
[web2py] Re: 'best' way to include a JavaScript file
Look at the way index.html (from the welcome app) handles 'message': {{if 'message' in globals():}} h3{{=message}}/h3 I'd suggest you do something similar (although I would do it with the main layout file (presumably layout.html): {{ if additional_js in globals(): }} code to include your JS ref Then in your controller actions make sure you set 'additional_js' in the dict that you pass. Just one suggestion among the many possibilities.. I hope it helps.. On Thursday, July 12, 2012 9:49:44 PM UTC-5, MichaelF wrote: I want to include a JavaScript file, but only for certain views. What's the best way to include it? Do I have the controller append it to the response.files property? Do I simply use the script with src=... somewhere in the view? Something else?
[web2py] Re: 'best' way to include a JavaScript file
The response.files thing has always confused me. I can see using it everywhere except for layout.html where I'd rather insert the files in specific places (for example, not everything should be in the head).