Re: [web2py] Many-to-many relations with CRUD Insert
Yes, thats clear. Until now i use a program, which is based on INFORMIXDB with Python und CGI. In this program (respectively programs) i do exactly that what you described above in your mail. It is not difficult to write these programs but it is slow and boring. But now i know web2py and i wanted to use this tool and all of its benefits to create more elegant forms and views. So my Question is again: Is there any method to create an INPUT-Form (not for output, SELECT is easy!) with CRUD or SQLFORM for the many-to-many Relation book-author-verb? Or more precisely: is it possible to make a form with CRUD or SQLFORM, which includes all fields of book and a listbox with autors, so that i can select one or more authors and then klick the *only *submit-button of the form to insert the book and the corresponding ids in table verb? I think the problem is that we have 2 tables for CRUD/SQLFORM, which are not directly connected via foreign keys (namely book and author).
[web2py] Apache/mod_wsgi: Exposing individual web2py apps alongside other non-web2py services
Hello, I have an Apache server with mod_wsgi, and I would like to host web2py alongside a variety of other things. For example: http://example.com/ hosts a PHP website. Might link to things like / about.php, /users/view.php, etc http://example.com/files a standard Apache listing of files in a directory http://example.com/myapp1 a web2py application named myapp1 http://example.com/myapp2 a web2py application named myapp2 The Apache/mod_wsgi deployment example in the web2py book uses: WSGIScriptAlias / /users/www-data/web2py/wsgihandler.py which effectively causes web2py to take over the root of the URL hierarchy. In that case, http://example.com/myapp1 http://example.com/myapp2 work as expected, but you've locked yourself out of serving any non- web2py content on the server. My workaround was to do this: WSGIScriptAlias /web2py /users/www-data/web2py/wsgihandler.py to get web2py content namespaced under /web2py, and then use mod_rewrite to create nicer URLs into the /web2py location; e.g.: RewriteRule ^/myapp1(/.*)?$ /web2py/myapp1$1 [PT,L] However, now the app is accessible through two URLs: http://example.com/myapp1 or http://example.com/web2py/myapp1. Moreover, any of my web2py applications are accessible via /web2py/[appname] even if I only want to expose a select few applications on a particular server. I can restrict which applications are accessible via something like: Location /web2py Order Allow,Deny Deny from all /Location and then explicitly allow only those apps I want to expose. Then I can (sort of) get rid of the redundant /web2py/[appname] URL with something like: RewriteRule ^/web2py/myapp1 /myapp1 [R,L] but now it seems like we've gone to a lot of work to accomplish a fairly simple task. Is anyone aware of a cleaner way to expose one or a few web2py apps without lettings web2py take over the entire root URL namespace? Thanks, Kevin
Re: [web2py] Many-to-many relations with CRUD Insert
On 17 January 2012 11:03, Christian Winterhager christian.winterha...@onlinehome.de wrote: Yes, thats clear. Until now i use a program, which is based on INFORMIXDB with Python und CGI. In this program (respectively programs) i do exactly that what you described above in your mail. It is not difficult to write these programs but it is slow and boring. But now i know web2py and i wanted to use this tool and all of its benefits to create more elegant forms and views. So my Question is again: Is there any method to create an INPUT-Form (not for output, SELECT is easy!) with CRUD or SQLFORM for the many-to-many Relation book-author-verb? Or more precisely: is it possible to make a form with CRUD or SQLFORM, which includes all fields of book and a listbox with autors, so that i can select one or more authors and then klick the *only *submit-button of the form to insert the book and the corresponding ids in table verb? I think the problem is that we have 2 tables for CRUD/SQLFORM, which are not directly connected via foreign keys (namely book and author). In the 'verb' table you can use the type 'reference' for 'book' and 'list:reference' for authors (with the multiple-option). Then you can have a form using crud for input where you can select the book and the list of authors. See http://www.web2py.com/books/default/chapter/29/6?search=list%3Areference . I am working with a biliometric database and I have inserted constraints on database level to prevent the same combination of appearing in the linking table ('verb' in your case). I am working with Postgresql and found that the web2py-communications with the database breaks when this constraint complains. So I had to build in code to check for the existence of that combination of fields in the table before inserting it. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
Re: [web2py] Many-to-many relations with CRUD Insert
On 17 January 2012 11:27, Johann Spies johann.sp...@gmail.com wrote: I am working with a biliometric database Sorry that must be bibliometric database -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Skype Integration
Hi, I want to integrate skype in my web2py application. I have skypekit downloaded from skype.com. But it gives error : SSLError:ssl read operation timed out detailed stack trace: Traceback (most recent call last): File /usr/lib/python2.6/threading.py, line 532, in __bootstrap_inner self.run() File applications/filem/modules/skypekit_mod/ipc/python/ skypekit.py, line 143, in run self.connection._start() File applications/filem/modules/skypekit_mod/ipc/python/ skypekit.py, line 521, in _start if self._read_byte(1) == 'Z': File applications/filem/modules/skypekit_mod/ipc/python/ skypekit.py, line 236, in _read_byte read = self.socket.recv(4096) File /usr/lib/python2.6/ssl.py, line 215, in recv return self.read(buflen) File /usr/lib/python2.6/ssl.py, line 136, in read return self._sslobj.read(len) SSLError: The read operation timed out please Help.. Thank You.
[web2py] Re: book 4th edition in PDF
Thanks for writing the book. Concerning payment, i couldn´t find any information about stripe on your page, so i googled them and validated them at visa. I can imagine more people wouldn´t just trust their creditcard details to a form not knowing what system is handling the details and where it´s stored an so forth. Will buy the book now - trying.. Regards, Remco Boerma, the Netherlands
[web2py] Re: book 4th edition in PDF
Works, mastercard
[web2py] Re: Links to referencing records - type 'exceptions.AttributeError' 'str' object has no attribute 'ignore_common_filters'
Hi!!! I made a modifications in my script: def list_records(): expresion = 'list_records' table = request.args(0) query = request.vars.query pos = query.find(expresion) if pos = 0: pos = pos + len(expresion) query= query[pos:] q = db(query) records = q.select() else: records = T('record does not exist') return dict(records=records,table=pos,query=query) But I get the same error: type 'exceptions.AttributeError' 'str' object has no attribute 'ignore_common_filters' Is there other posibility to implement a relation master-detail?. Thanks for your time. On 14 ene, 20:16, Alan Etkin spame...@gmail.com wrote: def list_records(): table = request.args(0) query = request.vars.query records= db(query).select(db[table]) return dict(records=records,table=table,query=query) the fourth line passes a string to the db instance call that expects a query object as those created with this statement: q = db.mytable.myfield.id == number Maybe you can do new_query = eval(q) to create the normal db call input. The admin interface does something similar (i don't know if it uses eval) as it processes queries sent by browser user input.
Re: [web2py] Represent - redirect
Thanks !! Op 17 januari 2012 00:44 schreef Anthony abasta...@gmail.com het volgende: On Monday, January 16, 2012 4:47:01 PM UTC-5, Mathias Van Daele wrote: Thanks for answer Johann. But how can I catch the value of args in the concerned function ? args from the URL are always in request.args, so in the edit_akb_country() function, the id would be in request.args(0). See http://web2py.com/books/default/chapter/29/4#Dispatching. Anthony
[web2py] Re: DAL IMAPAdapter
I am about to send a new diff to the issues list for IMAPAdapter: Added a new static field size to limit size in queries or filter message sizes Possible query commands will be: db.table.size 3 (to fetch only messages smaller than 3 octets) db.table.size 1000 (fetch only large messages) # this is a very risky query for requests could lock the server and client in long sessions (db.mailbox.size n) (db.mailbox.size n) # low/high bounds search There is a new working connection pooling mechanism (overriding the base class) that checks the connection and re-connects on socket errors I think that mail search and fetch is more or less accomplished (requires more intensive testing with different IMAP services) Next features in the list pending: -update() command (for flags and other editable elements) -delete()
[web2py] Ckeditor Crud Controller Problem
Hello I am having a problem with CKEditor in Crud I get the following error when I try to use it Traceback (most recent call last): File /opt/web2py/gluon/restricted.py, line 192, in restricted exec ccode in environment File /opt/web2py/applications/pstv/controllers/control_panel.py https://www.paradigmshift.tv/admin/edit/pstv/controllers/control_panel.py, line 158, in module File /opt/web2py/gluon/globals.py, line 145, in lambda self._caller = lambda f: f() File /opt/web2py/gluon/tools.py, line 2499, in f return action(*a, **b) File /opt/web2py/applications/pstv/controllers/control_panel.py https://www.paradigmshift.tv/admin/edit/pstv/controllers/control_panel.py, line 28, in contributions db.contrib.contributions = advanced_editor File /opt/web2py/gluon/dal.py, line 4735, in __setattr__ raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: contributions It works perfectly fine in another function that is pretty much the same thing. I have posted the code below hoping some one can shed a light on this. DAL code db.define_table('contrib', Field('userinfo', db.auth_user, default=auth.user_id, readable=False, writable=False), Field('title'), Field('contributions','text',requires=IS_NOT_EMPTY())) Controller Code @auth.requires_membership('admin') def contributions(): db.contrib.contributions = advanced_editor form = crud.update(db.contrib,1,deletable=False,next=URL('control_panel','contributions')) #response.flash = 'You have successfully updated your Contributions page' return dict(form=form) Editor code in db.py def advanced_editor(field, value): return TEXTAREA(_id = str(field).replace('.','_'), _name=field.name, _class='text ckeditor', value=value, _cols=80, _rows=10) and the view {{extend 'cpanel.html'}} h1Easily update your Contributions page!/h1 {{=form}} I have another bit of code which is basically the same as this. and it works great Any ideas greatly appreciated *cheers Thank You
[web2py] Re: Ckeditor Crud Controller Problem
db.define_table('contrib', Field('userinfo', db.auth_user, default=auth.user_id, readable=False, writable=False), Field('title'), Field('contributions','text',requires=IS_NOT_EMPTY())) Controller Code @auth.requires_membership('admin') def contributions(): db.contrib.contributions = advanced_editor db.contrib.contributions is a Field object that is part of the contrib table -- you cannot (and do not want to) replace it. Perhaps you're trying to set the field's widget: db.contrib.contributions.widget = advanced_editor This can also be done in the field's initial definition: db.define_table('contrib', Field('contributions', ..., widget=advanced_editor)) See http://web2py.com/books/default/chapter/29/7#Widgets. Anthony
[web2py] UnicodeEncodeError on GAE
Hi! I'm web2py and python newbie. I like web2py! But recently I have a problem on GAE. I encounterd UnicodeEncodeError on GAE when I update a field value of one table on appadmin. The table has a list:string field. I suspect that cause is list:string field. File gluon\html.py, line 1585, in _postprocessing _value = str(self['_value']) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) web2py version is 1.99.4 I found similar case. But it seems not to match with my problem. http://groups.google.com/group/web2py/browse_thread/thread/a14bb4b530e3767e I confirmed type(self['_value']). in case of string, it is 'str'. in case of list:stirng, it is 'unicode'. I tried below but don't go good. (dev_appserver OK. GAE NG) if isinstance(self['_value'],unicode): _value = self['_value'].encode('utf-8') else: _value = str(self['_value']) I don't know how to fix this... (I can't see detail of error of ticket on GAE Data viewer... only like this dp0 S'output' p1 Stype 'exceptions.UnicodeEncodeError' 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) p2 sS'layer' p3 ) Could Anyone help me?
[web2py] Re: Links to referencing records - type 'exceptions.AttributeError' 'str' object has no attribute 'ignore_common_filters'
I made a modifications in my script: def list_records(): expresion = 'list_records' table = request.args(0) query = request.vars.query pos = query.find(expresion) if pos = 0: pos = pos + len(expresion) query= query[pos:] q = db(query) records = q.select() else: records = T('record does not exist') return dict(records=records,table=pos,query=query) But I get the same error: type 'exceptions.AttributeError' 'str' object has no attribute 'ignore_common_filters' Same problem -- in db(query), query must be a Query object, but in your case it is just a string. You would have to do something like db(eval(query)), but that would be a security risk because you don't know what is in query. Instead, it's probably safer to parse the query itself and look for the table and id in the query -- confirm the table exists in db, and then build the actual query yourself. Anthony
Re: [web2py] Many-to-many relations with CRUD Insert
I have also constraints on database level, but this is necessary for normal logical consistency of the database model. The problem is for me again - even if i use that reference or list.reference - that i cannot have * ONLY* these fields book.title author.name in my form on the screen and *only one submit-Button*, because CRUD accepts only one table and so there were 2 submit-buttons and 2 CRUD.create forms. As i said i want to insert the book-data (for simplicity here the title) without clicking the submit button, then select some author (better: one or more authors), then click submit, and the web2py-System must then insert the book, look for the new book-id and insert this book-id together with the author-id in the connection-table verb. On a very low-level programming view with CGI, Python and informix (or just MySQL) this can be done without great effort, but you have to write too much code. That is the reason why i want to have a simple form, created by CRUD or SQLFORM. By the way, i searched the Newsgroup here and i did'nt find anyone, who had this same problem. I'm wondering about that, because it is a standard situation in many commercial databases: you have producers and articles, but the connection between the two ist stored in a new table- say prod_art in form of a tupel (producer_id, article_id). How to put Producer-, Article-Data and informations about who produces which article (Table prod_art) in only one FORM with only ONE Submit Button? P.S. Naturally i have one solution, but i think it is a dirty one: 1. With CRUD make 2 INSERT-Forms for tables author and book. 2. If FORM for the book is accepted, and we therefor know the new book_id. 3. go to the NEXTURL, i.e. the CRUD.create - FORM for the table verb 4. In the Controller, before accepting the form, let verb.book_id = book_id from step 2. 5. Choose an author from the table verb. Thanks to this CRUD-Feature! 6. Insert verb. Thats all, but it is too complicated for Users, wo want to insert thousends of Books: 2 Screen, 2 Submit-Buttons, switching between the screens. As in said, i build a very user-friendly solution with CGI, but i think, it must be done also with web2py
[web2py] Re: Many-to-many relations with CRUD Insert
This might give you some ideas: http://web2py.com/books/default/chapter/29/7#One-form-for-multiple-tables. I suppose you would have to loop through the list of submitted authors to insert multiple records into the verb table. Anthony On Monday, January 16, 2012 3:35:16 PM UTC-5, Christian Winterhager wrote: One of the standard examples of many-to-many Relations is a library. For simplicity i choose only 3 Tables: db.define_table ('author', Field ('name', 'string', length=100)) db.define_table ('verb', Field ('bnr', db.book ), Field ('anr', db.author ), ) db.define_table ('book', Field('title', 'string', length=250)) It is very easy to insert a new book, one or more author and the corresponding record in the table verb. But i found no way to insert a book with the CRUD-Method. The complexityhttp://dict.leo.org/ende?lp=endep=DOKJAAsearch=complexitytrestr=0x8001 is that i first must insert a row into table book, then one into table author and last i have to connect the inserted rows with the corresponding numbers 'bnr' and 'anr' in table verb. Does anyone know if there is a way to do that with CRUD?
[web2py] Re: Question about many to many forms
Check out SQLFORM.smartgrid http://web2py.com/books/default/chapter/29/7#SQLFORM.grid-and-SQLFORM.smartgrid-%28experimental%29 Also the image blog example gives a viable approach, though the relationship is one-to-many http://web2py.com/books/default/chapter/29/3#An-image-blog Also I think you could use components: http://web2py.com/books/default/chapter/29/12 On Jan 16, 5:34 am, Thiago Magro thiago.ma...@gmail.com wrote: Hello everyone, I have a question with forms for many to many relations and I just cant find the answer. Its possible to have forms inside forms? For example: I have a model Food that has inside a lot of components(nutrients). So Food has many components. Is there any chances that I could create a form for a food, and on the same form create a lot of subforms to create each food component as well? And going further, is it possible to edit a food and its components on the same form? What I looking for is something like acccept_nested_attributes from Rails. Thanks for any help! Thiago
[web2py] Re: Links to referencing records - type 'exceptions.AttributeError' 'str' object has no attribute 'ignore_common_filters'
Ok, Thanks a lot. On 17 ene, 11:00, Anthony abasta...@gmail.com wrote: I made a modifications in my script: def list_records(): expresion = 'list_records' table = request.args(0) query = request.vars.query pos = query.find(expresion) if pos = 0: pos = pos + len(expresion) query= query[pos:] q = db(query) records = q.select() else: records = T('record does not exist') return dict(records=records,table=pos,query=query) But I get the same error: type 'exceptions.AttributeError' 'str' object has no attribute 'ignore_common_filters' Same problem -- in db(query), query must be a Query object, but in your case it is just a string. You would have to do something like db(eval(query)), but that would be a security risk because you don't know what is in query. Instead, it's probably safer to parse the query itself and look for the table and id in the query -- confirm the table exists in db, and then build the actual query yourself. Anthony
[web2py] Re: DAL IMAPAdapter
The new version of the adapter with fixes and size queries http://code.google.com/p/web2py/issues/detail?id=610#c4
Re: [web2py] Re: There is no web2py homebrew for OS X
The pypi repo must be the defeault form of install web2py is cross platform, and easy to use. 2012/1/17 pbreit pbreitenb...@gmail.com Might not be a bad idea but it's way better to install Web2py from source. Then you have excellent version control. -- Alvaro Lizama Molina - http://alvarolizama.net
[web2py] too short - password error not proper case.
Not a biggie, but it seems strange that the auth table generates too short error message It seems all the other messages seem proper case like Cannot be empty this should be changed to Too short for consistency
[web2py] Re: Many-to-many relations with CRUD Insert
Antony, thank you, i tried exactly this some weeks ago and it did not work. Since now... may be, that i worked not enough. I will try more and we will see.
[web2py] jQuery UI modal form dialog and user function.
I would like the default/user function's view default/user.html to open in a modal form dialog as in jQuery UI: http://jqueryui.com/demos/dialog/#modal-form Does one of you have example of how to get this to work? Kind regards, Annet.
[web2py] Re: Many-to-many relations with CRUD Insert
Anthony, the basic recommendation was to use SQLFORM.factory, and that was a good idea. I tried it again and i had now more success than some weeks before. So now i can insert rows in the table book and the table verb in one FORM and with only one submit-button. The FORM looks like this: form=SQLFORM.factory(db.book, db.verb.anr) if form.process().accepted: id = db.book.insert(**db.book._filter_fields(form.vars)) db.commit() booknumber = id authornumber = form.vars.anr id = db.verb.insert(bnr=booknumber,anr=authornumber) db.commit() response.flash='Bingo!' It looks very good but you know, if you have succesfully finished a job, you find some other problems...
Re: [web2py] Re: Ckeditor Crud Controller Problem
*cheers I must of been blind not to see that last night ty very much On Tue, Jan 17, 2012 at 5:51 AM, Anthony abasta...@gmail.com wrote: db.define_table('contrib', Field('userinfo', db.auth_user, default=auth.user_id, readable=False, writable=False), Field('title'), Field('contributions','text',**requires=IS_NOT_EMPTY())) Controller Code @auth.requires_membership('**admin') def contributions(): db.contrib.contributions = advanced_editor db.contrib.contributions is a Field object that is part of the contrib table -- you cannot (and do not want to) replace it. Perhaps you're trying to set the field's widget: db.contrib.contributions.widget = advanced_editor This can also be done in the field's initial definition: db.define_table('contrib', Field('contributions', ..., widget=advanced_editor)) See http://web2py.com/books/default/chapter/29/7#Widgets. Anthony
[web2py] Python / web2py or.... the learning path?
Do you think that someone with basic knowledge of programming (a little theoretical knowledge of languages like python, javascript and c), could have a chance to start learning web programming language using python and web2py framework? I'm not talking about the understanding of language syntax, but more about the programming, mechanisms understanding which explain what is happening behind a website. Are there any good sources of knowledge, which explains all these basic things in a simple way... of course, using python and web2py framework? Many says, that PHP is better choice, because have many sources that explain a beginner programmer all the important mechanisms what is going on behind the website and so on. Also, you can become productive fairly rapidly. What would you say? What is your expiriens?
[web2py] Re: Help with OAuth20 facebook infinite redirect
Hello, Do you mind sharing what facebook app you switched too? I was writing FB apps in PHP but I want to switch to web2py so I am looking for a nice working base app to start with to create both canvas apps and tab page apps. Any links you can point me too would be appreciated. I have found 3-4 python examples but not necessarily for web2py and the web3py examples are either outdated, do not work or do not have enough detail for me to create something that works. Thanks, Ben
[web2py] Guidence on using web2py for a facebook canvas app or tab page app
Hello, I have developed a few apps for facebook using PHP but I really want switch future development to web2py. I have not found any good updated base facebook web2py apps to start from. A lot of the FB python code I have found applies to Django or assumes you will be using google app engine which I am not. I have created modules and tried 3 versions of a facebook.py file I have found 1) https://github.com/pythonforfacebook/facebook-sdk 2) The order code from the hellowfacebook web2py example 3) https://github.com/facebook/fbconsole I have included the Javascript SDK in my web2py view found here. https://developers.facebook.com/docs/reference/javascript/ Since I understand it is best to set and grab cookies and initiate a login and session with the JS SDK I also tried mods of recommend code here but can't get it to work either. http://stackoverflow.com/questions/2727118/getting-facebook-oauth-access-token-through-python-sdk-does-not-seem-to-be-worki I am still new to web2py so maybe I have something in the wrong place or have not declared or imported things properly. in my default.py I can import any facebook module code I use with import facebook But where do I put this code that actually calls the defs and objects? in my controller? another module or view? cookie = facebook.get_user_from_cookie(self.request.cookies, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET) graph = facebook.GraphAPI(cookie[access_token]) current_user = graph.get_object(me) So my questions are... 1) Is there a base application with up-to-date code I can use to create a FB canvas or tab page app that creates a link for a user to login, let's me grab the cookie/access token from the JS SDK and pull some info from the FB graph api. 2) which python FB classes or API or SDK should I use and import to best use with web2py. 3) where is the best place to place the code that calls the facebook class defs and methods? In a controller, controller def, module or view? Thanks for any input. Ben
[web2py] Re: Python / web2py or.... the learning path?
web2py was originally created as a teaching tool -- I think you'll find it relatively easy to learn web programming with web2py, especially if you have some programming experience. The book (http://web2py.com/books/default/chapter/29) is a great learning resource. For a general understanding of how things work, check out the Introduction, Overview, http://web2py.com/books/default/chapter/29/4#Workflow, and http://web2py.com/books/default/chapter/29/4#Dispatching. Another new (partially complete) learning resource for beginners is http://killer-web-development.com/. Anthony On Tuesday, January 17, 2012 10:38:17 AM UTC-5, Artur wrote: Do you think that someone with basic knowledge of programming (a little theoretical knowledge of languages like python, javascript and c), could have a chance to start learning web programming language using python and web2py framework? I'm not talking about the understanding of language syntax, but more about the programming, mechanisms understanding which explain what is happening behind a website. Are there any good sources of knowledge, which explains all these basic things in a simple way... of course, using python and web2py framework? Many says, that PHP is better choice, because have many sources that explain a beginner programmer all the important mechanisms what is going on behind the website and so on. Also, you can become productive fairly rapidly. What would you say? What is your expiriens?
[web2py] Working XMLRPC code failing on new web2py version ?...
Hi, I have this very old web2py app that has been working 24/7 since early 2008... One instance runs on my phone (Nokia N900, a Linux device), another on my home server (also Linux). The mobile instance frequently pushes database records to the server instance, using XMLRPC, by calling the relevant method on the remote, something like : client = xmlrpclib.ServerProxy(target+'/current/handle', allow_none=True) rows = db(db.current.id0).select() status, response.flash = client.accept(rows.colnames, rows.response) This has been running flawlessly for four years, although both ends have sometimes been upgraded : * the mobile instance runs a semi-recent version of web2py (1.94.5) on an old version of Python (2.5.4) * the server instance does the opposite (Python 2.7 and web2py 1.56.1 !) * so this is a fairly change-resistant combination so far... However, today I tried the latest web2py (1.99.4), because I wanted to host the mobile instance on an Android phone. After fighting my way through Android and SL4A to the underlying Linux core, I got it to run nicely, except for that push code above, which fails on the third line with : TypeError: cannot marshal type 'datetime.date' objects Now, obviously, one of the columns in rows.response contains a datetime.date value. But why is this suddenly a problem ? I moved the whole thing to a Windows box (with Python 2.6.5) and got the same result. Could this be caused by the newer version of web2py ? Where to start looking ? Thanks for any ideas, fp
[web2py] Re: jQuery UI modal form dialog and user function.
In user.html add lines: link href=http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/ themes/{{=response.theme or smoothness}}/jquery-ui.css rel=stylesheet type=text/css / script src=http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/ jquery-ui.min.js type=text/javascript/script script language=javascript $(document).ready(function(){ $('#web2py_user_form').dialog({autoOpen : true, modal : true, width : 'auto'}); }) /script change line: div id=web2py_user_form style='display:none' On Jan 17, 5:56 pm, Annet anneve...@googlemail.com wrote: I would like the default/user function's view default/user.html to open in a modal form dialog as in jQuery UI:http://jqueryui.com/demos/dialog/#modal-form Does one of you have example of how to get this to work? Kind regards, Annet.
[web2py] Re: Proposal for SQLFORM.grid
Please open ticket and I will add this tonight On Jan 16, 11:58 pm, Martin Weissenboeck mweis...@gmail.com wrote: Hi! grid generats SQLFORMs for 'new', 'view' and 'edit'. But only the first propagates the parameter formstyle from the constructor: Line 1550 ('new'): create_form = SQLFORM( table, ignore_rw = ignore_rw, formstyle = formstyle, There is no formstile in line 1566 ('view') form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, readonly=True,_class='web2py_form') and line 1578 ('edit') edit_form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, deletable=deletable, Proposal: change to form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, *formstyle = formstyle, * readonly=True,_class='web2py_form') and edit_form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, *formstyle = formstyle,* deletable=deletable, Regards, Martin
[web2py] Re: Skype Integration
can you show any code? On Jan 17, 4:17 am, ganesh waghmare ganeshwaghmar...@gmail.com wrote: Hi, I want to integrate skype in my web2py application. I have skypekit downloaded from skype.com. But it gives error : SSLError:ssl read operation timed out detailed stack trace: Traceback (most recent call last): File /usr/lib/python2.6/threading.py, line 532, in __bootstrap_inner self.run() File applications/filem/modules/skypekit_mod/ipc/python/ skypekit.py, line 143, in run self.connection._start() File applications/filem/modules/skypekit_mod/ipc/python/ skypekit.py, line 521, in _start if self._read_byte(1) == 'Z': File applications/filem/modules/skypekit_mod/ipc/python/ skypekit.py, line 236, in _read_byte read = self.socket.recv(4096) File /usr/lib/python2.6/ssl.py, line 215, in recv return self.read(buflen) File /usr/lib/python2.6/ssl.py, line 136, in read return self._sslobj.read(len) SSLError: The read operation timed out please Help.. Thank You.
[web2py] Re: Working XMLRPC code failing on new web2py version ?...
Please open a ticket. What's the latest version that worked? Can you show how you expose the service? On Jan 17, 1:49 pm, fpp fpp@gmail.com wrote: Hi, I have this very old web2py app that has been working 24/7 since early 2008... One instance runs on my phone (Nokia N900, a Linux device), another on my home server (also Linux). The mobile instance frequently pushes database records to the server instance, using XMLRPC, by calling the relevant method on the remote, something like : client = xmlrpclib.ServerProxy(target+'/current/handle', allow_none=True) rows = db(db.current.id0).select() status, response.flash = client.accept(rows.colnames, rows.response) This has been running flawlessly for four years, although both ends have sometimes been upgraded : * the mobile instance runs a semi-recent version of web2py (1.94.5) on an old version of Python (2.5.4) * the server instance does the opposite (Python 2.7 and web2py 1.56.1 !) * so this is a fairly change-resistant combination so far... However, today I tried the latest web2py (1.99.4), because I wanted to host the mobile instance on an Android phone. After fighting my way through Android and SL4A to the underlying Linux core, I got it to run nicely, except for that push code above, which fails on the third line with : TypeError: cannot marshal type 'datetime.date' objects Now, obviously, one of the columns in rows.response contains a datetime.date value. But why is this suddenly a problem ? I moved the whole thing to a Windows box (with Python 2.6.5) and got the same result. Could this be caused by the newer version of web2py ? Where to start looking ? Thanks for any ideas, fp
Re: [web2py] Re: Python / web2py or.... the learning path?
Absolutelly YES! I teach web2py in my course http://cursodepython.com.br the great part of audience is beginners also in web and programming, with Python it is very easy to learn O.O and web2py makes very easy to understand web workflow. * I am making some tests, may be my course will be recorded in english too. On Tue, Jan 17, 2012 at 5:46 PM, Anthony abasta...@gmail.com wrote: web2py was originally created as a teaching tool -- I think you'll find it relatively easy to learn web programming with web2py, especially if you have some programming experience. The book ( http://web2py.com/books/default/chapter/29) is a great learning resource. For a general understanding of how things work, check out the Introduction, Overview, http://web2py.com/books/default/chapter/29/4#Workflow, and http://web2py.com/books/default/chapter/29/4#Dispatching. Another new (partially complete) learning resource for beginners is http://killer-web-development.com/. Anthony On Tuesday, January 17, 2012 10:38:17 AM UTC-5, Artur wrote: Do you think that someone with basic knowledge of programming (a little theoretical knowledge of languages like python, javascript and c), could have a chance to start learning web programming language using python and web2py framework? I'm not talking about the understanding of language syntax, but more about the programming, mechanisms understanding which explain what is happening behind a website. Are there any good sources of knowledge, which explains all these basic things in a simple way... of course, using python and web2py framework? Many says, that PHP is better choice, because have many sources that explain a beginner programmer all the important mechanisms what is going on behind the website and so on. Also, you can become productive fairly rapidly. What would you say? What is your expiriens? -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] how to remove duplicate tables in smartgrid?
My problem is similar: At first there is the table of persons auth_user with some additional fields like a phone number and so on. Now one persons (A) writes something concerning another person (B). Let's sove it with a table db.define_table('report', Field('from_person', 'reference auth_user'), Field('about_person', 'reference auth_user'), Field('text'), singular='REPORT', plural='REPORTS') A SQLFORM.smartgrid(db.auth_user, linked_tables=['report']) shows a grid with two REPORTS-buttons: Report Auth users http://127.0.0.1:8000/smartgridtest2/default/report/auth_user Addhttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/new/auth_user Exporthttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/csv?keywords= 2 records found Idhttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user?keywords=order=auth_user.id First namehttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user?keywords=order=auth_user.first_name Last namehttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user?keywords=order=auth_user.last_name E-mailhttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user?keywords=order=auth_user.email 1 jim smith j...@smith.com REPORTShttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/report.from_person/1 REPORTShttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/report.about_person/1 Viewhttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/view/auth_user/1 Edithttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/edit/auth_user/1 Delete http://127.0.0.1:8000/smartgridtest2/default/report#null 2 joesmith j...@smith.com REPORTShttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/report.from_person/2 REPORTShttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/report.about_person/2 Viewhttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/view/auth_user/2 Edithttp://127.0.0.1:8000/smartgridtest2/default/report/auth_user/edit/auth_user/2 Delete http://127.0.0.1:8000/smartgridtest2/default/report#null But the first button is not necessary, because the from_user is the current user. *Is it possible to remove (only) the first button?* I have tried the parameter links to create my own button. It works, but the two REPORTS remain. links_in_grid = True removes every button. Maybe it would be better if links_in_grid switches off only the default buttons? If somebody wants to try it - this is my controller: def report(): grid = SQLFORM.smartgrid(db.auth_user, linked_tables=['report'], user_signature = False) return locals() By the way: there is always the plural form - what is the condition to display the singular form? Regards, Martin 2011/12/26 Jim Gregory bikesatw...@gmail.com I am creating an application that has a one-to-many table that references the same table twice: db.define_table('product', Field('title', required=True, unique=True), Field('sku', required = True, unique=True), Field('description', 'text'), format = '%(title)s' ) db.define_table('related_product', Field('product_id', db.product, writable=False), Field('product', 'reference product'), ) If I create a smartgrid on the 'product' table using: def product(): return dict(grid=SQLFORM.smartgrid( db.product, linked_tables=['related_product'], )) the related_product table appears twice because it references the product table twice. Any way to prevent this? -Jim
Re: [web2py] Re: Proposal for SQLFORM.grid
Done. 2012/1/17 Massimo Di Pierro massimo.dipie...@gmail.com Please open ticket and I will add this tonight On Jan 16, 11:58 pm, Martin Weissenboeck mweis...@gmail.com wrote: Hi! grid generats SQLFORMs for 'new', 'view' and 'edit'. But only the first propagates the parameter formstyle from the constructor: Line 1550 ('new'): create_form = SQLFORM( table, ignore_rw = ignore_rw, formstyle = formstyle, There is no formstile in line 1566 ('view') form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, readonly=True,_class='web2py_form') and line 1578 ('edit') edit_form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, deletable=deletable, Proposal: change to form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, *formstyle = formstyle, * readonly=True,_class='web2py_form') and edit_form = SQLFORM(table,record,upload=upload,ignore_rw=ignore_rw, *formstyle = formstyle,* deletable=deletable, Regards, Martin
[web2py] Need help with drag-n-drop using jQuery
I'm prototyping a scheduling board with drivers in the columns and their deliveries in the rows to prove that I can reassign deliveries using drag-n-drop under web2py. I have developed a matrix of movable cells that I based on Massimo's Excel Spreadsheet module. I can drag-n-drop cells just fine, but the performance is hideous. The drop takes 10 seconds typically. I must be missing some configuration item or something; I just can't make the thing work with a speed that will interest my boss. Can anyone suggest where I might look to make things snappy? My code is simple and short ( 200 LOC). Might it have anything to do with the ram-cache? I appreciate any help you can offer to get me moving again (and to escape being forced to develop our board on Alpha5 or Servoy instead). Thanks in advance.
Re: [web2py] Guidence on using web2py for a facebook canvas app or tab page app
Hello Ben, Take a look at this simple example app http://goo.gl/6tXxs http://code.google.com/r/michelecomitini-facebookaccess/source/browse/applications/#applications%2FhelloFacebook Web2py comes with support for oauth2.0 (for facebook auth) included, so take some time to understand how web2py works creating a simple app that requires authentication, read the web2py book on how to do it. Then copy the code from the app above to make your facebook app. It is much simpler than what you think... mic 2012/1/17 Ben Tammetta b...@clubelite.com: Hello, I have developed a few apps for facebook using PHP but I really want switch future development to web2py. I have not found any good updated base facebook web2py apps to start from. A lot of the FB python code I have found applies to Django or assumes you will be using google app engine which I am not. I have created modules and tried 3 versions of a facebook.py file I have found 1) https://github.com/pythonforfacebook/facebook-sdk 2) The order code from the hellowfacebook web2py example 3) https://github.com/facebook/fbconsole I have included the Javascript SDK in my web2py view found here. https://developers.facebook.com/docs/reference/javascript/ Since I understand it is best to set and grab cookies and initiate a login and session with the JS SDK I also tried mods of recommend code here but can't get it to work either. http://stackoverflow.com/questions/2727118/getting-facebook-oauth-access-token-through-python-sdk-does-not-seem-to-be-worki I am still new to web2py so maybe I have something in the wrong place or have not declared or imported things properly. in my default.py I can import any facebook module code I use with import facebook But where do I put this code that actually calls the defs and objects? in my controller? another module or view? cookie = facebook.get_user_from_cookie(self.request.cookies, FACEBOOK_APP_ID, FACEBOOK_APP_SECRET) graph = facebook.GraphAPI(cookie[access_token]) current_user = graph.get_object(me) So my questions are... 1) Is there a base application with up-to-date code I can use to create a FB canvas or tab page app that creates a link for a user to login, let's me grab the cookie/access token from the JS SDK and pull some info from the FB graph api. 2) which python FB classes or API or SDK should I use and import to best use with web2py. 3) where is the best place to place the code that calls the facebook class defs and methods? In a controller, controller def, module or view? Thanks for any input. Ben
[web2py] Re: Python / web2py or.... the learning path?
There are indeed a *lot* of PHP tutorials and articles out there. Most of them are of little value in general, or even misleading readers into bad practices (as referenced by Christian Heilmann in a recent post on Smashing Magazinehttp://www.smashingmagazine.com/2011/12/27/hitting-the-ground-running-along-with-faceplant/). However, most of the *best *PHP sources will teach you web-development techniques that you can do in Python (or more precisely, are already easy for you to implement in web2py). As a developer who is also growing in my understanding of the best practices, I recommend you look around as much as you can for great articles on best practices. I have learned a lot from the following places: - A List Apart http://www.alistapart.com/ - I would *start off here*. In general, their articles do a great job of establishing practices you want to emulate. - Smashing Magazine http://www.smashingmagazine.com/ - They post one article a day, and the quality varies significantly, so be vigilant. Most articles focus on front-end and trending topics in web design. - Smashing Network http://network.smashingmagazine.com/ - This is a list of recent web-related blog posts curated by the Smashing team. The quality varies even more, but there is enough there to scan through for value. - This Google Group - You will learn *so much* from the talented people here. - Paul Irish http://paulirish.com/ and his Google+ pagehttps://plus.google.com/113127438179392830442/posts- Paul is a young developer with a passion for making the web better by sharing information. Most of what he shares is front-end specific, but makes http://paulirish.com/2011/web-browser-frontend-and-standards-feeds-to-follow/life http://html5boilerplate.com/easierhttp://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ . - Christian Heilmann http://christianheilmann.com/ - archives just about every talk he gives on various web topics. This list isn't as exhaustive. But I would also like to put out a request for other places to look for web development. Being relatively new to Python and the server-side myself, I don't have a go-to list for that side. Anyone else have ideas?
[web2py] Re: UnicodeEncodeError on GAE
try decode instead of encode (the string is encoded in utf-8 and you are trying to decode): mystr.decode(utf-8) it was a different but similar problem that i had on GAE that i solved this way. good luck! cfh
[web2py] Re: Implementing tornado chat server with web2py
I implemented a similar solution, but the user keeps on getting disconnected from the tornado server. This happens frequently with chrome. Any guesses, so as why the user is being disconnected so often (in every 4-5 secs).
[web2py] Re: Python / web2py or.... the learning path?
I find the Widnows/Mac Web2py download to be one of the easiest ways to get started and to learn to program. You will thank yourself later by learning Python instead of PHP. Python is easy to learn because it is pretty well thought-out, the syntax is clean and easy to read, there is not a lot of extraneous crud, etc. With the Windows or Mac download of Web2py, you can be programming in minutes using either a text editor or the built-in text editor. There is enough sample code that you will be able to figure out how to write your own in a short period of time after observing the existing code. The Web2py Book includes a brief, easy-to follow intro to Python: http://web2py.com/books/default/chapter/29/2 Then, just follow the Overview: http://web2py.com/books/default/chapter/29/3
[web2py] web2py powered sites yogesh link not working
http://www.yogeshd.in/ link is not working in the bottom of the page :)
Re: [web2py] Re: There is no web2py homebrew for OS X
Web2py changes too fast to use anything but source, in my opinion.
[web2py] Re: UnicodeEncodeError on GAE
Thank you for replay. I tried, but the same error message. (app_devserver NG, GAE NG) I think it's strange that error message is UnicodeEncodeError, is not UnicodeDecodeError... On 1月18日, 午前7:44, howesc how...@umich.edu wrote: try decode instead of encode (the string is encoded in utf-8 and you are trying to decode): mystr.decode(utf-8) it was a different but similar problem that i had on GAE that i solved this way. good luck! cfh
[web2py] Re: error class proposal
I've created a function getFormFields which I call for every form I'm using. In this function I go through all inputs of the form with form.elements('input, select, textarea') and then I check if the name of the input field exists in form.errors. If there is an error I add a css error class. At the end of the function I return all input fields as a dict. On 16 Jan., 23:56, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I understand. Let me think about this the problem is some some widgets do not have a single input fiels (think if lists and checkboxes). Please open a ticket in google code so we do not forget. On Jan 16, 2:25 pm, David da...@styleflare.com wrote: Sorry for not being clear; I meant if the field has an error obviously. After form validation, the ie. input would have an error class This would be useful for styling the fields with say red borders Alternatively if there is generic way to handle this I would appreciate it. Thanks. On 1/16/12 2:26 PM, Massimo Di Pierro wrote: Why do you want to add an error class to the input? The error class is normally used for inputs. Perhaps I do not understand. On Jan 15, 7:40 pm, Davidda...@styleflare.com wrote: I was thinking about the form validation. I thought that it may be useful to include an error class on the input widget when the form is submitted and has invalid data. ie. from divclass=w2p_fw inputid=auth_user_passwordclass=passwordtype=passwordvalue=name=p assword divid=password__errorclass=errorstyle=display: block;too short/div /div to divclass=w2p_fw inputid=auth_user_passwordclass=password errortype=passwordvalue=name=password divid=password__errorclass=errorstyle=display: block;too short/div /div Notice the error is the class of the input. I think this would be very useful and don't think it would break any backwards compatibility. Thanks.
Re: [web2py] Re: error class proposal
Massimo added this to trunk. Please see .inputinvalid class On Jan 17, 2012 8:47 PM, Alex mrauc...@gmail.com wrote: I've created a function getFormFields which I call for every form I'm using. In this function I go through all inputs of the form with form.elements('input, select, textarea') and then I check if the name of the input field exists in form.errors. If there is an error I add a css error class. At the end of the function I return all input fields as a dict. On 16 Jan., 23:56, Massimo Di Pierro massimo.dipie...@gmail.com wrote: I understand. Let me think about this the problem is some some widgets do not have a single input fiels (think if lists and checkboxes). Please open a ticket in google code so we do not forget. On Jan 16, 2:25 pm, David da...@styleflare.com wrote: Sorry for not being clear; I meant if the field has an error obviously. After form validation, the ie. input would have an error class This would be useful for styling the fields with say red borders Alternatively if there is generic way to handle this I would appreciate it. Thanks. On 1/16/12 2:26 PM, Massimo Di Pierro wrote: Why do you want to add an error class to the input? The error class is normally used for inputs. Perhaps I do not understand. On Jan 15, 7:40 pm, Davidda...@styleflare.com wrote: I was thinking about the form validation. I thought that it may be useful to include an error class on the input widget when the form is submitted and has invalid data. ie. from divclass=w2p_fw inputid=auth_user_passwordclass=passwordtype=passwordvalue=name=p assword divid=password__errorclass=errorstyle=display: block;too short/div /div to divclass=w2p_fw inputid=auth_user_passwordclass=password errortype=passwordvalue=name=password divid=password__errorclass=errorstyle=display: block;too short/div /div Notice the error is the class of the input. I think this would be very useful and don't think it would break any backwards compatibility. Thanks.
[web2py] Re: web2py powered sites yogesh link not working
Thanks for pointing that out. Looks like it may have been a spam posting. Anthony
[web2py] Can I pass a variable through an ajax load?
{{=LOAD('controller_name','function',ajax=True)}} if so, where would I put it? I am trying to grab that variable on the page that is being loaded. Hope this makes sense I am completely worn out. Chris
[web2py] Re: Can I pass a variable through an ajax load?
Sure: {{=LOAD('controller_name','function', args=[...], vars=dict(...), ajax=True)}} On Tuesday, January 17, 2012 9:38:48 PM UTC-5, chawk wrote: {{=LOAD('controller_name','function',ajax=True)}} if so, where would I put it? I am trying to grab that variable on the page that is being loaded. Hope this makes sense I am completely worn out. Chris
[web2py] how to download file from within a cid target
I'm trying to generate a pdf with the bundled pdf generator (fypdf) from withing a .load file that is loaded into a div. Outside the cid div (i.e. extension .html) the download works fine but from within the .load, the contents get rendered into the cid target, never downloading to the user. How can i download a generated file from within a cid ? print request.function+request.extension:, request.function+.+request.extension response.headers['Content-Type']='application/pdf' #tmp_pdf = f.render('invoice.pdf', dest='S') attachment = 'attachment;filename=invoice.pdf' response.headers['Content-Disposition'] = attachment response.extension ='pdf' #response.cid ='' #response.ajax = False content = f.render('invoice.pdf', dest='S') return f.render('invoice.pdf', dest='S')#response.stream(content) Another similar problem is blog headlines that are generated from a feedburner javascript within a .load / cid and never render, while they render perfectly outside (.html). Maybe these two problems are linked.
[web2py] Re: Can I pass a variable through an ajax load?
Thanks Anthony.
[web2py] Re: UnicodeEncodeError on GAE
First I don't know that it's need to update default version setting after update version at app.yaml. After update default version, that go good. I'm sorry for lack of my GAE knowlege. (I'm ashamed..) Anyway if someone encounter the same problem, this thread is useful. (I'm not sure this is the best way or not. But it's good in my case.) gluon/html.py modified. else: -_value = str(self['_value']) +if isinstance(self['_value'],unicode): +_value = self['_value'].encode('utf-8') +else: +_value = str(self['_value']) if t == 'checkbox' and not '_checked' in self.attributes: On 1月18日, 午前9:26, ttsujie ttsu...@gmail.com wrote: Thank you for replay. I tried, but the same error message. (app_devserver NG, GAE NG) I think it's strange that error message is UnicodeEncodeError, is not UnicodeDecodeError... On 1月18日, 午前7:44, howesc how...@umich.edu wrote: try decode instead of encode (the string is encoded in utf-8 and you are trying to decode): mystr.decode(utf-8) it was a different but similar problem that i had on GAE that i solved this way. good luck! cfh
[web2py] Re: get user id on mobile app after login to web2py
The cookies was an easy and strait forward implementation. Adding response.cookies['myCookie'] = 'myData' in the web2py default controller (that the user will visit once logged in) and using the CookieManager Class on the app side provided a simple solution. Thanks, Yuval On Jan 16, 8:10 pm, Bruno Rocha rochacbr...@gmail.com wrote: You can redirect the user after login to a new url and post user ID as args or vars, so in client side I think you can take it from location. Or you can set a input hidden with the value and read it with jquery, or the cookie. On Tue, Jan 17, 2012 at 2:07 AM, Yuval yuval...@gmail.com wrote: This is on the server side, I looked for the better way to get it over from the server to the mobile application/ client side. I will just set the user id in a cookie and I will pick up from the cookie on the mobile application side. Thanks Yuval On Jan 16, 4:50 pm, Yuval yuval...@gmail.com wrote: I need the web2py user id on an android mobile application. The user will use a web page (WebView) to perform the login (or to register). Once logged in, what is the best suggested way to pass back the user id to the container application (browser)? Thanks, Yuval -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] dynamic SQLForm.factory from query
Dear Everyone, I am still plugging away on web2py and loving it more and more the better I understand python. I have a page where a large list is generated from a database query. Next to each item from the list, I would like to put the ability to add a comment. I did this statically by creating X number of forms for X number of list items displayed on the page, so I know the concept is possible. Now, I want to make it dynamic. I searched this group, and all over the web for dynamic form web2py, multiple form web2py, etc. and all iterations thereof. I did find these threads: http://groups.google.com/group/web2py/browse_thread/thread/1f577d46bd535433 https://groups.google.com/forum/#!topic/web2py/nE_-yhDG-3o The second one seemed closer to what I'm trying to do, but for now, my problem is much simpler. I have one table, one query, and just a variable number of fields. I tried every syntax I could muster blindly trying to pass in a list of fields to SQLFORM or SQLFORM.factory. Below is my code, chopped of the unimportant bits for clarity: def multi_comment(): records=db(myquery).select() fields=[] counter=1 for i in records: fields.append(Field('note','text')) fields.append(Field('div_id', default=str(counter))) counter=counter+1 pass form=SQLFORM.factory(*fields) return dict(form=form, fields=fields) I am getting only one field in my form with a div_id of 1. I know there has to be a simple way to do this, I am just not skilled enough to do it. Any suggestions? Also, any help with implementing the db insert after the form has been processed would be wonderful! Thank you in advance!
Re: [web2py] Re: Movuca - The Social CMS - Need Testers and Contributors
HI, A lot of people are sending me emails with suggestions and bug reports (some people who are not familiar with github to fill issues there) So I created UserVoice account for Movuca If you have any consideration, suggestion, bug report, idea etc... http://movuca.uservoice.com Thank you -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: Skype Integration
Hi massimo, code: In default.py- import Skype accountName = skype_username accountPsw = skype_password loggedIn= False Skype.Account.OnPropertyChange = AccountOnChange MySkype = Skype.GetSkype(keypair_keyFileName) account = MySkype.GetAccount(accountName) account.LoginWithPassword(accountPsw, False, False) while not loggedIn: sleep(1) def AccountOnChange (self, property_name): global loggedIn; if property_name == 'status': print ('Login sequence: ' + self.status); if self.status == 'LOGGED_IN': loggedIn = True; if self.status == 'LOGGED_OUT': loggedIn = False; In /ipc/python/skypekit.py def run(self): try: self.connection._start() except: self.connection.stop() raise def _start(self): while not self.stopped: if self._read_byte(1) == 'Z': if self.stopped: return def _read_byte(self, num_bytes_to_read = 1): result = self.read_buffer while not self.stopped and len(result) num_bytes_to_read: try: read = self.socket.recv(4096) if not read: self.stop() raise ConnectionClosed . Thank You On Jan 18, 1:55 am, Massimo Di Pierro massimo.dipie...@gmail.com wrote: can you show any code? On Jan 17, 4:17 am, ganesh waghmare ganeshwaghmar...@gmail.com wrote: Hi, I want to integrateskypein my web2py application. I have skypekit downloaded fromskype.com. But it gives error : SSLError:ssl read operation timed out detailed stack trace: Traceback (most recent call last): File /usr/lib/python2.6/threading.py, line 532, in __bootstrap_inner self.run() File applications/filem/modules/skypekit_mod/ipc/python/ skypekit.py, line 143, in run self.connection._start() File applications/filem/modules/skypekit_mod/ipc/python/ skypekit.py, line 521, in _start if self._read_byte(1) == 'Z': File applications/filem/modules/skypekit_mod/ipc/python/ skypekit.py, line 236, in _read_byte read = self.socket.recv(4096) File /usr/lib/python2.6/ssl.py, line 215, in recv return self.read(buflen) File /usr/lib/python2.6/ssl.py, line 136, in read return self._sslobj.read(len) SSLError: The read operation timed out please Help.. Thank You.
[web2py] MSSQL How to access tables which not created by web2py
Hi all, In db.py, I successful create a connect to MSSQL and create a new table in mydb database like below. db.py msdb = DAL('mssql://user:passwd@sqlserver/mydb') msdb.define_table('test1',Field('firstname'),Field('surname')) Now in mydb, I got two tables test which already exists and test1 which web2py just created. In default.py, I tried to return all the tables in mydb def mssql(): crud = Crud(msdb) # Try to return all the tables a = crud.tables() return dict(a=a) But in view mssql.html {{=a}} only the test1 shows. So my questions is that, If I want to query/update the test table which not created by web2py, how should I do? Do I need import pyodbc and create a connect and query again? Many thanks.
Re: [web2py] MSSQL How to access tables which not created by web2py
You need to map the existent table and set migrate=False, also you will need to specify which field is the 'id' or primary keys, and for all fields you need to tell the datatype. msdb.define_table( 'test', FIeld('cod', 'id'), Field('field1', datatype), Field('field2', datatype), migrate=False ) look here: http://web2py.com/books/default/chapter/29/6#Legacy-databases-and-keyed-tables -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: dynamic SQLForm.factory from query
Did you have a look at the wiki example in the web2py book: http://www.web2py.com/books/default/chapter/29/3#A-wiki ? Instead of a 'page' table you have the table from which you retrieve the list and, just like in the example, a table to store the comments. page_id in your case becomes list_id. I don't see why you need the fields and counter variable. I would move the for loop to the view and do something like: {{for row in rows:}} tr td{{=row.field_name}}/td td{{=A('Add comment',_href=URL('addComment',args=row.id))}}/td /tr {{pass}} .. and in the addComment function something like: db.comment.list_id.default=request.args(0) form=crud.create(table=db.comment) I hope this helps you solve the problem. Kind regards, Annet