[web2py] Re: Trouble with lazy virtual fields
Can I help or do something to track it down? On jún. 28, 20:52, szimszon szims...@gmail.com wrote: The virtualfields class is not a common python class? On jún. 28, 09:35, szimszon szims...@gmail.com wrote: That's weired why is this working: class web_sites_extra(): def servername( self ): return self.web_sites.txt.split() and this not: class web_sites_extra(): def servername( self ): r=self.web_sites.txt.split() return self.web_sites.txt.split() or this: class web_sites_extra(): def servername( self ): r=something return self.web_sites.txt.split() On jún. 28, 09:13, szimszon szims...@gmail.com wrote: After the http://www.thadeusb.com/weblog/2009/12/31/web2py_virtualfields_as_an_... webpage I made something like: --- cut --- db.define_table( 'web_sites', Field( 'web_id', db.web, label = T( 'Web config' ), requires = IS_IN_DB( db, 'web.id', '%(name)s' ) ), Field( 'name', 'string', label = T( 'Name' ), requires = [IS_NOT_EMPTY()] ), Field( 'txt', 'text', label = T( 'Config file' ), requires = [IS_NOT_EMPTY()] ), Field( 'weight', 'integer', label = T( 'Weight' ), requires = [IS_NOT_EMPTY()] ), Field( 'active', 'boolean', label = T( 'Active' ), default = True, ), Field( 'modified', 'boolean', label = T( 'Modified' ), default = True, writable = False, readable = False, ), ) # computing ServerNames and ServerAliases ## class web_sites_extra(): def servername( self ): def lzy( ): x = 'sfjha' return x return lzy db.web_sites.virtualfields.append( web_sites_extra() ) --- cut --- In the view: --- cut --- {{=selected_rows[0].servername()}} But I got: File gluon/sql.py, line 665, in __getattr__ return dict.__getitem__(self,key) KeyError: 'servername' If I only change: class web_sites_extra(): def servername( self ): def lzy( ): x = 'sfjha' return x return lzy to: class web_sites_extra(): def lzy( self ): x = 'sfjha' return x def servername( self ): return self.lzy it works.
[web2py] Re: patch to dal [Re: bug in SQLFORM?]
In trunk so that people can try it. On 28 Giu, 20:14, Jose jjac...@gmail.com wrote: The code should look like: self._db._execute('SELECT SCOPE_IDENTITY();') Jose
[web2py] Re: calling secured function from cron
I have following line in crontab: * * * * * root *cpe_lang/test_only the function in controller is defined as: @auth.requires( (request.client==None) or (auth.has_membership('managers')) ) def test_only(): logging.error('Test cron') logging.info(str(request)) if request.client != None: logging.info('from user') else: logging.info('from cron') Function is NOT executed. and that is traceback: Traceback (most recent call last): File web2py.py, line 20, in module gluon.widget.start(cron=True) File /myapp/web2py/gluon/widget.py, line 759, in start import_models=options.import_models, startfile=options.run) File /myapp/web2py/gluon/shell.py, line 174, in run exec ('print %s()' % f, _env) File string, line 1, in module File /myapp/web2py/gluon/tools.py, line 2116, in f '?_next='+urllib.quote(next)) File /myapp/web2py/gluon/http.py, line 104, in redirect Location=location) gluon.http.HTTP I can only execute the function it by hand. I was also trying to do it with curl from cron * * * * * /usr/bin/curl -u manager_user:my_pass http://127.0.0.1:8000/my_app/cpe_lang/test_only but i get the error: Exception in thread Thread-19: Traceback (most recent call last): File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/threading.py, line 460, in __bootstrap self.run() File /Users/msh/c_workspace/sara_refactor/web2py/gluon/newcron.py, line 206, in run shell=self.shell) File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/subprocess.py, line 593, in __init__ errread, errwrite) File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/subprocess.py, line 1079, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory why No such file or directory? I am sure curl is in that location.
[web2py] Issues with sessions on multiple tabs/windows
I have a robot that is running on web2py. It has it's main operating screen and a screen specifically for debugging and other information. I have the main screen that pulls a page that reports the very general status information, and when that screen is requested about 20 different session variables are reset to up to date information. this information is found from a file that it reads and unpickles. When I try to get the debug screen to see all the information it comes as if the session was not even created. None I have the debug and the main robot running screen on the same computer and they are in the same web2py application. What could I be doing wrong? Should I pull from the same file twice one for the status page on the robot opporation part and then pull again for the debug screen? Very confuse, Jason Brower
Re: [web2py] do you use web2py for teaching?
On Mon, Jun 28, 2010 at 7:22 PM, mdipierro mdipie...@cs.depaul.edu wrote: Please post some info about the class or drop me a private note. We're teaching web2py for the final year Computer Science (BSc) project (since 2009): http://reingart.blogspot.com/p/materia-edi-3.html Also I taught web2py at: * Programming in Python course (incluiding web2py for web development) 2009, 2010 coming soon: http://www.clubdeprogramadores.com/cursos/CursoMuestra.php?Id=519 * GNU/Linux + PostgreSQL+ Python (web2py) course for a StartUp in Rafaela-SF, 2009 (no public page remains) Sorry, all is in spanish, I have more detailed documents if you want Best regards, Mariano Reingart http://www.web2py.com.ar http://www.sistemasagiles.com.ar http://reingart.blogspot.com
[web2py] Re: calling secured function from cron
Please add a logging.info(str(request.client)) Outside the function, in a model. On 29 Giu, 04:41, mika miss.from.h...@gmail.com wrote: I have following line in crontab: * * * * * root *cpe_lang/test_only the function in controller is defined as: @auth.requires( (request.client==None) or (auth.has_membership('managers')) ) def test_only(): logging.error('Test cron') logging.info(str(request)) if request.client != None: logging.info('from user') else: logging.info('from cron') Function is NOT executed. and that is traceback: Traceback (most recent call last): File web2py.py, line 20, in module gluon.widget.start(cron=True) File /myapp/web2py/gluon/widget.py, line 759, in start import_models=options.import_models, startfile=options.run) File /myapp/web2py/gluon/shell.py, line 174, in run exec ('print %s()' % f, _env) File string, line 1, in module File /myapp/web2py/gluon/tools.py, line 2116, in f '?_next='+urllib.quote(next)) File /myapp/web2py/gluon/http.py, line 104, in redirect Location=location) gluon.http.HTTP I can only execute the function it by hand. I was also trying to do it with curl from cron * * * * * /usr/bin/curl -u manager_user:my_passhttp://127.0.0.1:8000/my_app/cpe_lang/test_only but i get the error: Exception in thread Thread-19: Traceback (most recent call last): File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/threading.py, line 460, in __bootstrap self.run() File /Users/msh/c_workspace/sara_refactor/web2py/gluon/newcron.py, line 206, in run shell=self.shell) File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/subprocess.py, line 593, in __init__ errread, errwrite) File /System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/subprocess.py, line 1079, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory why No such file or directory? I am sure curl is in that location.
[web2py] Re: Issues with sessions on multiple tabs/windows
I cannot say without more details. Just consider that if you have two windows open they share the same session variables. On 29 Giu, 04:46, Jason Brower encomp...@gmail.com wrote: I have a robot that is running on web2py. It has it's main operating screen and a screen specifically for debugging and other information. I have the main screen that pulls a page that reports the very general status information, and when that screen is requested about 20 different session variables are reset to up to date information. this information is found from a file that it reads and unpickles. When I try to get the debug screen to see all the information it comes as if the session was not even created. None I have the debug and the main robot running screen on the same computer and they are in the same web2py application. What could I be doing wrong? Should I pull from the same file twice one for the status page on the robot opporation part and then pull again for the debug screen? Very confuse, Jason Brower
[web2py] Re: synchronize tables in two databases
I found a person who wants the same http://www.freelancer.com/projects/pingfreelance_566941.html This person is willing to pay for development of a tool to generate the reverse schema, from Database for Web2py. May be a good chance for any experienced web2py programmer develop and then release to the community. On Jun 28, 11:25 pm, rochacbruno rochacbr...@gmail.com wrote: Would be great if we have a tool to automate reverse DBTables mapping to web2py models! -- rochacbruno.com.br On Jun 28, 7:17 pm, mdipierro mdipie...@cs.depaul.edu wrote: On 28 Giu, 15:18, Avik Basu avikb...@gmail.com wrote: My problem is that I have some different tables in each of the databases which is why I could not use the db export/import functions. Also, I am not defining tables in db2 as those tables already exist and have data in them. Am I still able to access the database function if i have not defined any tables for it in the model? No. You have to define table tables you want to use since it is necessary map database types into web2py types. You do not need to define all fields, only those you plan to access. Set migrate=False. Avik On Jun 28, 4:06 pm, mdipierro mdipie...@cs.depaul.edu wrote: import cStringIO s=cStringIO.StringIO() after the same tables are defined for both dbs: db2.export_to_csv_file(s) s.seek(0) db1.import_form_csv_file(s) On 28 Giu, 13:25, Avik Basu avikb...@gmail.com wrote: Hi, I'm trying to synchronize two databases that are similar but not exactly the same. I would like to create two connections (db1 and db2) and go through table by table to do the synchronization. db1 = DAL('sqlite://storage.db') db2 = DAL('mysql://username:passw...@mysql.test.com/test_db', pool_size=10, check_reserved=['mysql'], migrate=False, fake_migrate=False) db1 is defined in db.py while db2 is a mysql database (created via web2py) that already exists and has data in it. i'm trying to update the data in db2 with the data in db1. What is a good way to deal with this problem? Avik
[web2py] Re: synchronize tables in two databases
http://groups.google.com/group/web2py/browse_thread/thread/c347e86a6644432a/c1c7126c1b14600d?lnk=gstq=Script+to+generate+schema#c1c7126c1b14600d On 29 Giu, 07:42, rochacbruno rochacbr...@gmail.com wrote: I found a person who wants the same http://www.freelancer.com/projects/pingfreelance_566941.html This person is willing to pay for development of a tool to generate the reverse schema, from Database for Web2py. May be a good chance for any experienced web2py programmer develop and then release to the community. On Jun 28, 11:25 pm, rochacbruno rochacbr...@gmail.com wrote: Would be great if we have a tool to automate reverse DBTables mapping to web2py models! -- rochacbruno.com.br On Jun 28, 7:17 pm, mdipierro mdipie...@cs.depaul.edu wrote: On 28 Giu, 15:18, Avik Basu avikb...@gmail.com wrote: My problem is that I have some different tables in each of the databases which is why I could not use the db export/import functions. Also, I am not defining tables in db2 as those tables already exist and have data in them. Am I still able to access the database function if i have not defined any tables for it in the model? No. You have to define table tables you want to use since it is necessary map database types into web2py types. You do not need to define all fields, only those you plan to access. Set migrate=False. Avik On Jun 28, 4:06 pm, mdipierro mdipie...@cs.depaul.edu wrote: import cStringIO s=cStringIO.StringIO() after the same tables are defined for both dbs: db2.export_to_csv_file(s) s.seek(0) db1.import_form_csv_file(s) On 28 Giu, 13:25, Avik Basu avikb...@gmail.com wrote: Hi, I'm trying to synchronize two databases that are similar but not exactly the same. I would like to create two connections (db1 and db2) and go through table by table to do the synchronization. db1 = DAL('sqlite://storage.db') db2 = DAL('mysql://username:passw...@mysql.test.com/test_db', pool_size=10, check_reserved=['mysql'], migrate=False, fake_migrate=False) db1 is defined in db.py while db2 is a mysql database (created via web2py) that already exists and has data in it. i'm trying to update the data in db2 with the data in db1. What is a good way to deal with this problem? Avik
[web2py] Re: do you use web2py for teaching?
I understood that your question was referring to the use of web2py as a tool for teaching programming and web development (In educational institutions,, Universities etc). In these cases I never used, but... I Also did some private classes, and right now I am training 5 IT professionals of São Paulo Prefecture who intends to start using web2py for internal tools development. Like Álvaro, I was invited to an 8 hours hands on training about web development with web2py, Alvaro will teach in Rio and I'll do in São Paulo. We are preparing a basic portuguese course book, that we intend to release under creative commons, because we have to use the same course material for both locations. more info (in portuguese ): http://softwarelivre.org/portal/desenvolvimento-web-agil-com-python-e-web2py-treinamento-mao-na-massa Translated description: Invited by Tempo Real Events http://www.temporealeventos.com.br/ , a company operating for over five years providing training, conferences, seminars, workshops and tutorials Hands on, having already served about 15 thousand professionals, Álvaro Justen http:// blog.justen.eng.br/ and I http://rochacbruno.com.br/ delivers the hands-on training - Agile Web Development with Python and web2py - I will be responsible for Sao Paulo classes and he by the students of Rio de Janeiro. The training is divided into two modules, Basic and Advanced, and the target audience is Web developers, programmers and web designers looking for a tool for agile development, dynamic, safe and easy to use. For the basic module, you must have basic knowledge of HTML and programming logic (any language). To study the advanced module, it is advisable that the applicant has participated in the first module, or have equivalent knowledge, and have basic knowledge in Python language. The training modules will have a book and will be developed a fully functional web application. Addressed to various issues related to Web development as MVC, sessions, authentication and authorization, internationalization, deploy, Google App Engine, among others. Moreover, everything will be based on free software with Ubuntu 10.04. {{ }}'s On Jun 28, 7:22 pm, mdipierro mdipie...@cs.depaul.edu wrote: Please post some info about the class or drop me a private note.
[web2py] Re: Anybody having trouble accessing web2py google group on mozilla firefox 3.6.6?
thanks for tip - I also faced the same problem with FF when on Windows. On Jun 29, 2:34 am, Thadeus Burgess thade...@thadeusb.com wrote: try logging completely out of your google account, clearing firefox cookies, closing firefox, then start again. -- Thadeus On Mon, Jun 28, 2010 at 10:32 AM, weheh richard_gor...@verizon.net wrote: I'm able to access the web2py group no problem on IE (ugh). But starting just recently, on Mozilla, I'm getting stuck in an infinite loop. The tab displays, Redirecting constantly. The URL is: https://www.google.com/accounts/ServiceLogin?service=groups2passive=... Anybody else run into this problem?
[web2py] Web2py Application Exhibition Part 2
Web2py Application Exhibition Do you have a Web2py app that you'd like to show the world? If so, you may be interested in the Web2py Application Exhibition. The WAE is a way to... 1. Demonstrate what can be done with Web2py. 2. Share and learn about useful web2py, python, Javascript, jQuery etc. techniques. 3. Earn some money toward that new you've been craving. Projects will be judged in the following areas. Ease of use Usefulness Visual Appeal The Rules 1. Applications must be submitted no later than July 30, 2010 2. Source must be included with your submissions. 3. If the application is written by a team, Massimo can NOT be part of the team. 4. After a 2 week review period, on August 15, 2010, the winners will be announced on the web2py-users list. 5. The 1st place winner will receive $100 US Dollars, 2nd place will receive $50 6. You must enjoy using Web2py! Massimo is not affiliated with this exhibition, ( maybe he'll help judge if I can twist his arm ) so, if you have any questions or comments, I can be contacted on gmail If the google-groups hides my contact info, you can find it at http://bithawk.org mr.netadadmin
[web2py] web2py with AppStats
if you are on GAE it s to have AppStats on it s quite easy http://blog.socialcaddy.com/appstats-for-web2py-0
Re: [web2py] Re: elFinder-web2py , Filemanager for Web2py!
Let me know where it dont work. I am suprised too :D may be for security issues? On Fri, Jun 25, 2010 at 4:30 PM, Giuseppe Luca Scrofani glsdes...@gmail.com wrote: Even following your indication I can't make it work :( I will retry after dinner. I am surprised of how this project seems not interesting to the others... It is very strange, In my humble, I think this have to be shipped by default in web2py...
[web2py] models for auth system
Hello, Where can I find the models of auth tables? Are they stored somewhere in the web2py tree? Jonhy
[web2py] format of fk field
Hello, I know there is a way to show an other field value of the same row for a fk field. Is that correct? How to do it? This work in case of m2m table : If you check in appadmin in membership table the group_id are replaced by the role of the auth_group table... I there a way to do the same thing for table containing many fields and fk? Can't find the code to do that... Should be in the model of the auth_ tables... Jonhy
[web2py] sql.py error?
I think the most recent update to trunk I've found a spot in sql.py where functionality is different though it might be intended. In the last stable release you could make a call: auth.add_permission(group.id,'name','table_name') You could do this with out first checking for it's existence already. A new entry was created and no errors thrown. Now if you try to do the above call and that same permission is already defined you get: --New Error raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference --/New Error While it's good that this points out that I wasn't checking for these permissions before, it's bad that you find out by an error which didn't previously exist. I can wrap my add_permission calls in a try: block, or i could check for the permission before adding. But is that something that should just be included in web2py by default? It's how I assumed it worked originally :)
Re: [web2py] Re: models for auth system
On 2010-06-29 14:30, Chris S wrote: that's what you're looking for. Yes! Thank Chris.
[web2py] Re: sql.py error?
Actually, that's not exactly what's happening. The error is produced when trying to make two calls back to back to auth.add_permission(). Single calls still create duplicate enteries but back to back calls error on the 2nd call never creating an entry. To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table1') return Either one of the above can be run by itself, but both in the same controller will fail with the above error on the 2nd permission. On Jun 29, 1:35 pm, Chris S sanders.ch...@gmail.com wrote: I think the most recent update to trunk I've found a spot in sql.py where functionality is different though it might be intended. In the last stable release you could make a call: auth.add_permission(group.id,'name','table_name') You could do this with out first checking for it's existence already. A new entry was created and no errors thrown. Now if you try to do the above call and that same permission is already defined you get: --New Error raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference --/New Error While it's good that this points out that I wasn't checking for these permissions before, it's bad that you find out by an error which didn't previously exist. I can wrap my add_permission calls in a try: block, or i could check for the permission before adding. But is that something that should just be included in web2py by default? It's how I assumed it worked originally :)
[web2py] Re: sql.py error?
Crap that should read: To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table2') return I'm trying to assign two different permissions to the same group in a single function to get the error. On Jun 29, 2:11 pm, Chris S sanders.ch...@gmail.com wrote: Actually, that's not exactly what's happening. The error is produced when trying to make two calls back to back to auth.add_permission(). Single calls still create duplicate enteries but back to back calls error on the 2nd call never creating an entry. To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table1') return Either one of the above can be run by itself, but both in the same controller will fail with the above error on the 2nd permission. On Jun 29, 1:35 pm, Chris S sanders.ch...@gmail.com wrote: I think the most recent update to trunk I've found a spot in sql.py where functionality is different though it might be intended. In the last stable release you could make a call: auth.add_permission(group.id,'name','table_name') You could do this with out first checking for it's existence already. A new entry was created and no errors thrown. Now if you try to do the above call and that same permission is already defined you get: --New Error raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference --/New Error While it's good that this points out that I wasn't checking for these permissions before, it's bad that you find out by an error which didn't previously exist. I can wrap my add_permission calls in a try: block, or i could check for the permission before adding. But is that something that should just be included in web2py by default? It's how I assumed it worked originally :)
[web2py] web2py security - keep it up!
Hello there! My name is Craig Younkins. I'm a summer intern at OWASP, the Open Web Application Security Project. This summer I'm working heavily on web security in Python. First, I would like to praise Dr. Di Pierro and all the web2py contributors for their focus on security. Examining the OWASP Top 10 (http://www.web2py.com/examples/default/security) is a great way to start. Keep it up! Second, I'd like to invite the web2py community over to a site I've started about security in Python - http://www.pythonsecurity.org . The site aims to be the central hub for security in Python, and right now has a focus on web security. Inside there are articles specific to software like frameworks as well as articles related to security topics like cross-site scripting. We also have a Google Group (http:// groups.google.com/group/python-security/topics) which I encourage the developers to join. There you can get answers to your Python security questions. I hope you check it out! Lastly, I'd like to encourage you to take a look at web2py's page on PythonSecurity.org - http://www.pythonsecurity.org/wiki/web2py/ . I haven't had the time yet to examine web2py in detail, but on that page there is a pretty well-defined template of questions to be answered. Going through the list there will help the developers see areas in web2py that could use improvement, as well as documenting the strengths for other frameworks to model off of. Thanks! Craig Younkins
[web2py] Re: sql.py error?
can you give a complete example necessary to reproduce? Alternatively, you can debug yourself: set a breakpoint at gluon/ tools.py::Auth:add_permission() and analyze what's going on... - Yarko On Jun 29, 2:13 pm, Chris S sanders.ch...@gmail.com wrote: Crap that should read: To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table2') return I'm trying to assign two different permissions to the same group in a single function to get the error. On Jun 29, 2:11 pm, Chris S sanders.ch...@gmail.com wrote: Actually, that's not exactly what's happening. The error is produced when trying to make two calls back to back to auth.add_permission(). Single calls still create duplicate enteries but back to back calls error on the 2nd call never creating an entry. To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table1') return Either one of the above can be run by itself, but both in the same controller will fail with the above error on the 2nd permission. On Jun 29, 1:35 pm, Chris S sanders.ch...@gmail.com wrote: I think the most recent update to trunk I've found a spot in sql.py where functionality is different though it might be intended. In the last stable release you could make a call: auth.add_permission(group.id,'name','table_name') You could do this with out first checking for it's existence already. A new entry was created and no errors thrown. Now if you try to do the above call and that same permission is already defined you get: --New Error raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference --/New Error While it's good that this points out that I wasn't checking for these permissions before, it's bad that you find out by an error which didn't previously exist. I can wrap my add_permission calls in a try: block, or i could check for the permission before adding. But is that something that should just be included in web2py by default? It's how I assumed it worked originally :)
[web2py] Re: sql.py error?
I'm actually not sure how to set break points. I'm using Eclipse so I'm sure there's a way but while I'm educating myself. Here's all you should need to know if the above isn't descriptive enough. In db.py: auth = Auth(globals(),db) # authentication/authorization auth.define_tables()# creates all needed tables Using Appadmin -Add a user to auth_users -Create group 'admin' in auth_groups -Make the user a member of admin in auth_memberships In the application: def add(): Debug Function group=db(db.auth_group.role=='admin').select()[0] auth.add_permission(group.id,'access','mystuff') auth.add_permission(group.id,'access','myotherstuff') redirect(URL(request.application,request.controller,'index')) Call /application/controller/add In appadmin view the auth_permissions table. You should see two entries one with the group.id for Admin, access, and table of 'mystuff'. one with the group.id for Admin, access, and table of 'myotherstuff'. Instead you'll get the above error and only mystuff is added to the auth_permissions. You can comment out either line and add them one at a time with no errors. In fact you can add the same permission several times and you'll see duplicate enteries. You can not however, have both of the above added in a single function call. This use to work but no longer does. When I get some time maybe I can test which revision broke this but my guess is it's 650:7c531beb7820 with comment self._last_reference, thanks Dave. Sorry I'm not more help. Wish I could just patch this but I'm still learning python/web2py and this one's a bit above me. On Jun 29, 3:01 pm, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: can you give a complete example necessary to reproduce? Alternatively, you can debug yourself: set a breakpoint at gluon/ tools.py::Auth:add_permission() and analyze what's going on... - Yarko On Jun 29, 2:13 pm, Chris S sanders.ch...@gmail.com wrote: Crap that should read: To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table2') return I'm trying to assign two different permissions to the same group in a single function to get the error. On Jun 29, 2:11 pm, Chris S sanders.ch...@gmail.com wrote: Actually, that's not exactly what's happening. The error is produced when trying to make two calls back to back to auth.add_permission(). Single calls still create duplicate enteries but back to back calls error on the 2nd call never creating an entry. To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table1') return Either one of the above can be run by itself, but both in the same controller will fail with the above error on the 2nd permission. On Jun 29, 1:35 pm, Chris S sanders.ch...@gmail.com wrote: I think the most recent update to trunk I've found a spot in sql.py where functionality is different though it might be intended. In the last stable release you could make a call: auth.add_permission(group.id,'name','table_name') You could do this with out first checking for it's existence already. A new entry was created and no errors thrown. Now if you try to do the above call and that same permission is already defined you get: --New Error raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference --/New Error While it's good that this points out that I wasn't checking for these permissions before, it's bad that you find out by an error which didn't previously exist. I can wrap my add_permission calls in a try: block, or i could check for the permission before adding. But is that something that should just be included in web2py by default? It's how I assumed it worked originally :)
[web2py] built in web2py datepicker bug with Google Chrome
Hello, Is there other user that are having datepicker coming blank when changing the year or mouth couples of time with Google Chrome? I test it with firefox no problem. I use web2py 1.7.8 Jonhy
[web2py] Re: sql.py error?
Narrowing it down. I forgot to mention I'm running on the GAE development server right now. So the above error is likely with gql.py not sql.py. I've reverted my copy of gql.py to 631:1f7ae1da46ff and the error is now gone. The problem is with Line Number 279: Original - tmp = self._tableobj(**fields) tmp.put() /Original - New -- tmp = self._tableobj(**fields) self._last_reference = tmp tmp.put() /New -- There it is now someone smarter than me can figure out why that line's causing a problem when trying to add more than one permission in a single function call. On Jun 29, 3:27 pm, Chris S sanders.ch...@gmail.com wrote: I'm actually not sure how to set break points. I'm using Eclipse so I'm sure there's a way but while I'm educating myself. Here's all you should need to know if the above isn't descriptive enough. In db.py: auth = Auth(globals(),db) # authentication/authorization auth.define_tables() # creates all needed tables Using Appadmin -Add a user to auth_users -Create group 'admin' in auth_groups -Make the user a member of admin in auth_memberships In the application: def add(): Debug Function group=db(db.auth_group.role=='admin').select()[0] auth.add_permission(group.id,'access','mystuff') auth.add_permission(group.id,'access','myotherstuff') redirect(URL(request.application,request.controller,'index')) Call /application/controller/add In appadmin view the auth_permissions table. You should see two entries one with the group.id for Admin, access, and table of 'mystuff'. one with the group.id for Admin, access, and table of 'myotherstuff'. Instead you'll get the above error and only mystuff is added to the auth_permissions. You can comment out either line and add them one at a time with no errors. In fact you can add the same permission several times and you'll see duplicate enteries. You can not however, have both of the above added in a single function call. This use to work but no longer does. When I get some time maybe I can test which revision broke this but my guess is it's 650:7c531beb7820 with comment self._last_reference, thanks Dave. Sorry I'm not more help. Wish I could just patch this but I'm still learning python/web2py and this one's a bit above me. On Jun 29, 3:01 pm, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: can you give a complete example necessary to reproduce? Alternatively, you can debug yourself: set a breakpoint at gluon/ tools.py::Auth:add_permission() and analyze what's going on... - Yarko On Jun 29, 2:13 pm, Chris S sanders.ch...@gmail.com wrote: Crap that should read: To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table2') return I'm trying to assign two different permissions to the same group in a single function to get the error. On Jun 29, 2:11 pm, Chris S sanders.ch...@gmail.com wrote: Actually, that's not exactly what's happening. The error is produced when trying to make two calls back to back to auth.add_permission(). Single calls still create duplicate enteries but back to back calls error on the 2nd call never creating an entry. To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table1') return Either one of the above can be run by itself, but both in the same controller will fail with the above error on the 2nd permission. On Jun 29, 1:35 pm, Chris S sanders.ch...@gmail.com wrote: I think the most recent update to trunk I've found a spot in sql.py where functionality is different though it might be intended. In the last stable release you could make a call: auth.add_permission(group.id,'name','table_name') You could do this with out first checking for it's existence already. A new entry was created and no errors thrown. Now if you try to do the above call and that same permission is already defined you get: --New Error raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference --/New Error While it's good that this points out that I wasn't checking for these permissions before, it's bad that you find out by an error which didn't previously exist. I can wrap my add_permission calls in a try: block, or i could check for the permission before adding. But is that something that should just be included in web2py by default? It's how I assumed it worked originally :)
Re: [web2py] facebook oauth support
hi, MCM the web2py community is very much interested in facebook graphApi intergration with web2py, can you make it plugin/model? I use some graph api calls in my applications but it is simple token exchange, no integration with app. but I know the subject, maybe I can help. thx for all your efforts -- Kuba
[web2py] Re: facebook oauth support
there is also this: http://web2pyslices.com/main/slices/take_slice/77 still not a plugin exactly, but it supports multiple authentication types. On Jun 29, 2:13 pm, Kuba Kucharski kuba.kuchar...@gmail.com wrote: hi, MCM the web2py community is very much interested in facebook graphApi intergration with web2py, can you make it plugin/model? I use some graph api calls in my applications but it is simple token exchange, no integration with app. but I know the subject, maybe I can help. thx for all your efforts -- Kuba
Re: [web2py] Re: facebook oauth support
hey, howesc If you could provide working application package w/o facebook keys of course it would be neat because I did not manage to get your slice fully working. -- Kuba
[web2py] Re: web2py security - keep it up!
WOW. Thank you. I tried fill the blank but I need to read it again tomorrow. Massimo On 29 Giu, 11:08, Craig Younkins cyounk...@gmail.com wrote: Hello there! My name is Craig Younkins. I'm a summer intern at OWASP, the Open Web Application Security Project. This summer I'm working heavily on web security in Python. First, I would like to praise Dr. Di Pierro and all the web2py contributors for their focus on security. Examining the OWASP Top 10 (http://www.web2py.com/examples/default/security) is a great way to start. Keep it up! Second, I'd like to invite the web2py community over to a site I've started about security in Python -http://www.pythonsecurity.org. The site aims to be the central hub for security in Python, and right now has a focus on web security. Inside there are articles specific to software like frameworks as well as articles related to security topics like cross-site scripting. We also have a Google Group (http:// groups.google.com/group/python-security/topics) which I encourage the developers to join. There you can get answers to your Python security questions. I hope you check it out! Lastly, I'd like to encourage you to take a look at web2py's page on PythonSecurity.org -http://www.pythonsecurity.org/wiki/web2py/. I haven't had the time yet to examine web2py in detail, but on that page there is a pretty well-defined template of questions to be answered. Going through the list there will help the developers see areas in web2py that could use improvement, as well as documenting the strengths for other frameworks to model off of. Thanks! Craig Younkins
Re: [web2py] Re: facebook oauth support
ok, maybe howesc!=cfhowes, sory ;) I thought it is yours. -- Kuba
[web2py] Re: Problem trying to insert an image with CKEditor and SQLFORM
This one still has me stumped so I'm taking the liberty of adding some more info to make it current in the discussions. As I noted in the earlier post, the problem has to to do with CKEditor's image insertion dialog somehow triggering a form submission. This is really puzzling, because the link insertion dialog is nearly identical but doesn't trigger a submit. Below is a modified version of the index function with some write statements to print the request vars and session formkeys. Any help much appreciated! def index(): form = SQLFORM(db.page, showid=False,keepvalues=True) sys.stderr.write(\n\nsession formkey: %s%session['_formkey[page_create]']) sys.stderr.write(\nrequest.vars:%s%repr(request.vars)) if form.accepts(request.vars,session): response.flash = Form accepted redirect(URL(r=request,f=show)) elif form.errors: response.flash = Uh-oh! else: response.flash = Fill out the form sys.stderr.write(\n%s\n%response.flash) return dict(form=form) So when I visit the index page and use the CKEditor to insert a link, I see the following output in the console. (initial display) session formkey:bf5ec584-0ec9-4e74-90ff-ba53971ea2f5 request.vars:Storage {} Fill out the form (after inserting link, clicking ok to insert dialog, then clicking submit) session formkey:f95327b1-6152-4fb3-abd2-00444c9cc298 request.vars:Storage {'body': 'p\r\n\ta href=http://web2py.com/ book/static/tree.jpglink/a/p\r\n', '_formkey': 'f95327b1-6152-4fb3-abd2-00444c9cc298', '_formname': 'page_create'} If I try the same thing except that this time I insert an image, I get an extra submit and the session formkey gets out of sync with the request.vars formkey. (initial display) session formkey:76e5e1fe-365c-401d-aaac-f2a751c8873e request.vars:Storage {} Fill out the form (after inserting image and clicking ok in dialog) session formkey:a143b2f1-bc5c-41b0-90e6-ef01fdc8e913 request.vars:Storage {} Fill out the form (after clicking Submit) session formkey:9ee58f15-c1cd-4fa1-8766-b69b9a4478ac request.vars:Storage {'body': 'p\r\n\timg alt= src=http:// web2py.com/book/static/tree.jpg style=width: 401px; height: 500px; //p\r\n', '_formkey': 'a143b2f1-bc5c-41b0-90e6-ef01fdc8e913', '_formname': 'page_create'} Fill out the form The formkeys don't match, so form.accepts fails and the data never gets into the table. Thanks, Mike On Jun 21, 2:01 pm, Michael Ellis michael.f.el...@gmail.com wrote: Not sure if this is a web2py or ckeditor problem or just some misunderstanding on my part. Here's what's happening: If I create a CKEditor instance in a SQLFORM, things work as expected until I try to insert an image. Clicking the Ok button in ckeditor's image dialog appears to be causing an immediate and unwanted form submission with a formkey that doesn't match the real formkey. This doesn't raise a form error. Instead it triggers the final else branch of the form.accepts logic (see below) and the image along with any other text that was entered is lost. I recently ran into this in a larger app, but am able to reproduce it in the following minimal model and controller. Has anyone else run into this and is there a workaround other than switching the CKEditor to Source mode and manually entering the img tag? I'm using web2py1.79.2 and CKEditor 3.3.1 (revision 5586) but have also seen the problem in CKEditor 3.2. MODEL db.define_table('page', Field('body', 'text'), ) def advanced_editor(field, value): eid = str(field).replace('.','_') return TEXTAREA(_id = eid, _name=field.name, _class='text ckeditor', value=value, _cols=80, _rows=10) db.page.body.widget = advanced_editor VIEW (default.py/index.html) {{extend 'layout.html'}} script type=text/javascript src={{=URL(request.application,'static','js/ckeditor/ckeditor.js')}}/sc ript {{=BEAUTIFY(response._vars)}} CONTROLLER def index(): form = SQLFORM(db.page, showid=False) if form.accepts(request.vars,session): response.flash = Form accepted redirect(URL(r=request,f=show)) elif form.errors: response.flash = Uh-oh! else: ## Trying to insert an image lands here. response.flash = Fill out the form. return dict(form=form) def show(): shown = dict() for row in db(db.page.id0).select(): shown[row.id] = row.body return dict(shown=shown) Thanks, Mike
[web2py] Re: sql.py error?
I do not know but I made a change in trunk. Could you please try if it fixes the problem? On 29 Giu, 16:02, Chris S sanders.ch...@gmail.com wrote: Narrowing it down. I forgot to mention I'm running on the GAE development server right now. So the above error is likely with gql.py not sql.py. I've reverted my copy of gql.py to 631:1f7ae1da46ff and the error is now gone. The problem is with Line Number 279: Original - tmp = self._tableobj(**fields) tmp.put() /Original - New -- tmp = self._tableobj(**fields) self._last_reference = tmp tmp.put() /New -- There it is now someone smarter than me can figure out why that line's causing a problem when trying to add more than one permission in a single function call. On Jun 29, 3:27 pm, Chris S sanders.ch...@gmail.com wrote: I'm actually not sure how to set break points. I'm using Eclipse so I'm sure there's a way but while I'm educating myself. Here's all you should need to know if the above isn't descriptive enough. In db.py: auth = Auth(globals(),db) # authentication/authorization auth.define_tables() # creates all needed tables Using Appadmin -Add a user to auth_users -Create group 'admin' in auth_groups -Make the user a member of admin in auth_memberships In the application: def add(): Debug Function group=db(db.auth_group.role=='admin').select()[0] auth.add_permission(group.id,'access','mystuff') auth.add_permission(group.id,'access','myotherstuff') redirect(URL(request.application,request.controller,'index')) Call /application/controller/add In appadmin view the auth_permissions table. You should see two entries one with the group.id for Admin, access, and table of 'mystuff'. one with the group.id for Admin, access, and table of 'myotherstuff'. Instead you'll get the above error and only mystuff is added to the auth_permissions. You can comment out either line and add them one at a time with no errors. In fact you can add the same permission several times and you'll see duplicate enteries. You can not however, have both of the above added in a single function call. This use to work but no longer does. When I get some time maybe I can test which revision broke this but my guess is it's 650:7c531beb7820 with comment self._last_reference, thanks Dave. Sorry I'm not more help. Wish I could just patch this but I'm still learning python/web2py and this one's a bit above me. On Jun 29, 3:01 pm, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: can you give a complete example necessary to reproduce? Alternatively, you can debug yourself: set a breakpoint at gluon/ tools.py::Auth:add_permission() and analyze what's going on... - Yarko On Jun 29, 2:13 pm, Chris S sanders.ch...@gmail.com wrote: Crap that should read: To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table2') return I'm trying to assign two different permissions to the same group in a single function to get the error. On Jun 29, 2:11 pm, Chris S sanders.ch...@gmail.com wrote: Actually, that's not exactly what's happening. The error is produced when trying to make two calls back to back to auth.add_permission(). Single calls still create duplicate enteries but back to back calls error on the 2nd call never creating an entry. To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table1') return Either one of the above can be run by itself, but both in the same controller will fail with the above error on the 2nd permission. On Jun 29, 1:35 pm, Chris S sanders.ch...@gmail.com wrote: I think the most recent update to trunk I've found a spot in sql.py where functionality is different though it might be intended. In the last stable release you could make a call: auth.add_permission(group.id,'name','table_name') You could do this with out first checking for it's existence already. A new entry was created and no errors thrown. Now if you try to do the above call and that same permission is already defined you get: --New Error raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference --/New Error While it's good that this points out that I wasn't checking for these permissions before, it's bad that you find out by an error which didn't previously exist. I can wrap my add_permission calls in a try: block, or i could check for the permission before adding. But is that something that should just be included in web2py by default? It's how I
[web2py] RE: Problem trying to insert an image with CKEditor and SQLFORM
Apologies for new post with same title but adding new info to the old thread doesn't seem to be making it current in the discussions and I'm really stuck trying to understand the problem. Anyway the original post plus some new info I added just is at http://groups.google.com/group/web2py/browse_thread/thread/84c50617a1f30e19 Any help much appreciated! Thanks, Mike
[web2py] Re: GAE / Case sensitivity / canonical validator?
I'm not sure what the like operator has to do with this? I guess what I'm talking about is using a validator to actually do the work of an autocompleted normalized field. Much like the password encryption validator.. or is_lower works... those validators actually change the value of the field before storing it. what I'm looking for is a way to have a validator that will do an IS_LOWER on a different field of the same record which would in essence BE a hidden autocomputed normalized field is there already a hidden autocomputed normalized field functionality in Web2py? could you point me towards it? right now I have written separate code that computes the normalized/ canonical value and puts it in the other field... but I'd rather not have this extra code at the app level... would be better to have it in the model level so that it doesn't get overlooked by accident Thanks! -Nick Franceschina On Jun 25, 5:38 pm, mdipierro mdipie...@cs.depaul.edu wrote: While it sould be easy to write such validator using the like operator, it would not be portable because it would not work on gae and would be slow in general. The preferred way is to use a hidden autocomputed normalized field. On Jun 25, 10:54 am, NickFranceschina nickfrancesch...@gmail.com wrote: Massimo, just realized that GQL does not allow for LOWER() or UPPER()... thus cannot do case-insensitive searches. the generally suggested solution is to create another field and store the canonical form of the string you're trying to search example: person.name = Nick Franceschina person.canonical = nick franceschina would be nice to have a validator that could do this automatically... it would work like the IS_LOWER() validator, but would look into another field for the data... something like: Field('canonical', 'string', requires=CANONICAL('person.name')) then I just put my data into name as I always do, and wouldn't have to write special code to do the canonical field... is there anything like this now, and I'm not seeing it? i'll keep looking... Thanks, -Nick Franceschina
[web2py] multiselect plugin from web2py slice
Hello, I install multiselect plugin it works just fine... http://web2pyslices.com/main/slices/take_slice/70 But I receive this error when I try to got on a record from the appadmin : Error traceback Traceback (most recent call last): File /web2py/gluon/restricted.py, line 178, in restricted exec ccode in environment File /web2py/applications/app/controllers/appadmin.py, line 410, in module File /web2py/gluon/globals.py, line 96, in lambda self._caller = lambda f: f() File /web2py/applications/app/controllers/appadmin.py, line 273, in update f='download', args=request.args[:1])) File /web2py/gluon/sqlhtml.py, line 688, in __init__ inp = field.widget(field, default) File /web2py/applications/app/models/plugins.py, line 11, in multiselect_widget inp = SQLFORM.widgets.options.widget(f,v) File /web2py/gluon/sqlhtml.py, line 190, in widget % field SyntaxError: widget cannot determine options of atable.field1 Jonhy
[web2py] Accessing auth_user table
Hello, On this page: http://web2pyslices.com/main/slices/take_slice/53 I have found a great pice of code which allows to check on the fly if there is an exact value already in database. Oryginal code: def ajaxuserexist(): username = request.vars.values()[0] query = db.users.name.like(username) numres = db(query).count() if numres 0 : return 'yes' return 'no' But when I try to implement the same solution on auth_user table for login column it stops working: query = db.auth_users.login.like(username) Do you know some solution/workaround to this problem? Best regards.
[web2py] Re: multiselect plugin from web2py slice
Work around that work actually is to define the widget in the controller : move this from model to controller : db.atable.field1.widget=multiselect_widget Jonhy On 2010-06-29 18:29, Jean-Guy wrote: Hello, I install multiselect plugin it works just fine... http://web2pyslices.com/main/slices/take_slice/70 But I receive this error when I try to got on a record from the appadmin : Error traceback Traceback (most recent call last): File /web2py/gluon/restricted.py, line 178, in restricted exec ccode in environment File /web2py/applications/app/controllers/appadmin.py, line 410, in module File /web2py/gluon/globals.py, line 96, in lambda self._caller = lambda f: f() File /web2py/applications/app/controllers/appadmin.py, line 273, in update f='download', args=request.args[:1])) File /web2py/gluon/sqlhtml.py, line 688, in __init__ inp = field.widget(field, default) File /web2py/applications/app/models/plugins.py, line 11, in multiselect_widget inp = SQLFORM.widgets.options.widget(f,v) File /web2py/gluon/sqlhtml.py, line 190, in widget % field SyntaxError: widget cannot determine options of atable.field1 Jonhy
[web2py] Many To Many Select
Given a many-to-many relationship between table1 and table2 and a row in table1, I am trying to figure out the fastest way to select all the rows in table2 that are associated with the row. (I'm still trying to pick up web2py, so thanks for everyone's patience if I've missed the blatently obvious.) From the web2py book documentation, the best I can figure out is something like this: db.define_table('link_table', Field('table1', db.table1), Field('table2', db.table2) ) # Pick the row from table 1 r = db(db.table1.name == Example).select()[0] linked_view = db(db.table1.id == db.link_table.table1) (db.table2.id == db.linked_table.table2)) for row in linked_view(db.table1.id == r.id).select([fields from table2 I want]) # Do something clever for the matching rows I've found pass But I keep thinking there ought to be something cleverer that I can do, especially given that r has a set containing the rows of link_table that contain the entries of table2 that I want. But I can't figure out how to leverage that set into a shorter query. Thanks, Al
[web2py] Re: Many To Many Select
If I understand: for row in db(db.link_table.table1==r.id) (db.table2.id==db.linked_table.table2).select(db.table2.id,db.table2.other): print row.id, row.other if no double links else sub=db(db.link_table.table1==r.id)._select(db.linked_table.table2) for row in db(db.table2.id.belongs(sub)).select(db.table2.id,db.table2.other): print row.id, row.other linked_view = db(db.table1.id == db.link_table.table1) (db.table2.id == db.linked_table.table2)) for row in linked_view(db.table1.id == r.id).select([fields from table2 I want]) On 29 Giu, 17:54, Al rayalans...@yahoo.com wrote: Given a many-to-many relationship between table1 and table2 and a row in table1, I am trying to figure out the fastest way to select all the rows in table2 that are associated with the row. (I'm still trying to pick up web2py, so thanks for everyone's patience if I've missed the blatently obvious.) From the web2py book documentation, the best I can figure out is something like this: db.define_table('link_table', Field('table1', db.table1), Field('table2', db.table2) ) # Pick the row from table 1 r = db(db.table1.name == Example).select()[0] linked_view = db(db.table1.id == db.link_table.table1) (db.table2.id == db.linked_table.table2)) for row in linked_view(db.table1.id == r.id).select([fields from table2 I want]) # Do something clever for the matching rows I've found pass But I keep thinking there ought to be something cleverer that I can do, especially given that r has a set containing the rows of link_table that contain the entries of table2 that I want. But I can't figure out how to leverage that set into a shorter query. Thanks, Al
[web2py] Re: Sending html emails [bug?]
I did some tests with trunk Mail on GAE: mail.send(..., message=message) - Mail.send failure:May not set empty value for 'html' mail.send(..., message=(None, message)) - Mail.send failure:May not set empty value for 'body' mail.send(..., message=(message, message)) - sends email as HTML Richard On May 20, 1:22 am, mdipierro mdipie...@cs.depaul.edu wrote: I made a change that should allow attachments to work on GAE. Can you check it does not break the regularmailon GAE? On May 19, 8:00 am, mdipierro mdipie...@cs.depaul.edu wrote: moving to trunk! Thanks. ;-) On May 19, 7:53 am, PanosJee panos...@gmail.com wrote: Just fixed it tools.py 437 result =mail.send_mail(sender=self.settings.sender, to=to, subject=subject, body=text, html=html) On 19 Μάϊος, 15:43, mdipierro mdipie...@cs.depaul.edu wrote: In gluon tools.py locate this code result =mail.send_mail(sender=self.settings.sender, to=to, subject=subject, body=text) and replace it with result =mail.send_mail(sender=self.settings.sender, to=to, subject=subject,html=text) Let me know if it solves the problem. On May 19, 6:54 am, PanosJee panos...@gmail.com wrote: Hmmm no solution works for me We use the latese web2py version I tries the solution of Alexander but wihout any success (i also tried the solution of Thadeus but GAE just died without any log!) On 19 ÌÜúïò, 01:02, mdipierro mdipie...@cs.depaul.edu wrote: This message=[None,messagehtml] whatever it does need some documentation. On May 18, 3:48 pm, Alexandre Andrade alexandrema...@gmail.com wrote: I have sucess with: for person in db(db.cme.id==request.args(0)).select(): context = dict(person=person) messagehtml = response.render('email.html', context) status =mail.send(to=[person.email], subject='My Subject', message=[None,messagehtml]) where 'email.html' is a view. 2010/5/18 Jon Romero darks...@gmail.com It seems that I cannot send emails ashtml(they are displaying as text). mail=Mail() mail.settings = ... mail.send(to=user.email, subjest=subject, message=(message_text, message_html)) Any clues? -- Atenciosamente -- = Alexandre Andrade Hipercenter.com
[web2py] Re: Sending html emails [bug?]
also the reply_to field is ignored On Jun 30, 9:25 am, Richard richar...@gmail.com wrote: I did some tests with trunk Mail on GAE: mail.send(..., message=message) - Mail.send failure:May not set empty value for 'html' mail.send(..., message=(None, message)) - Mail.send failure:May not set empty value for 'body' mail.send(..., message=(message, message)) - sends email as HTML Richard On May 20, 1:22 am, mdipierro mdipie...@cs.depaul.edu wrote: I made a change that should allow attachments to work on GAE. Can you check it does not break the regularmailon GAE? On May 19, 8:00 am, mdipierro mdipie...@cs.depaul.edu wrote: moving to trunk! Thanks. ;-) On May 19, 7:53 am, PanosJee panos...@gmail.com wrote: Just fixed it tools.py 437 result =mail.send_mail(sender=self.settings.sender, to=to, subject=subject, body=text, html=html) On 19 Μάϊος, 15:43, mdipierro mdipie...@cs.depaul.edu wrote: In gluon tools.py locate this code result =mail.send_mail(sender=self.settings.sender, to=to, subject=subject, body=text) and replace it with result =mail.send_mail(sender=self.settings.sender, to=to, subject=subject,html=text) Let me know if it solves the problem. On May 19, 6:54 am, PanosJee panos...@gmail.com wrote: Hmmm no solution works for me We use the latese web2py version I tries the solution of Alexander but wihout any success (i also tried the solution of Thadeus but GAE just died without any log!) On 19 ÌÜúïò, 01:02, mdipierro mdipie...@cs.depaul.edu wrote: This message=[None,messagehtml] whatever it does need some documentation. On May 18, 3:48 pm, Alexandre Andrade alexandrema...@gmail.com wrote: I have sucess with: for person in db(db.cme.id==request.args(0)).select(): context = dict(person=person) messagehtml = response.render('email.html', context) status =mail.send(to=[person.email], subject='My Subject', message=[None,messagehtml]) where 'email.html' is a view. 2010/5/18 Jon Romero darks...@gmail.com It seems that I cannot send emails ashtml(they are displaying as text). mail=Mail() mail.settings = ... mail.send(to=user.email, subjest=subject, message=(message_text, message_html)) Any clues? -- Atenciosamente -- = Alexandre Andrade Hipercenter.com
[web2py] Re: elFinder-web2py , Filemanager for Web2py!
Yes, this project like me, and Massimo said about an Admin version 2 of web2py based at elFinder Look at this http://groups.google.es/group/web2py/browse_thread/thread/ae2e3ef69daef09a/e88c6812af206cc6 So, probably it will be shipped by default in the future :D I am working on integration too :) On 25 jun, 18:30, Giuseppe Luca Scrofani glsdes...@gmail.com wrote: Even following your indication I can't make it work :( I will retry after dinner. I am surprised of how this project seems not interesting to the others... It is very strange, In my humble, I think this have to be shipped by default in web2py...
[web2py] GAE / parents / ancestors in Web2py?
I've been reading and googling and searching... but not sure what the latest, up-to-date information is on this: in GAE parents and references are two different things. when you create an object in GAE you can, on insert, assign the parent... and this puts the new object into the parents entity group... which lets you: - use those objects within transactions in the entity group - do a query on an object and specify an ancestor (which can be many many levels up the heirarchy, since the gae key actually contains a composite of its entire entity group path, I think) when it comes to transactions, I saw a few discussions that said we can just use the native GAE transaction methods in order to run transactions... but that doesn't really help unless we can assign parents to our objects (thus creating these entity groups). I also saw some discussions about implementing this feature of parents... but I can't figure out if it exists yet. I would really like to be able to use transactions and also do has ancestor queries... but I think there's going to end up being a disconnect on what is possible in both the the big table world and the SQL world... making it difficult to make a single DAL be all things HOPEFULLY what I just wrote makes sense... I could very well be completely confused and would love any feedback to help straighten me out :) Thank you, -Nick Franceschina
[web2py] Re: Many To Many Select
Ah, belongs() + a clever select SQL. Thanks. Al On Jun 29, 7:04 pm, mdipierro mdipie...@cs.depaul.edu wrote: If I understand: for row in db(db.link_table.table1==r.id) (db.table2.id==db.linked_table.table2).select(db.table2.id,db.table2.other): print row.id, row.other if no double links else sub=db(db.link_table.table1==r.id)._select(db.linked_table.table2) for row in db(db.table2.id.belongs(sub)).select(db.table2.id,db.table2.other): print row.id, row.other linked_view = db(db.table1.id == db.link_table.table1) (db.table2.id == db.linked_table.table2)) for row in linked_view(db.table1.id == r.id).select([fields from table2 I want]) On 29 Giu, 17:54, Al rayalans...@yahoo.com wrote: Given a many-to-many relationship between table1 and table2 and a row in table1, I am trying to figure out the fastest way to select all the rows in table2 that are associated with the row. (I'm still trying to pick up web2py, so thanks for everyone's patience if I've missed the blatently obvious.) From the web2py book documentation, the best I can figure out is something like this: db.define_table('link_table', Field('table1', db.table1), Field('table2', db.table2) ) # Pick the row from table 1 r = db(db.table1.name == Example).select()[0] linked_view = db(db.table1.id == db.link_table.table1) (db.table2.id == db.linked_table.table2)) for row in linked_view(db.table1.id == r.id).select([fields from table2 I want]) # Do something clever for the matching rows I've found pass But I keep thinking there ought to be something cleverer that I can do, especially given that r has a set containing the rows of link_table that contain the entries of table2 that I want. But I can't figure out how to leverage that set into a shorter query. Thanks, Al- Hide quoted text - - Show quoted text -
[web2py] Re: sql.py error?
Just updated same thing. Here's the full error log for you. Error Log--- ERROR2010-06-30 04:31:46,888 restricted.py:143] Traceback (most recent call last): File C:\Users\Chris\Documents\Workspace\WebDev\gluon \restricted.py, line 178, in restricted exec ccode in environment File C:\Users\Chris\Documents\Workspace\WebDev\applications\init/ controllers/blog_division.py:add, line 115, in module File C:\Users\Chris\Documents\Workspace\WebDev\gluon\globals.py, line 96, in lambda self._caller = lambda f: f() File C:\Users\Chris\Documents\Workspace\WebDev\applications\init/ controllers/blog_division.py:add, line 26, in add File C:\Users\Chris\Documents\Workspace\WebDev\applications\init/ models/global.py, line 28, in add_permission id = auth.add_permission(group_id,name,table_name,record_id) File C:\Users\Chris\Documents\Workspace\WebDev\gluon\tools.py, line 2406, in add_permission record_id=long(record_id)) File C:\Users\Chris\Documents\Workspace\WebDev\gluon\contrib \gql.py, line 281, in insert self._last_reference = tmp File C:\Users\Chris\Documents\Workspace\WebDev\gluon\sql.py, line 1611, in __setattr__ raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference --End Error Log- An explanation of what the structure looks like. In the controller is: def add(): Debug Function group=db(db.auth_group.role=='admin').select()[0] add_permission(group.id,'access','admin') add_permission(group.id,'access','contact') redirect(URL(request.application,request.controller,'index')) Then in global.py (a file in my models) def add_permission( group_id, name='any', table_name='', record_id=0, ): Calls auth.add_permission only if permission is new rows = db(db.auth_permission.table_name==table_name).select() new=True for row in rows: if (row.group_id == group_id) \ (row.name == name)\ (row.table_name == table_name)\ (row.record_id == record_id): new=False id = row.id if new: id = auth.add_permission(group_id,name,table_name,record_id) return id I've only this afternoon wrapped auth.add_permission in this other function (when I noticed it allowed me to add duplicate enteries). The error has been the same the whole time and goes away if gql.py is reverted. Hope that wrapper function in global.py doesn't confuse anyone it's not part of this problem I don't believe. On Jun 29, 5:13 pm, mdipierro mdipie...@cs.depaul.edu wrote: I do not know but I made a change in trunk. Could you please try if it fixes the problem? On 29 Giu, 16:02, Chris S sanders.ch...@gmail.com wrote: Narrowing it down. I forgot to mention I'm running on the GAE development server right now. So the above error is likely with gql.py not sql.py. I've reverted my copy of gql.py to 631:1f7ae1da46ff and the error is now gone. The problem is with Line Number 279: Original - tmp = self._tableobj(**fields) tmp.put() /Original - New -- tmp = self._tableobj(**fields) self._last_reference = tmp tmp.put() /New -- There it is now someone smarter than me can figure out why that line's causing a problem when trying to add more than one permission in a single function call. On Jun 29, 3:27 pm, Chris S sanders.ch...@gmail.com wrote: I'm actually not sure how to set break points. I'm using Eclipse so I'm sure there's a way but while I'm educating myself. Here's all you should need to know if the above isn't descriptive enough. In db.py: auth = Auth(globals(),db) # authentication/authorization auth.define_tables() # creates all needed tables Using Appadmin -Add a user to auth_users -Create group 'admin' in auth_groups -Make the user a member of admin in auth_memberships In the application: def add(): Debug Function group=db(db.auth_group.role=='admin').select()[0] auth.add_permission(group.id,'access','mystuff') auth.add_permission(group.id,'access','myotherstuff') redirect(URL(request.application,request.controller,'index')) Call /application/controller/add In appadmin view the auth_permissions table. You should see two entries one with the group.id for Admin, access, and table of 'mystuff'. one with the group.id for Admin, access, and table of 'myotherstuff'. Instead you'll get the above error and only mystuff is added to the auth_permissions. You can comment out either line and add them one at a time with no errors. In fact you can add the same permission several times and you'll see duplicate enteries. You can not however, have both of the above added in a single function
[web2py] Re: sql.py error?
On Jun 29, 3:27 pm, Chris S sanders.ch...@gmail.com wrote: I'm actually not sure how to set break points. I'm using Eclipse so I'm sure there's a way but while I'm educating myself. A bit of an aside, but for completeness: Not sure about Eclipse... maybe this will help: http://pydev.org/manual_adv_debugger.html It sort of looks familiar - like winpdb (which is a free windowed --- NOT windows --- debugger for python; you could get that separate). I would (of course) do this with local gae environment. An alternative is to get a 30-day eval of WingIDE, and debug with that either should be fine. - Yarko Here's all you should need to know if the above isn't descriptive enough. In db.py: auth = Auth(globals(),db) # authentication/authorization auth.define_tables() # creates all needed tables Using Appadmin -Add a user to auth_users -Create group 'admin' in auth_groups -Make the user a member of admin in auth_memberships In the application: def add(): Debug Function group=db(db.auth_group.role=='admin').select()[0] auth.add_permission(group.id,'access','mystuff') auth.add_permission(group.id,'access','myotherstuff') redirect(URL(request.application,request.controller,'index')) Call /application/controller/add In appadmin view the auth_permissions table. You should see two entries one with the group.id for Admin, access, and table of 'mystuff'. one with the group.id for Admin, access, and table of 'myotherstuff'. Instead you'll get the above error and only mystuff is added to the auth_permissions. You can comment out either line and add them one at a time with no errors. In fact you can add the same permission several times and you'll see duplicate enteries. You can not however, have both of the above added in a single function call. This use to work but no longer does. When I get some time maybe I can test which revision broke this but my guess is it's 650:7c531beb7820 with comment self._last_reference, thanks Dave. Sorry I'm not more help. Wish I could just patch this but I'm still learning python/web2py and this one's a bit above me. On Jun 29, 3:01 pm, Yarko Tymciurak resultsinsoftw...@gmail.com wrote: can you give a complete example necessary to reproduce? Alternatively, you can debug yourself: set a breakpoint at gluon/ tools.py::Auth:add_permission() and analyze what's going on... - Yarko On Jun 29, 2:13 pm, Chris S sanders.ch...@gmail.com wrote: Crap that should read: To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table2') return I'm trying to assign two different permissions to the same group in a single function to get the error. On Jun 29, 2:11 pm, Chris S sanders.ch...@gmail.com wrote: Actually, that's not exactly what's happening. The error is produced when trying to make two calls back to back to auth.add_permission(). Single calls still create duplicate enteries but back to back calls error on the 2nd call never creating an entry. To reproduce: def test(): auth.add_permission(id,'name','table1') auth.add_permission(id,'name','table1') return Either one of the above can be run by itself, but both in the same controller will fail with the above error on the 2nd permission. On Jun 29, 1:35 pm, Chris S sanders.ch...@gmail.com wrote: I think the most recent update to trunk I've found a spot in sql.py where functionality is different though it might be intended. In the last stable release you could make a call: auth.add_permission(group.id,'name','table_name') You could do this with out first checking for it's existence already. A new entry was created and no errors thrown. Now if you try to do the above call and that same permission is already defined you get: --New Error raise SyntaxError, 'Object exists and cannot be redefined: %s' % key SyntaxError: Object exists and cannot be redefined: _last_reference --/New Error While it's good that this points out that I wasn't checking for these permissions before, it's bad that you find out by an error which didn't previously exist. I can wrap my add_permission calls in a try: block, or i could check for the permission before adding. But is that something that should just be included in web2py by default? It's how I assumed it worked originally :)