[web2py] strange problem connecting to the database - help!
hi everybody I need your help! I have a problem that is tormenting me and driving me to madness, my application suddenly stopped working, and gives me this error (changed names and passwords for security reasons): ERROR MESSAGE: web2py™ Version 1.89.5 (2010-11-21 22:12:54) Python Python 2.6.6: C:\Python26\python.exe Traceback (most recent call last): File C:\web2py_1_89_5\gluon\restricted.py, line 188, in restricted exec ccode in environment File C:/web2py_1_89_5/applications/snow/models/db.py, line 39, in module db = DAL('postgres://username:pass@'+host_name+':5432/snow') # if not, use SQLite or other DB File C:\web2py_1_89_5\gluon\sql.py, line 4073, in DAL raise RuntimeError, %s (tried 5 times) % exception RuntimeError: 'module' object has no attribute 'connect' (tried 5 times) -- MY CODE: import os db_host_name='newhost' db_computer_name='NEWHOST' local_computer_name=os.getenv('COMPUTERNAME') host_name=('localhost' if local_computer_name==db_computer_name else db_host_name) if request.env.web2py_runtime_gae:# if running on Google App Engine db = DAL('gae') # connect to Google BigTable session.connect(request, response, db = db) # and store sessions and tickets there ### or use the following lines to store sessions in Memcache # from gluon.contrib.memdb import MEMDB # from google.appengine.api.memcache import Client # session.connect(request, response, db = MEMDB(Client())) else: # else use a normal relational database db = DAL('postgres://username:pass@'+host_name+':5432/snow') # if not, use SQLite or other DB the crazy thing is the same application code, when run on my local computer with my web2py local server - it's working! only on the server itself there is a problem, it's like there is a problem with the postgresql database web2py server running on the same machine I tried to go back to a version of the application that I know for sure that was working before, and it doesn't work either! it seems that the fault is not in the application code but outside somewhere...? does anybody has an idea what the problem could be? maybe it has something to do with the psycopg2 module? please help!! any suggestion will be very appreciated!
[web2py] Re: strange problem connecting to the database - help!
Thank you all for your help!! turn out the problem was in the psycopg2 module! when I tried: import psycopg2 dir(psycopg2) I got only 4-5 functions, and no 'connect' function! re-installed pstcopg2 and re-launched web2py and it worked like magic! now when I do dir(psycopg2) I get all the functions have no idea why the psycopg module suddenly shrunk :-S
[web2py] Re: unique constraint of multiple columns (at database level)
Thank you guys for your answers, ron - it was just an example Luther - this table was migrated from our old data and we do intent to use auth instead still, it's good practice to always have unique field or combination of fields in a table besides the id, id is for machines, not suitable for the real world my understanding is that IS_NOT_IN_DB is not forced at the database level like the unique keyword, I'm looking for something like the unique keyword only for multiple fields, not just one is there something like this?
[web2py] Re: unique constraint of multiple columns (at database level)
Thank you guys for your answers, ron - it was just an example Luther - this table was migrated from our old data and we do intent to use auth instead still, it's good practice to always have unique field or combination of fields in a table besides the id, id is for machines, not suitable for the real world my understanding is that IS_NOT_IN_DB is not forced at the database level like the unique keyword, I'm looking for something like the unique keyword only for multiple fields, not just one is there something like this?
[web2py] unique constraint of multiple columns (at database level)
hello everybody! I created a table of contacts that requires the first name+last name to be unique the table: db.define_table(Contacts, Field(FirstName, string, length=45, notnull=True), Field(LastName, string, length=45, notnull=True), Field(Title, string, length=45, default=None), Field(Department, string, length=45, default=None), Field(Address, string, length=255, default=None), Field(Phone, string, length=45, default=None), Field(Fax, string, length=45, default=None), Field(Email, string, length=45, default=None), Field(Comments, text, default=None), migrate=True) how do I instruct the DAL to create unique constraint on FirstName +LastName when in creates the table in the database? I have lots of tables that have unique constrain on 2-3 fields, so I prefer not to do this manually. any help will be appreciated!
[web2py] global name 'db' is not recognize in a module
hi all, I want to share a bunch of functions between controllers, so I moved them to a module called 'utilities' in the modules folder, and in the controller I import the module as suggested here in the forum: import applications.myapp.modules.utilities as util reload(util) the problem is, it's not working, I get an error: NameError: global name 'db' is not defined how can I get my 'utilities' file to recognize the global variable 'db'?
[web2py] Re: global name 'db' is not recognize in a module
Thank you for the answer so how would you share functions between controllers easily? without passing global objects to the functions all the time? is the only way is to bundle it all in one class that will be initialized with the 'db' variable? or there is other way? On May 4, 1:49 pm, mdipierro mdipie...@cs.depaul.edu wrote: A module is a module. You can import stuff form the module but the module will not see variables defined in the calling environment. In the module you can defined a function that takes db as parameter, import the funciton and call it with the db instance. You will have the problem not just for db, but also for the other web2py global objects. Massimo On May 4, 4:16 am, canna c.ne...@gmail.com wrote: hi all, I want to share a bunch of functions between controllers, so I moved them to a module called 'utilities' in the modules folder, and in the controller I import the module as suggested here in the forum: import applications.myapp.modules.utilities as util reload(util) the problem is, it's not working, I get an error: NameError: global name 'db' is not defined how can I get my 'utilities' file to recognize the global variable 'db'?
[web2py] using inline tables in the query (subquery in the FROM field)
Hello everybody! I really need help with a query I'm trying to execute in Web2Py DAL is there a way to use an inline table in the FROM field of a query? this is my query: SELECT SUM( HoursWorked / DayHoursSum ) AS DaysWorked FROM `Tasks_TimeLog` H, ( SELECT TheDate, User_id, SUM( HoursWorked ) AS DayHoursSum FROM `Tasks_TimeLog` GROUP BY TheDate, User_id )S WHERE H.User_id = S.User_id AND H.TheDate = S.TheDate AND Task='2' GROUP BY Task this is the inline table in Web2py: inlineTable=db()._select(db.Tasks_TimeLog.TheDate,db.Tasks_TimeLog.User_id,db.Tasks_TimeLog.HoursWorked.sum(),groupby=db.Tasks_TimeLog.TheDate| db.Tasks_TimeLog.User_id) how do I use the inline table in my full query?? rows=db(db.Tasks_TimeLog.Task=='2'.).select(.,groupby=db.Tasks_TimeLog.Task) Thanks to all the helpers!!
[web2py] Re: using inline tables in the query (subquery in the FROM field)
Thank you! I thought I was missing something you right, I used executesql anyway in case my question wont be answered :-) Thank you again for clearing this up! On Apr 13, 4:08 pm, mdipierro mdipie...@cs.depaul.edu wrote: DAL cannot do this. You need to use db.executesql(). sorry. On Apr 13, 5:06 am, canna c.ne...@gmail.com wrote: Hello everybody! I really need help with a query I'm trying to execute in Web2Py DAL is there a way to use an inline table in the FROM field of a query? this is my query: SELECT SUM( HoursWorked / DayHoursSum ) AS DaysWorked FROM `Tasks_TimeLog` H, ( SELECT TheDate, User_id, SUM( HoursWorked ) AS DayHoursSum FROM `Tasks_TimeLog` GROUP BY TheDate, User_id )S WHERE H.User_id = S.User_id AND H.TheDate = S.TheDate AND Task='2' GROUP BY Task this is the inline table in Web2py: inlineTable=db()._select(db.Tasks_TimeLog.TheDate,db.Tasks_TimeLog.User_id,db.Tasks_TimeLog.HoursWorked.sum(),groupby=db.Tasks_TimeLog.TheDate| db.Tasks_TimeLog.User_id) how do I use the inline table in my full query?? rows=db(db.Tasks_TimeLog.Task=='2'.).select(.,groupby=db.Tasks_TimeLog.Task) Thanks to all the helpers!!
[web2py] Re: is there a way to communicate with Web2Py from an external program?
thank you. I understand that I have to publish a service that can send and receive calls from clients what do I need to look for on the client side? meaning, what ability 3dsMax should have in order to use this service? On 22 מרץ, 21:28, mdipierro mdipie...@cs.depaul.edu wrote: Perhaps you can use XMLRPC described here:http://www.web2py.com/book/default/section/9/2 Perhaps other users have other/better solutions. On Mar 22, 2:02 pm, canna c.ne...@gmail.com wrote: Hello everybody! I making my first steps inWeb2Py, and although I'm not at this stage yet, I will eventually have to deal with this issue, and wanted to be prepared as a vfx studio we keep information on every 3D model that is created in 3D program (time spent working on it, it's status etc.) up until now we wrote this information (using scripts) to INI files, now we'll have to write to MySQL server. there is a way to send SQL queries from 3dsMax with .NET but then it's bypassweb2pyserver and doesn't benefit from it's useful model structure. is there a way for 3dsMax to send and receive information fromweb2py server without bumping into security issues? thanks to all the helpers!-הסתר טקסט מצוטט- -הראה טקסט מצוטט- -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] is there a way to communicate with Web2Py from an external program?
Hello everybody! I making my first steps in Web2Py, and although I'm not at this stage yet, I will eventually have to deal with this issue, and wanted to be prepared as a vfx studio we keep information on every 3D model that is created in 3D program (time spent working on it, it's status etc.) up until now we wrote this information (using scripts) to INI files, now we'll have to write to MySQL server. there is a way to send SQL queries from 3dsMax with .NET but then it's bypass web2py server and doesn't benefit from it's useful model structure. is there a way for 3dsMax to send and receive information from web2py server without bumping into security issues? thanks to all the helpers! -- You received this message because you are subscribed to the Google Groups web2py-users group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.