[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-08 Thread Felipe Meirelles
Well, the real problem is I'm using GAE with Google Cloud SQL, so I have 
the migrations problem but here is the fix:

On restricted.py line 72:

def _get_table(self, db, tablename, app):
tablename = tablename + '_' + app
try:
table = db[tablename]
except:
db.rollback()   # not necessary but one day
# any app may store tickets on DB
table = db.define_table(
tablename,
db.Field('ticket_id', length=100),
db.Field('ticket_data', 'text'),
db.Field('created_datetime', 'datetime'),
)
logging.info(table)
return table

The problem is web2py was trying to create the table in every request, even 
when it already exists (don't know why, but with lazy tables 
db.get(tablename, None) was returning none always). So I swaped to 
db[tablename] and added a exception handling for it. Seem to work just fine 
now. 

Can you take a look and see if this dosen't conflicts with another DBs to 
move it to trunk? Thanks!

Thanks.

On Friday, January 4, 2013 10:58:07 PM UTC-2, Massimo Di Pierro wrote:

 Admin is readonly on GAE and by default not deployed. 

 On Friday, 4 January 2013 17:10:56 UTC-6, Alan Etkin wrote:

 El jueves, 3 de enero de 2013 11:31:45 UTC-3, Felipe Meirelles escribió:

 Well, the problem is when the ticket is saved, self.db points to DAL 
 uri=google:sql://**:novello-solutionworkshop:novello-solutionworkshop/novello_test
  
 but when load() is called, it points to DAL uri=gae.


 AFAIK admin is db less. It uses the db of the app it manages. Besides, 
 wasn't admin disabled for GAE?



-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-08 Thread Felipe Meirelles
Never mind, this solution just worked the first time, when I need to define 
the table, the second time it fails too...

On Tuesday, January 8, 2013 4:21:01 PM UTC-2, Felipe Meirelles wrote:

 Well, the real problem is I'm using GAE with Google Cloud SQL, so I have 
 the migrations problem but here is the fix:

 On restricted.py line 72:

 def _get_table(self, db, tablename, app):
 tablename = tablename + '_' + app
 try:
 table = db[tablename]
 except:
 db.rollback()   # not necessary but one day
 # any app may store tickets on DB
 table = db.define_table(
 tablename,
 db.Field('ticket_id', length=100),
 db.Field('ticket_data', 'text'),
 db.Field('created_datetime', 'datetime'),
 )
 logging.info(table)
 return table

 The problem is web2py was trying to create the table in every request, 
 even when it already exists (don't know why, but with lazy tables 
 db.get(tablename, None) was returning none always). So I swaped to 
 db[tablename] and added a exception handling for it. Seem to work just fine 
 now. 

 Can you take a look and see if this dosen't conflicts with another DBs to 
 move it to trunk? Thanks!

 Thanks.

 On Friday, January 4, 2013 10:58:07 PM UTC-2, Massimo Di Pierro wrote:

 Admin is readonly on GAE and by default not deployed. 

 On Friday, 4 January 2013 17:10:56 UTC-6, Alan Etkin wrote:

 El jueves, 3 de enero de 2013 11:31:45 UTC-3, Felipe Meirelles escribió:

 Well, the problem is when the ticket is saved, self.db points to DAL 
 uri=google:sql://**:novello-solutionworkshop:novello-solutionworkshop/novello_test
  
 but when load() is called, it points to DAL uri=gae.


 AFAIK admin is db less. It uses the db of the app it manages. Besides, 
 wasn't admin disabled for GAE?



-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-08 Thread Felipe Meirelles
Now its working for all requests, but the solution is a little odd:
First try to get the table, then try to define it for the first time and if 
it fails, try to just define the table, with no migrate. Is this OK?

def _get_table(self, db, tablename, app):
tablename = tablename + '_' + app
logging.info(tablename)
table = None
try:
table = db[tablename]
except:
db.rollback()   # not necessary but one day
# any app may store tickets on DB
logging.info(Trying to create)
try:
db.define_table(
tablename,
db.Field('ticket_id', length=100),
db.Field('ticket_data', 'text'),
db.Field('created_datetime', 'datetime'),
)
table = db[tablename]
except:
try:
db.define_table(
tablename,
db.Field('ticket_id', length=100),
db.Field('ticket_data', 'text'),
db.Field('created_datetime', 'datetime'),
migrate=False
)
table = db[tablename]
except:
pass
return table

On Tuesday, January 8, 2013 4:34:39 PM UTC-2, Felipe Meirelles wrote:

 Never mind, this solution just worked the first time, when I need to 
 define the table, the second time it fails too...

 On Tuesday, January 8, 2013 4:21:01 PM UTC-2, Felipe Meirelles wrote:

 Well, the real problem is I'm using GAE with Google Cloud SQL, so I have 
 the migrations problem but here is the fix:

 On restricted.py line 72:

 def _get_table(self, db, tablename, app):
 tablename = tablename + '_' + app
 try:
 table = db[tablename]
 except:
 db.rollback()   # not necessary but one day
 # any app may store tickets on DB
 table = db.define_table(
 tablename,
 db.Field('ticket_id', length=100),
 db.Field('ticket_data', 'text'),
 db.Field('created_datetime', 'datetime'),
 )
 logging.info(table)
 return table

 The problem is web2py was trying to create the table in every request, 
 even when it already exists (don't know why, but with lazy tables 
 db.get(tablename, None) was returning none always). So I swaped to 
 db[tablename] and added a exception handling for it. Seem to work just fine 
 now. 

 Can you take a look and see if this dosen't conflicts with another DBs to 
 move it to trunk? Thanks!

 Thanks.

 On Friday, January 4, 2013 10:58:07 PM UTC-2, Massimo Di Pierro wrote:

 Admin is readonly on GAE and by default not deployed. 

 On Friday, 4 January 2013 17:10:56 UTC-6, Alan Etkin wrote:

 El jueves, 3 de enero de 2013 11:31:45 UTC-3, Felipe Meirelles escribió:

 Well, the problem is when the ticket is saved, self.db points to DAL 
 uri=google:sql://**:novello-solutionworkshop:novello-solutionworkshop/novello_test
  
 but when load() is called, it points to DAL uri=gae.


 AFAIK admin is db less. It uses the db of the app it manages. Besides, 
 wasn't admin disabled for GAE?



-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-04 Thread Alan Etkin
El jueves, 3 de enero de 2013 11:31:45 UTC-3, Felipe Meirelles escribió:

 Well, the problem is when the ticket is saved, self.db points to DAL 
 uri=google:sql://**:novello-solutionworkshop:novello-solutionworkshop/novello_test
  
 but when load() is called, it points to DAL uri=gae.


AFAIK admin is db less. It uses the db of the app it manages. Besides, 
wasn't admin disabled for GAE?

-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-04 Thread Massimo Di Pierro
Admin is readonly on GAE and by default not deployed. 

On Friday, 4 January 2013 17:10:56 UTC-6, Alan Etkin wrote:

 El jueves, 3 de enero de 2013 11:31:45 UTC-3, Felipe Meirelles escribió:

 Well, the problem is when the ticket is saved, self.db points to DAL 
 uri=google:sql://**:novello-solutionworkshop:novello-solutionworkshop/novello_test
  
 but when load() is called, it points to DAL uri=gae.


 AFAIK admin is db less. It uses the db of the app it manages. Besides, 
 wasn't admin disabled for GAE?



-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-03 Thread Felipe Meirelles
Massimo, just figured it out:

Using App Engine + Lazy Tables results on _get_table() in restricted.py 
line 77 returning None as the tablename all the times.

So I tried to set lazy_tables = False, then the table is found, but when

table.insert(ticket_id=ticket_id,
 ticket_data=cPickle.dumps(ticket_data),
 created_datetime=request.now)

is called, it returns the right ID, but is not inserted on the database...

Can you guys take a look?

Thanks


On Tuesday, December 18, 2012 2:52:56 PM UTC-2, Massimo Di Pierro wrote:

 If there is no ticket here is a problem talking to database or other 
 internal web2py error, not an application error. Please check for traceback 
 in the app engine logs.

 On Tuesday, 18 December 2012 06:08:56 UTC-6, Felipe Meirelles wrote:

 Hi, I'm using GAE + Cloud SQL but every time I get an error, there is no 
 ticket. Can I set web2py to save tickets to database as in Google NoSQL 
 (big table)?



-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-03 Thread Felipe Meirelles
Just added a self.db.commit() after the insert command, and it worked as 
spected, but the load() function cant retrieve the ticket data...

I've tried to inspect the select stmt with _select(), but it dosent returns 
the SQL. Any ideas?

On Thursday, January 3, 2013 11:07:04 AM UTC-2, Felipe Meirelles wrote:

 Massimo, just figured it out:

 Using App Engine + Lazy Tables results on _get_table() in restricted.py 
 line 77 returning None as the tablename all the times.

 So I tried to set lazy_tables = False, then the table is found, but when

 table.insert(ticket_id=ticket_id,
  ticket_data=cPickle.dumps(ticket_data),
  created_datetime=request.now)

 is called, it returns the right ID, but is not inserted on the database...

 Can you guys take a look?

 Thanks


 On Tuesday, December 18, 2012 2:52:56 PM UTC-2, Massimo Di Pierro wrote:

 If there is no ticket here is a problem talking to database or other 
 internal web2py error, not an application error. Please check for traceback 
 in the app engine logs.

 On Tuesday, 18 December 2012 06:08:56 UTC-6, Felipe Meirelles wrote:

 Hi, I'm using GAE + Cloud SQL but every time I get an error, there is no 
 ticket. Can I set web2py to save tickets to database as in Google NoSQL 
 (big table)?



-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-03 Thread Felipe Meirelles
Actualy, it is displaying the SQL as:

select [gluon.dal.Field object at 0x126F9290, gluon.dal.Field object at 
0x126F9170, gluon.dal.Field object at 0x126F9190, gluon.dal.Field 
object at 0x126F9210] where Query [(ticket_id = 
u'127.0.0.1.2013-01-03.13-22-37.4b65b4db-1e4f-48f1-baca-5f0201fdb53a':type 
'unicode')]


On Thursday, January 3, 2013 11:36:15 AM UTC-2, Felipe Meirelles wrote:

 Just added a self.db.commit() after the insert command, and it worked as 
 spected, but the load() function cant retrieve the ticket data...

 I've tried to inspect the select stmt with _select(), but it dosent 
 returns the SQL. Any ideas?

 On Thursday, January 3, 2013 11:07:04 AM UTC-2, Felipe Meirelles wrote:

 Massimo, just figured it out:

 Using App Engine + Lazy Tables results on _get_table() in restricted.py 
 line 77 returning None as the tablename all the times.

 So I tried to set lazy_tables = False, then the table is found, but when

 table.insert(ticket_id=ticket_id,
  ticket_data=cPickle.dumps(ticket_data),
  created_datetime=request.now)

 is called, it returns the right ID, but is not inserted on the database...

 Can you guys take a look?

 Thanks


 On Tuesday, December 18, 2012 2:52:56 PM UTC-2, Massimo Di Pierro wrote:

 If there is no ticket here is a problem talking to database or other 
 internal web2py error, not an application error. Please check for traceback 
 in the app engine logs.

 On Tuesday, 18 December 2012 06:08:56 UTC-6, Felipe Meirelles wrote:

 Hi, I'm using GAE + Cloud SQL but every time I get an error, there is 
 no ticket. Can I set web2py to save tickets to database as in Google NoSQL 
 (big table)?



-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-03 Thread Felipe Meirelles
Well, the problem is when the ticket is saved, self.db points to DAL 
uri=google:sql://**:novello-solutionworkshop:novello-solutionworkshop/novello_test
 
but when load() is called, it points to DAL uri=gae.

Where the admin application DAL is defined?

On Thursday, January 3, 2013 11:47:38 AM UTC-2, Felipe Meirelles wrote:

 Actualy, it is displaying the SQL as:

 select [gluon.dal.Field object at 0x126F9290, gluon.dal.Field object at 
 0x126F9170, gluon.dal.Field object at 0x126F9190, gluon.dal.Field 
 object at 0x126F9210] where Query [(ticket_id = 
 u'127.0.0.1.2013-01-03.13-22-37.4b65b4db-1e4f-48f1-baca-5f0201fdb53a':type 
 'unicode')]


 On Thursday, January 3, 2013 11:36:15 AM UTC-2, Felipe Meirelles wrote:

 Just added a self.db.commit() after the insert command, and it worked as 
 spected, but the load() function cant retrieve the ticket data...

 I've tried to inspect the select stmt with _select(), but it dosent 
 returns the SQL. Any ideas?

 On Thursday, January 3, 2013 11:07:04 AM UTC-2, Felipe Meirelles wrote:

 Massimo, just figured it out:

 Using App Engine + Lazy Tables results on _get_table() in restricted.py 
 line 77 returning None as the tablename all the times.

 So I tried to set lazy_tables = False, then the table is found, but when

 table.insert(ticket_id=ticket_id,
  ticket_data=cPickle.dumps(ticket_data),
  created_datetime=request.now)

 is called, it returns the right ID, but is not inserted on the 
 database...

 Can you guys take a look?

 Thanks


 On Tuesday, December 18, 2012 2:52:56 PM UTC-2, Massimo Di Pierro wrote:

 If there is no ticket here is a problem talking to database or other 
 internal web2py error, not an application error. Please check for 
 traceback 
 in the app engine logs.

 On Tuesday, 18 December 2012 06:08:56 UTC-6, Felipe Meirelles wrote:

 Hi, I'm using GAE + Cloud SQL but every time I get an error, there is 
 no ticket. Can I set web2py to save tickets to database as in Google 
 NoSQL 
 (big table)?



-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2013-01-03 Thread Massimo Di Pierro
I am not sure I understand the context here. Why do you have two dal uri? 
What load function?

On Thursday, 3 January 2013 08:31:45 UTC-6, Felipe Meirelles wrote:

 Well, the problem is when the ticket is saved, self.db points to DAL 
 uri=google:sql://**:novello-solutionworkshop:novello-solutionworkshop/novello_test
  
 but when load() is called, it points to DAL uri=gae.

 Where the admin application DAL is defined?

 On Thursday, January 3, 2013 11:47:38 AM UTC-2, Felipe Meirelles wrote:

 Actualy, it is displaying the SQL as:

 select [gluon.dal.Field object at 0x126F9290, gluon.dal.Field object 
 at 0x126F9170, gluon.dal.Field object at 0x126F9190, gluon.dal.Field 
 object at 0x126F9210] where Query [(ticket_id = 
 u'127.0.0.1.2013-01-03.13-22-37.4b65b4db-1e4f-48f1-baca-5f0201fdb53a':type 
 'unicode')]


 On Thursday, January 3, 2013 11:36:15 AM UTC-2, Felipe Meirelles wrote:

 Just added a self.db.commit() after the insert command, and it worked as 
 spected, but the load() function cant retrieve the ticket data...

 I've tried to inspect the select stmt with _select(), but it dosent 
 returns the SQL. Any ideas?

 On Thursday, January 3, 2013 11:07:04 AM UTC-2, Felipe Meirelles wrote:

 Massimo, just figured it out:

 Using App Engine + Lazy Tables results on _get_table() in restricted.py 
 line 77 returning None as the tablename all the times.

 So I tried to set lazy_tables = False, then the table is found, but when

 table.insert(ticket_id=ticket_id,
  ticket_data=cPickle.dumps(ticket_data),
  created_datetime=request.now)

 is called, it returns the right ID, but is not inserted on the 
 database...

 Can you guys take a look?

 Thanks


 On Tuesday, December 18, 2012 2:52:56 PM UTC-2, Massimo Di Pierro wrote:

 If there is no ticket here is a problem talking to database or other 
 internal web2py error, not an application error. Please check for 
 traceback 
 in the app engine logs.

 On Tuesday, 18 December 2012 06:08:56 UTC-6, Felipe Meirelles wrote:

 Hi, I'm using GAE + Cloud SQL but every time I get an error, there is 
 no ticket. Can I set web2py to save tickets to database as in Google 
 NoSQL 
 (big table)?



-- 





[web2py] Re: GAE + Cloud SQL: Tickets

2012-12-18 Thread Massimo Di Pierro
If there is no ticket here is a problem talking to database or other 
internal web2py error, not an application error. Please check for traceback 
in the app engine logs.

On Tuesday, 18 December 2012 06:08:56 UTC-6, Felipe Meirelles wrote:

 Hi, I'm using GAE + Cloud SQL but every time I get an error, there is no 
 ticket. Can I set web2py to save tickets to database as in Google NoSQL 
 (big table)?

--