Re: [web2py] Re: Prevent translation of the labels in the Log In form

2012-11-07 Thread Jan Rozhon
Sorry, I had a typo in the line. Now it is working - put 
auth.messages.label_password= 'Password ' with space in the model.


Thank you very much Niphlod


On 06/11/12 23:53, Niphlod wrote:

did you put that between
auth = Auth(...)
and
auth.define_tables() ?


On Tuesday, November 6, 2012 11:32:18 PM UTC+1, Jan Rozhon wrote:

Nope, no change still the local translation of the word Password
in the form :(. Inserted into db.py in the auth section.

Jan

Dne úterý, 6. listopadu 2012 16:18:49 UTC+1 Niphlod napsal(a):

if you don't change the string that has already a translation
it gets translated.
try with auth.messages.label_password= 'Password ##fixed in
english'

Il giorno martedě 6 novembre 2012 15:56:50 UTC+1, Jan Rozhon
ha scritto:

Hi, thanks for quick hint. Tried
adding auth.messages.label_password= 'Password' into my
model, but the label still gets translated. I modified it
to 'test', but the label didnt change.

Jan

Dne úterý, 6. listopadu 2012 15:29:48 UTC+1 Niphlod
napsal(a):

auth.messages settings... these are the defaults, but
they get to be translated by default (and normally is
a good thing). If you set them as
auth.messages.label_first_name = 'test' they shouldn't
be translated at all.

label_first_name='First name',
label_last_name='Last name',
label_username='Username',
label_email='E-mail',
label_password='Password',
label_registration_key='Registration key',
label_reset_password_key='Reset Password key',
label_registration_id='Registration identifier',
label_role='Role',
label_description='Description',
label_user_id='User ID',
label_group_id='Group ID',
label_name='Name',
label_table_name='Object or table name',
label_record_id='Record ID',
label_time_stamp='Timestamp',
label_client_ip='Client IP',
label_origin='Origin',
label_remember_me=Remember me (for 30 days),

On Tuesday, November 6, 2012 3:06:08 PM UTC+1, Jan
Rozhon wrote:

Hi, I am facing the problem that my Login
(.../user/login) form uses translations for its
labels and I need to forbid this behavior. What is
the correct way of doing this?

Thanks, Jan

--





--





[web2py] Prevent translation of the labels in the Log In form

2012-11-06 Thread Jan Rozhon
Hi, I am facing the problem that my Login (.../user/login) form uses 
translations for its labels and I need to forbid this behavior. What is the 
correct way of doing this?

Thanks, Jan

-- 





[web2py] Re: Prevent translation of the labels in the Log In form

2012-11-06 Thread Jan Rozhon
Hi, thanks for quick hint. Tried adding auth.messages.label_password= 
'Password' into my model, but the label still gets translated. I modified 
it to 'test', but the label didnt change.

Jan

Dne úterý, 6. listopadu 2012 15:29:48 UTC+1 Niphlod napsal(a):

 auth.messages settings... these are the defaults, but they get to be 
 translated by default (and normally is a good thing). If you set them as 
 auth.messages.label_first_name = 'test' they shouldn't be translated at all.

 label_first_name='First name',
 label_last_name='Last name',
 label_username='Username',
 label_email='E-mail',
 label_password='Password',
 label_registration_key='Registration key',
 label_reset_password_key='Reset Password key',
 label_registration_id='Registration identifier',
 label_role='Role',
 label_description='Description',
 label_user_id='User ID',
 label_group_id='Group ID',
 label_name='Name',
 label_table_name='Object or table name',
 label_record_id='Record ID',
 label_time_stamp='Timestamp',
 label_client_ip='Client IP',
 label_origin='Origin',
 label_remember_me=Remember me (for 30 days),

 On Tuesday, November 6, 2012 3:06:08 PM UTC+1, Jan Rozhon wrote:

 Hi, I am facing the problem that my Login (.../user/login) form uses 
 translations for its labels and I need to forbid this behavior. What is the 
 correct way of doing this?

 Thanks, Jan



-- 





[web2py] Re: Prevent translation of the labels in the Log In form

2012-11-06 Thread Jan Rozhon
Nope, no change still the local translation of the word Password in the 
form :(. Inserted into db.py in the auth section.

Jan

Dne úterý, 6. listopadu 2012 16:18:49 UTC+1 Niphlod napsal(a):

 if you don't change the string that has already a translation it gets 
 translated.
 try with auth.messages.label_password= 'Password ##fixed in english' 

 Il giorno martedì 6 novembre 2012 15:56:50 UTC+1, Jan Rozhon ha scritto:

 Hi, thanks for quick hint. Tried adding auth.messages.label_password= 
 'Password' into my model, but the label still gets translated. I modified 
 it to 'test', but the label didnt change.

 Jan

 Dne úterý, 6. listopadu 2012 15:29:48 UTC+1 Niphlod napsal(a):

 auth.messages settings... these are the defaults, but they get to be 
 translated by default (and normally is a good thing). If you set them as 
 auth.messages.label_first_name = 'test' they shouldn't be translated at all.

 label_first_name='First name',
 label_last_name='Last name',
 label_username='Username',
 label_email='E-mail',
 label_password='Password',
 label_registration_key='Registration key',
 label_reset_password_key='Reset Password key',
 label_registration_id='Registration identifier',
 label_role='Role',
 label_description='Description',
 label_user_id='User ID',
 label_group_id='Group ID',
 label_name='Name',
 label_table_name='Object or table name',
 label_record_id='Record ID',
 label_time_stamp='Timestamp',
 label_client_ip='Client IP',
 label_origin='Origin',
 label_remember_me=Remember me (for 30 days),

 On Tuesday, November 6, 2012 3:06:08 PM UTC+1, Jan Rozhon wrote:

 Hi, I am facing the problem that my Login (.../user/login) form uses 
 translations for its labels and I need to forbid this behavior. What is 
 the 
 correct way of doing this?

 Thanks, Jan



-- 





Re: [web2py] Re: Prevent translation of the labels in the Log In form

2012-11-06 Thread Jan Rozhon
Yep, thats the place I put it to. Is there a way to force english if I 
cannot prevent translation? I have tried modifying routes.py in my app, 
but no luck so far.


Thanks, Jan

On 06/11/12 23:53, Niphlod wrote:

did you put that between
auth = Auth(...)
and
auth.define_tables() ?


On Tuesday, November 6, 2012 11:32:18 PM UTC+1, Jan Rozhon wrote:

Nope, no change still the local translation of the word Password
in the form :(. Inserted into db.py in the auth section.

Jan

Dne úterý, 6. listopadu 2012 16:18:49 UTC+1 Niphlod napsal(a):

if you don't change the string that has already a translation
it gets translated.
try with auth.messages.label_password= 'Password ##fixed in
english'

Il giorno martedì 6 novembre 2012 15:56:50 UTC+1, Jan Rozhon
ha scritto:

Hi, thanks for quick hint. Tried
adding auth.messages.label_password= 'Password' into my
model, but the label still gets translated. I modified it
to 'test', but the label didnt change.

Jan

Dne úterý, 6. listopadu 2012 15:29:48 UTC+1 Niphlod
napsal(a):

auth.messages settings... these are the defaults, but
they get to be translated by default (and normally is
a good thing). If you set them as
auth.messages.label_first_name = 'test' they shouldn't
be translated at all.

label_first_name='First name',
label_last_name='Last name',
label_username='Username',
label_email='E-mail',
label_password='Password',
label_registration_key='Registration key',
label_reset_password_key='Reset Password key',
label_registration_id='Registration identifier',
label_role='Role',
label_description='Description',
label_user_id='User ID',
label_group_id='Group ID',
label_name='Name',
label_table_name='Object or table name',
label_record_id='Record ID',
label_time_stamp='Timestamp',
label_client_ip='Client IP',
label_origin='Origin',
label_remember_me=Remember me (for 30 days),

On Tuesday, November 6, 2012 3:06:08 PM UTC+1, Jan
Rozhon wrote:

Hi, I am facing the problem that my Login
(.../user/login) form uses translations for its
labels and I need to forbid this behavior. What is
the correct way of doing this?

Thanks, Jan

--





--





[web2py] Initial app setup

2012-10-06 Thread Jan Rozhon
Hi, I am facing the problem how to detect if the user is running the 
application for the first time and if so how to redirect all the requests 
to the page that would allow the initial setting of database connection and 
some other params. Is there a standardized way to achieve this and I am 
just missing it or do I need to tweak the app for myself?

Thanks for suggestions and again sorry if this is already discussed 
elsewhere, Jan

-- 





[web2py] Delete EXPORT button from SQLFORM.grid

2012-08-15 Thread Jan Rozhon
Hi all, 

did someone solve how to remove the export button from the SQLform.grid? 
Additionally, what is the proper way to display JSON string in the field?

Thanks for any hints, Jan

-- 





Re: [web2py] Delete EXPORT button from SQLFORM.grid

2012-08-15 Thread Jan Rozhon
Silly me didnt notice this option. Thx 

Dne středa, 15. srpna 2012 11:43:46 UTC+2 Johann Spies napsal(a):

 On 15 August 2012 11:31, Jan Rozhon jan.r...@gmail.com javascript:wrote:



 did someone solve how to remove the export button from the SQLform.grid? 


 Use the option: csv = False when you define the grid.

 Regards
 Johann 

 -- 
 Because experiencing your loyal love is better than life itself, 
 my lips will praise you.  (Psalm 63:3)



-- 





[web2py] Re: Cron problems

2012-06-09 Thread Jan Rozhon
Hi, any update on this topic? I am just facing that same issue, Thanks 
Michael for writing down a workaround.

Jan.

Dne středa, 23. května 2012 16:21:02 UTC+2 Massimo Di Pierro napsal(a):

 Please open a ticket about this. cron was not designed to do this but 
 there is no reason it cannot do it.

 On Tuesday, 22 May 2012 22:33:57 UTC-5, Michael Toomim wrote:

 I'm finding multiple problems getting cron to start the scheduler. Here's 
 the cron line:   
 @reboot dummyuser python web2py.py -K utility
 ...but it does not work without modifying web2py source.

 First, let's get an easy bug out of the way. The web2py book gives this 
 example for @reboot:

 @reboot * * * * root *mycontroller/myfunction

 But those asterisks shouldn't be there for @reboot tasks. Can we remove 
 them from the book?

 Now, when I put that line into my crontab and run web2py, it gives me 
 this error:

 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2011
 Version 1.99.7 (2012-03-04 22:12:08) stable
 Database drivers available: SQLite3, pymysql, psycopg2, pg8000, CouchDB, 
 IMAP
 Starting hardcron...
 please visit:
 http://192.168.56.101:8000
 use kill -SIGTERM 10818 to shutdown the web2py server
 Exception in thread Thread-2:
 Traceback (most recent call last):
   File /usr/lib/python2.6/threading.py, line 532, in __bootstrap_inner
 self.run()
   File /home/toomim/projects/utility/web2py/gluon/newcron.py, line 234, 
 in run
 shell=self.shell)
   File /usr/lib/python2.6/subprocess.py, line 633, in __init__
 errread, errwrite)
   File /usr/lib/python2.6/subprocess.py, line 1139, in _execute_child
 raise child_exception
 OSError: [Errno 2] No such file or directory

 This is an error in subprocess.Popen. I inserted some print statements 
 and found that it's calling it like this:
 subprocess.Popen('python web2py.py -K utility')

 This is incorrect, it should be:
 subprocess.Popen(['python', 'web2py.py' '-K' 'utility'])

 I was able to make it work by adding a call to split(), as you can see 
 here (in newcron.py: cronlauncher.run()):
 def run(self):
 import subprocess
 proc = subprocess.Popen(self.cmd.split(),

 But I do not understand how anybody could have made this work before, 
 without adding a split() call? And what confuses me further is that there 
 is an explicit join() call in the __init__() method that runs immediately 
 beforehand, as if we really did NOT want to have lists:

 elif isinstance(cmd,list):
 cmd = ' '.join(cmd)

 So does cron @reboot work for anybody running a script? It seems 
 impossible for it to work right now. Is this a bug?

 Finally, it would be great if we did not have to pass in a dummy user to 
 each cron line that does nothing...



Re: [web2py] Re: Web2py execution blocking

2012-06-08 Thread Jan Rozhon
Hi all, after two days of struggle I have found the reason of my troubles. 
The source of my issues is my javascript, which succeeds in completely 
blocking the web browser which then appears to be waiting for the response 
from the server which is not the actual situation, because in other browser 
I get the response with the lightning speed. Thank you all for 
your advices, I learnt a lot and my python code is much cleaner now, just 
hope I can do the same with my JS. 

Re: [web2py] Re: Web2py execution blocking

2012-06-05 Thread Jan Rozhon
I did some more testing and the problem still occures, not so frequently, 
but it does meaning the single json call didnt solve the issue. Now I am 
about to give it a try with MySQL, however I doubt it will help, because I 
put a comment as the first action in the mentioned controller and not even 
this action is performed, which leads me to opinion that web2py is doing 
something else while I try to access this controller. Can I somehow find 
out what it could be or what is the last action web2py performed?

Thank you, Jan

Dne úterý, 5. června 2012 10:05:24 UTC+2 mcm napsal(a):

 @Jan 

 Just a doubt.  There are two mutexes when using sqlite 
 - session opening (normal) 
 - db access (only with sqlite) 



 You should see what happens using another db (RDBMS like postgresql, 
 mysql). If that solves the problem, you found a bug. 
 Then post an issue on web2py.googlecode.com 

 mic 


 2012/6/4 Jan Rozhon jan.roz...@gmail.com: 
  Yea, it is sqlite db. May it cause the trouble? Thanks Jan. 
  
  Dne pondělí, 4. června 2012 21:53:20 UTC+2 mcm napsal(a): 
  
  @Jan 
  
  are you using sqlite? 
  
  mic 
  
  
  2012/6/4 Massimo Di Pierro massimo.dipie...@gmail.com: 
   I do not know what may be causing it, except that: 
   
   - one ajax/json call is better than many 
   - each call will lock the session for the use which means they are 
 not 
   executed concurrently, they are queued, unless you 
   session._unlock(response). 
   
   
   
   On Monday, 4 June 2012 11:02:23 UTC-5, Jan Rozhon wrote: 
   
   Hi Massimo, 
   
   thank you for your answer. Unfortunately, it didnt help. One thing I 
   didn't mention and might be causing this trouble is, that I ask for 
   several 
   json values provided by similar controllers as I posted in my first 
   post. 
   Can the multitude ofjson requests cause this weird behaviour? In 
 other 
   words, is it better to provide several small json streams or one 
 large? 
   
   Thanks in advance, Jan 
   
   Dne pondělí, 4. června 2012 17:38:41 UTC+2 Massimo Di Pierro 
 napsal(a): 
   
   Try replace output=rows with output=rows.as_list() 
   Perhaps the rows are not json serializable. 
   
   On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote: 
   
   Hi group, I have encountered a problem when I try to call a 
   controller 
   which should return a JSON array of values from database. However 
 in 
   abou 1 
   of 5 cases this call stucks in loading phase (chrome animation 
 in 
   tab) and 
   no response is received. Data is in database, every other 
 controller 
   is 
   working fine, cpu utilization is pretty low so is the memory and 
   there are 
   only about 1 rows in DB. Could you please give me some hints? 
   
   Thanks, Jan 
   
   PS. The controller looks like this: 
   
   def dberrorsselect(): 
   Performs sql query to get the errors in the form of list of 
   dicts 
   such as {field_name:value}. This is then transformed to json dict 
 for 
   transfer. 
   if session.tb_id: 
   
   
   
 max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
  

   if max_id != None: 
   selector_id=int(max_id)-5 
   else: 
   selector_id=0 
   rows=tb((tb.errors.test_id==session.tb_id)(tb.errors.id 
   selector_id)).select(tb.errors.ts, tb.errors.msg_short, 
   tb.errors.msg_long) 
   output=rows 
   else: 
   output=[] 
   return dict(output=output) 
   
   
   



Re: [web2py] Re: Web2py execution blocking

2012-06-05 Thread Jan Rozhon
One more thing, I am running a background job as well, can it block the 
web2py's execution? 


Re: [web2py] Re: Web2py execution blocking

2012-06-05 Thread Jan Rozhon
I understand this, but this would cause web2py to hang on the db select in 
the controller or not to enter the controller at all? I am still confused, 
that nothing from the controller is run not even the simple print 
something clause.

Dne úterý, 5. června 2012 18:03:32 UTC+2 Massimo Di Pierro napsal(a):

 Yes. The background process will lock the db every time you write until 
 you explicitely commit.

 On Tuesday, 5 June 2012 10:29:00 UTC-5, Jan Rozhon wrote:

 One more thing, I am running a background job as well, can it block the 
 web2py's execution? 



Re: [web2py] Re: Web2py execution blocking

2012-06-05 Thread Jan Rozhon
Ok, thank you both, I will recheck my code for commits and try tomorrow 
again and write the conclusion.

Jan

Dne úterý, 5. června 2012 21:02:44 UTC+2 mcm napsal(a):

 Jan, 

 Yes a subprocess will block  when the DAL tries to open the db file; 
 i.e. in the model file before entering executing the controller code. 

 If you use a RDBMS, assigning a dedicated db connection to the 
 process, you will not incur in the problem so frequently.  Anyway if 
 the subprocess never closes the transaction the controller sooner or 
 later will still lock up, unless you use only read-only selects both 
 in subprocess and controller. 
 Just do as Massimo says: keep doing commit or rollback in the 
 subprocess and the problem should go away.  There is no reason to keep 
 transaction open longer than  necessary, increasing the likelihood of 
 data conflict on commit. 

 mic 


 2012/6/5 Jan Rozhon jan.roz...@gmail.com: 
  I understand this, but this would cause web2py to hang on the db select 
 in 
  the controller or not to enter the controller at all? I am still 
 confused, 
  that nothing from the controller is run not even the simple print 
  something clause. 
  
  Dne úterý, 5. června 2012 18:03:32 UTC+2 Massimo Di Pierro napsal(a): 
  
  Yes. The background process will lock the db every time you write until 
  you explicitely commit. 
  
  On Tuesday, 5 June 2012 10:29:00 UTC-5, Jan Rozhon wrote: 
  
  One more thing, I am running a background job as well, can it block 
 the 
  web2py's execution? 



Re: [web2py] Re: Web2py execution blocking

2012-06-05 Thread Jan Rozhon
Nope, purely linux.

Dne úterý, 5. června 2012 22:11:08 UTC+2 Niphlod napsal(a):

 are you by any chance on windows ?

 I'm testing my app on that and for sure something is going on like you 
 described.

 I have a page full of loaded ajax components that on linux load 
 semi-concurrently while on windows they are fully serialized (i.e. the 
 browser fires ajax all in one time and on linux several of them are 
 loaded at once while on windows the next request is fullfilled only if 
 the previous one is completed).



Re: [web2py] Re: Web2py execution blocking

2012-06-05 Thread Jan Rozhon
No need to apologize, I welcome all suggestions, moreover this is always 
good to know.

Dne úterý, 5. června 2012 22:25:06 UTC+2 Niphlod napsal(a):

 sorry for that.. just to showcase the behaviour, same app, same db, 
 same web2py version, same python version, same libraries, only windows vs 
 linux




[web2py] Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Hi group, I have encountered a problem when I try to call a controller 
which should return a JSON array of values from database. However in abou 1 
of 5 cases this call stucks in loading phase (chrome animation in tab) 
and no response is received. Data is in database, every other controller is 
working fine, cpu utilization is pretty low so is the memory and there are 
only about 1 rows in DB. Could you please give me some hints?

Thanks, Jan

PS. The controller looks like this:

def dberrorsselect():
Performs sql query to get the errors in the form of list of dicts 
such as {field_name:value}. This is then transformed to json dict for 
transfer.
if session.tb_id:

max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
if max_id != None:
selector_id=int(max_id)-5
else:
selector_id=0
rows=tb((tb.errors.test_id==session.tb_id)(tb.errors.id  
selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
output=rows
else:
output=[] 
return dict(output=output)




[web2py] Re: Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Update, I have added several comments to this controller to see, where it 
gets block, the funny thing is that nothing really happens in those weird 
cases meaning that the controller is not executed at all, until I kill some 
spawned processes run by subprocess module, after that it appears, that all 
the request that came in the time period when controller was malfunctioning 
are handled at once (all comments appeared repeatedly). Maybe some problem 
with process spawning?

Thanks, Jan 

Dne pondělí, 4. června 2012 9:20:39 UTC+2 Jan Rozhon napsal(a):

 Hi group, I have encountered a problem when I try to call a controller 
 which should return a JSON array of values from database. However in abou 1 
 of 5 cases this call stucks in loading phase (chrome animation in tab) 
 and no response is received. Data is in database, every other controller is 
 working fine, cpu utilization is pretty low so is the memory and there are 
 only about 1 rows in DB. Could you please give me some hints?

 Thanks, Jan

 PS. The controller looks like this:

 def dberrorsselect():
 Performs sql query to get the errors in the form of list of dicts 
 such as {field_name:value}. This is then transformed to json dict for 
 transfer.
 if session.tb_id:
 
 max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
 if max_id != None:
 selector_id=int(max_id)-5
 else:
 selector_id=0
 rows=tb((tb.errors.test_id==session.tb_id)(tb.errors.id  
 selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
 output=rows
 else:
 output=[] 
 return dict(output=output)




[web2py] Re: Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Hi Massimo,

thank you for your answer. Unfortunately, it didnt help. One thing I didn't 
mention and might be causing this trouble is, that I ask for several json 
values provided by similar controllers as I posted in my first post. Can 
the multitude ofjson requests cause this weird behaviour? In other words, 
is it better to provide several small json streams or one large?

Thanks in advance, Jan

Dne pondělí, 4. června 2012 17:38:41 UTC+2 Massimo Di Pierro napsal(a):

 Try replace output=rows with output=rows.as_list()
 Perhaps the rows are not json serializable.

 On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote:

 Hi group, I have encountered a problem when I try to call a controller 
 which should return a JSON array of values from database. However in abou 1 
 of 5 cases this call stucks in loading phase (chrome animation in tab) 
 and no response is received. Data is in database, every other controller is 
 working fine, cpu utilization is pretty low so is the memory and there are 
 only about 1 rows in DB. Could you please give me some hints?

 Thanks, Jan

 PS. The controller looks like this:

 def dberrorsselect():
 Performs sql query to get the errors in the form of list of dicts 
 such as {field_name:value}. This is then transformed to json dict for 
 transfer.
 if session.tb_id:
 
 max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
 if max_id != None:
 selector_id=int(max_id)-5
 else:
 selector_id=0
 rows=tb((tb.errors.test_id==session.tb_id)(tb.errors.id  
 selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
 output=rows
 else:
 output=[] 
 return dict(output=output)




[web2py] Re: Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Ok, I have redesigned the page so that there is only one json call every 5 
seconds instead of 3. It looks better, 4 from 4 trials were ok . Previously 
I have never achieved 3 consecutive successful trials, so there is an 
improvement,  but I am not certain that the problem is really gone. I will 
do some more testing a write to the thread.
Again, thank you Massimo.

Dne pondělí, 4. června 2012 21:50:20 UTC+2 Massimo Di Pierro napsal(a):

 I do not know what may be causing it, except that:

 - one ajax/json call is better than many
 - each call will lock the session for the use which means they are not 
 executed concurrently, they are queued, unless you 
 session._unlock(response).



 On Monday, 4 June 2012 11:02:23 UTC-5, Jan Rozhon wrote:

 Hi Massimo,

 thank you for your answer. Unfortunately, it didnt help. One thing I 
 didn't mention and might be causing this trouble is, that I ask for several 
 json values provided by similar controllers as I posted in my first post. 
 Can the multitude ofjson requests cause this weird behaviour? In other 
 words, is it better to provide several small json streams or one large?

 Thanks in advance, Jan

 Dne pondělí, 4. června 2012 17:38:41 UTC+2 Massimo Di Pierro napsal(a):

 Try replace output=rows with output=rows.as_list()
 Perhaps the rows are not json serializable.

 On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote:

 Hi group, I have encountered a problem when I try to call a controller 
 which should return a JSON array of values from database. However in abou 
 1 
 of 5 cases this call stucks in loading phase (chrome animation in tab) 
 and no response is received. Data is in database, every other controller 
 is 
 working fine, cpu utilization is pretty low so is the memory and there are 
 only about 1 rows in DB. Could you please give me some hints?

 Thanks, Jan

 PS. The controller looks like this:

 def dberrorsselect():
 Performs sql query to get the errors in the form of list of 
 dicts such as {field_name:value}. This is then transformed to json dict 
 for 
 transfer.
 if session.tb_id:
 
 max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
 if max_id != None:
 selector_id=int(max_id)-5
 else:
 selector_id=0
 rows=tb((tb.errors.test_id==session.tb_id)(tb.errors.id  
 selector_id)).select(tb.errors.ts, tb.errors.msg_short, tb.errors.msg_long)
 output=rows
 else:
 output=[] 
 return dict(output=output)




Re: [web2py] Re: Web2py execution blocking

2012-06-04 Thread Jan Rozhon
Yea, it is sqlite db. May it cause the trouble? Thanks Jan.

Dne pondělí, 4. června 2012 21:53:20 UTC+2 mcm napsal(a):

 @Jan 

 are you using sqlite? 

 mic 


 2012/6/4 Massimo Di Pierro massimo.dipie...@gmail.com: 
  I do not know what may be causing it, except that: 
  
  - one ajax/json call is better than many 
  - each call will lock the session for the use which means they are not 
  executed concurrently, they are queued, unless you 
  session._unlock(response). 
  
  
  
  On Monday, 4 June 2012 11:02:23 UTC-5, Jan Rozhon wrote: 
  
  Hi Massimo, 
  
  thank you for your answer. Unfortunately, it didnt help. One thing I 
  didn't mention and might be causing this trouble is, that I ask for 
 several 
  json values provided by similar controllers as I posted in my first 
 post. 
  Can the multitude ofjson requests cause this weird behaviour? In other 
  words, is it better to provide several small json streams or one large? 
  
  Thanks in advance, Jan 
  
  Dne pondělí, 4. června 2012 17:38:41 UTC+2 Massimo Di Pierro napsal(a): 
  
  Try replace output=rows with output=rows.as_list() 
  Perhaps the rows are not json serializable. 
  
  On Monday, 4 June 2012 02:20:39 UTC-5, Jan Rozhon wrote: 
  
  Hi group, I have encountered a problem when I try to call a 
 controller 
  which should return a JSON array of values from database. However in 
 abou 1 
  of 5 cases this call stucks in loading phase (chrome animation in 
 tab) and 
  no response is received. Data is in database, every other controller 
 is 
  working fine, cpu utilization is pretty low so is the memory and 
 there are 
  only about 1 rows in DB. Could you please give me some hints? 
  
  Thanks, Jan 
  
  PS. The controller looks like this: 
  
  def dberrorsselect(): 
  Performs sql query to get the errors in the form of list of 
 dicts 
  such as {field_name:value}. This is then transformed to json dict for 
  transfer. 
  if session.tb_id: 
  
  
 max_id=tb(tb.errors.test_id==session.tb_id).select(tb.errors.id.max()).first()[tb.errors.id.max()]
  

  if max_id != None: 
  selector_id=int(max_id)-5 
  else: 
  selector_id=0 
  rows=tb((tb.errors.test_id==session.tb_id)(tb.errors.id  
  selector_id)).select(tb.errors.ts, tb.errors.msg_short, 
 tb.errors.msg_long) 
  output=rows 
  else: 
  output=[] 
  return dict(output=output) 
  
  
  



[web2py] Cannot operate on a closed database confusion

2012-05-18 Thread Jan Rozhon
Hi group,

I am stuck with a database problem in my project and I am unable to figure 
out, what is wrong. Basically, in *models* I define database (*tb*) and 
two *classes* (*sip_test* and *resmon*). The first class only runs 
several shell commands, but the second class i overseeing the outcome of 
the first class and therefore I run it in *separate thread* so it does not 
block the whole w2p with its periodic tasks. In this second class I am 
trying to *insert some values into database* (tb) but I get *Cannot 
operate on a closed database*. error. If I try to insert same values from 
controller it works fine, but not in any instance of this class. Could you 
point me to direction where the problem could be and possibly how to solve 
it?

Thanks in advance.

PS. I googled several thinks about threads and this db error, but they 
confused me even more, so sorry, if the answer is in there and I dont see 
it.


Re: [web2py] Cannot operate on a closed database confusion

2012-05-18 Thread Jan Rozhon
Thanks for hints, I will take a look at what you have mentioned. Threading 
seemed to me as the only option how to perform periodic updates of database 
without blocking web2py's main thead. I though about using AJAX/jQuery, but 
since there is no web page (view or controller) for the functionality 
threading appeared as the proper way...

Jan

Dne pátek, 18. května 2012 16:41:30 UTC+2 Richard napsal(a):

 I am not the best to help you... But maybe if you put your class in module 
 it could help... Also, maybe read Bruno's thread about models2modules it 
 will help you figure out (maybe) how to work with class in web2py. 

 Only one question, is it required that you use threading?

 Richard

 On Fri, May 18, 2012 at 9:44 AM, Jan Rozhon jan.roz...@gmail.com wrote:

 Sure, here is part of my model. Jan

 # coding: utf8

 import re
 import ast
 import applications.SIP_Tester.modules.functions as functions
 import os
 import shutil
 import subprocess
 import threading
 import time
 from  datetime import datetime

 tb = DAL('sqlite://tb.sqlite') # test database
 tb.define_table('tests',
  Field('test_id', 'integer', requires=IS_INT_IN_RANGE(0,
 65535), notnull=True, required=True, label='Test ID'),
  Field('ts', 'datetime', 
 requires=IS_DATETIME(format=T('%Y-%m-%d 
 %H:%M:%S'), error_message='must be -MM-DD HH:MM:SS!'), label=
 'Timestamp'),
  Field('args', 'text', requires=IS_LENGTH(65536), 
 label='Test 
 Arguments'),
  format='%(test_id)s')
 tb.define_table('counts',
  Field('test_id', tb.tests, ondelete='CASCADE', notnull=
 True, requires=IS_IN_DB(tb, tb.tests.test_id, '%(test_id)s')),
  Field('test_pid', 'integer', requires=IS_INT_IN_RANGE(0,
 65535), notnull=True, required=True, label='Test PID'),
  Field('ts', 'datetime', 
 requires=IS_DATETIME(format=T('%Y-%m-%d 
 %H:%M:%S'), error_message='must be -MM-DD HH:MM:SS!'), label=
 'Timestamp'),
  Field('msg_idx', 'integer', requires=IS_INT_IN_RANGE(0,
 1), label='Message Index'),
  Field('msg_name', 'string', requires=IS_LENGTH(100),label
 ='Message Name'),
  Field('msg_mode', 'string', requires=IS_LENGTH(10),label
 ='Message Mode'),
  Field('msg_value', 'integer', requires=IS_INT_IN_RANGE(0
 ,1e100), label='Message Value'),
  )
 
 counts_tab_fields=('test_id','test_pid','ts', 'msg_idx', 'msg_name', 
 'msg_mode', 'msg_value') #global table fields tuple to be 
 zipped for w2p inserts


 class SIP_test(object):
 def __init__(self, tb_id):
 self.uas = False
 self.tb_id = tb_id
 test_id_row = tb(tb.tests.id==self.tb_id).select(tb.tests.test_id
 ).first()
 self.test_id = test_id_row.test_id
 self.path='applications/SIP_Tester/tests/'+str(self.test_id)
 os.makedirs(self.path)
 args_row = tb(tb.tests.id==self.tb_id).select(tb.tests.args).
 first()
 args = ast.literal_eval(args_row.args)
 self.server_ip =  args['server_ip']
 self.uac_scenario = args['uac_scenario']
 self.rate = args['rate']
 self.max_calls = args['max_calls']
 self.sim_calls = args['sim_calls']
 self.uac_number_count = args['uac_number_count']
 self.uac_printf_string = args['uac_printf_string']
 uac_local_ip = args['local_ip_uac']
 self.uac_local_ip_len, self.uac_local_ip = functions.
 ip_input_type(uac_local_ip)
 self.uac_cli_list = self.get_cli_list('uac')
 if self.uas == True:
 self.uas_cli_list = self.get_cli_list('uas')
 ### run processes ###
 uac_proc_list = self.runproc(self.uac_cli_list)
 # Some other methods 


 class resmon(threading.Thread):
 def __init__(self, tb_id, path):
 threading.Thread.__init__(self)
 self.proclist=session.p
 self.tb_id = tb_id
 self.path = path
 self._stop = False
 self.counts_index_dict=None
 test_id_row=tb(tb.tests.id==self.tb_id).select(tb.tests.test_id).
 first()
 self.test_id=test_id_row.test_id 


 def stop(self):
 self._stop = True

#Some other methods

 def read_counts(self,pid,cfile):
 Parses counts files so the results can be imported to DB. 
 Sets class counts_index_dict variable
 line=cfile.readline()
 while line:
 if re.match('^CurrentTime;.*', line) and not self.
 counts_index_dict:
 index_dict={}
 item_list=line.strip().strip(';').split(';')
 for item in item_list:
 index_dict[item_list.index(item)]=item.strip().split(
 '_')
 self.counts_index_dict=index_dict
 elif re.match('^CurrentTime;.*', line) and self.
 counts_index_dict:pass
 else:
 cnt=0

Re: [web2py] Cannot operate on a closed database confusion

2012-05-18 Thread Jan Rozhon
Oh, I didnt know that. Basically, I am trying to run several processes and 
then monitor their output files periodically and import their content to 
DB, so that all the fancy DB stuff can be done on top of them. From my 
knowledge, periodic task that runs for the whole test period would block 
the web2py execution, which is what I am trying to prevent by threading.

Jan

Dne pátek, 18. května 2012 16:56:24 UTC+2 Massimo Di Pierro napsal(a):

 Rule #1. You cannot use threading in a model or controller.

 When an http request arrives the web server spawns a new thread which runs 
 your models, controller and view.
 This call is wrapped into a transaction which connects to the database (or 
 pick connection from pool), then commits and closes the database. These 
 threads are started and stopped by the web server, not the application.

 If you make your own threads from within a model, they may continue run 
 after the database is closed. Even if if you try prevent it 
 by explicitly joining, the web server may kill one of the threads at will 
 with unpredictable results. This can cause of all kind of trouble from 
 unpredictable behavior to memory leaks to the error you see.

 Moreover threads in Python just make the application slower because the 
 interpreter is not parallel. In this case you would not gain anything in 
 concurrency either.

 What are you trying to achieve? I think you need to use the scheduler or a 
 background process.


 On Friday, 18 May 2012 08:44:30 UTC-5, Jan Rozhon wrote:

 Sure, here is part of my model. Jan

 # coding: utf8

 import re
 import ast
 import applications.SIP_Tester.modules.functions as functions
 import os
 import shutil
 import subprocess
 import threading
 import time
 from  datetime import datetime

 tb = DAL('sqlite://tb.sqlite') # test database
 tb.define_table('tests',
  Field('test_id', 'integer', requires=IS_INT_IN_RANGE(0,
 65535), notnull=True, required=True, label='Test ID'),
  Field('ts', 'datetime', 
 requires=IS_DATETIME(format=T('%Y-%m-%d 
 %H:%M:%S'), error_message='must be -MM-DD HH:MM:SS!'), label=
 'Timestamp'),
  Field('args', 'text', requires=IS_LENGTH(65536), 
 label='Test 
 Arguments'),
  format='%(test_id)s')
 tb.define_table('counts',
  Field('test_id', tb.tests, ondelete='CASCADE', notnull=
 True, requires=IS_IN_DB(tb, tb.tests.test_id, '%(test_id)s')),
  Field('test_pid', 'integer', requires=IS_INT_IN_RANGE(0,
 65535), notnull=True, required=True, label='Test PID'),
  Field('ts', 'datetime', 
 requires=IS_DATETIME(format=T('%Y-%m-%d 
 %H:%M:%S'), error_message='must be -MM-DD HH:MM:SS!'), label=
 'Timestamp'),
  Field('msg_idx', 'integer', requires=IS_INT_IN_RANGE(0,
 1), label='Message Index'),
  Field('msg_name', 'string', requires=IS_LENGTH(100),label
 ='Message Name'),
  Field('msg_mode', 'string', requires=IS_LENGTH(10),label
 ='Message Mode'),
  Field('msg_value', 'integer', requires=IS_INT_IN_RANGE(0
 ,1e100), label='Message Value'),
  )
 
 counts_tab_fields=('test_id','test_pid','ts', 'msg_idx', 'msg_name', 
 'msg_mode', 'msg_value') #global table fields tuple to be 
 zipped for w2p inserts


 class SIP_test(object):
 def __init__(self, tb_id):
 self.uas = False
 self.tb_id = tb_id
 test_id_row = tb(tb.tests.id==self.tb_id).select(tb.tests.test_id
 ).first()
 self.test_id = test_id_row.test_id
 self.path='applications/SIP_Tester/tests/'+str(self.test_id)
 os.makedirs(self.path)
 args_row = tb(tb.tests.id==self.tb_id).select(tb.tests.args).
 first()
 args = ast.literal_eval(args_row.args)
 self.server_ip =  args['server_ip']
 self.uac_scenario = args['uac_scenario']
 self.rate = args['rate']
 self.max_calls = args['max_calls']
 self.sim_calls = args['sim_calls']
 self.uac_number_count = args['uac_number_count']
 self.uac_printf_string = args['uac_printf_string']
 uac_local_ip = args['local_ip_uac']
 self.uac_local_ip_len, self.uac_local_ip = functions.
 ip_input_type(uac_local_ip)
 self.uac_cli_list = self.get_cli_list('uac')
 if self.uas == True:
 self.uas_cli_list = self.get_cli_list('uas')
 ### run processes ###
 uac_proc_list = self.runproc(self.uac_cli_list)
 # Some other methods 


 class resmon(threading.Thread):
 def __init__(self, tb_id, path):
 threading.Thread.__init__(self)
 self.proclist=session.p
 self.tb_id = tb_id
 self.path = path
 self._stop = False
 self.counts_index_dict=None
 test_id_row=tb(tb.tests.id==self.tb_id).select(tb.tests.test_id).
 first()
 self.test_id=test_id_row.test_id 


 def stop(self

[web2py] ondelete='CASCADE'

2012-03-04 Thread Jan Rozhon
Hi all, I have a newbie question regarding the cascade delete of referenced 
database entries. Basically, I have these two tables:
tab = DAL('sqlite://tab.sqlite')
tab.define_table('tests', 
 Field('test_id', 'integer', required=True, default=''), 
 Field('test_pid', 'integer', ondelete='NO ACTION'), 
 Field('args'))
tab.define_table('test_counts',
 Field('test_id', tab.tests, requires=IS_IN_DB(tab, 
tab.tests.test_id, '%(test_id)s'), ondelete='CASCADE'), 
 Field('message'))

and I want web2py to create SQLite tables tests and test_counts. 
Test_counts should reference test_id field from the tests table and 
whenever the test entry with the corresponding test_id is deleted the 
appropriate rows in test_counts should be deleted as well, but it doesnt 
work that way and I am unable to find a solution either using my knowledge 
or google as well.

Thanks in advance for any answer, Jan 


Re: [web2py] Re: ondelete='CASCADE'

2012-03-04 Thread Jan Rozhon
Thanks for your quick response, Anthony. If I got it correctly, it would 
be working as expected if I changed the test_id type from integer to id. 
I gave it a try, but it only raised some errors (missing required field) 
and more importantly, it did not allow me to insert this field manually. 
Is there some other approach to reference other value than id?


Thanks, Jan

Dne 4.3.2012 19:41, Anthony napsal(a):
Note, when you create a table with define_table, it automatically 
creates a field called id of type id, which serves as the record 
ID. In your test_counts table, the test_id field is therefore 
referencing the id field of the tests table, not the test_id field, 
which is just a regular integer field. In any case, because of the 
ondelete='CASCADE', when you delete a record from tab.tests, it should 
delete any records from tab.test_counts that reference that record.


Anthony

On Sunday, March 4, 2012 12:42:05 PM UTC-5, Jan Rozhon wrote:

Hi all, I have a newbie question regarding the cascade delete of
referenced database entries. Basically, I have these two tables:
tab = DAL('sqlite://tab.sqlite')
tab.define_table('tests',
 Field('test_id', 'integer', required=True,
default=''),
 Field('test_pid', 'integer', ondelete='NO ACTION'),
 Field('args'))
tab.define_table('test_counts',
 Field('test_id', tab.tests,
requires=IS_IN_DB(tab, tab.tests.test_id, '%(test_id)s'),
ondelete='CASCADE'),
 Field('message'))

and I want web2py to create SQLite tables tests and test_counts.
Test_counts should reference test_id field from the tests table
and whenever the test entry with the corresponding test_id is
deleted the appropriate rows in test_counts should be deleted as
well, but it doesnt work that way and I am unable to find a
solution either using my knowledge or google as well.

Thanks in advance for any answer, Jan




--
Ing. Jan Rozhon
Doktorand katedry telekomunikační techniky
VŠB-TU Ostrava



Re: [web2py] Re: ondelete='CASCADE'

2012-03-04 Thread Jan Rozhon
Well, the problem is most likely in my (not) understanding the concept 
of cascade deletion. In my case, I try to create an interface 
application for network load tests. Each time I run a test with certain 
params I want them to be stored so the user can see them and repeat test 
whenever he wants. This is done by the tests table, in addition user 
should be provided with detailed analysis of message counts through 
test_counts table and errors through test_errors table (not in 
example). For each test I generate unique test_id (actually timestamp) 
which identifies test together with its results. I want to make sure, 
that when a user deletes a record of a certain test in the tests table 
then all the appropriate records in test_counts and test_errors get 
deleted as well. I tried it with table as you can see in my first post, 
but the test_counts entries remained in table although the test_id was 
referenced correctly and I am not able to modify it to be working as 
expected and described. I could actually use a autogenerated id but 
then it should work in the first place, shouldnt it?


Thank you, Jan

Dne 4.3.2012 21:10, Anthony napsal(a):


Thanks for your quick response, Anthony. If I got it correctly, it
would be working as expected if I changed the test_id type from
integer to id. I gave it a try, but it only raised some errors
(missing required field)


Changing test_id to type id should work, but you might need to 
start with a fresh table, as an id type field is an 
auto-incrementing integer field.


and more importantly, it did not allow me to insert this field
manually. Is there some other approach to reference other value
than id?


You wouldn't set the value of an id field manually. Why do you need a 
separate test_id field -- if it is unique per record, the 
automatically generated id field should work? In any case, why do you 
need test_counts.test_id to be the tests.test_id field rather than the 
tests.id field? In the latter case, you can still access the 
tests.test_id field (via a join or second query), and cascading 
deletes will work fine as well (i.e., when a record in tests is 
deleted, referencing records in test_counts will also be deleted).


Anthony



[web2py] Re: Disabling validation/part of form

2011-10-02 Thread Jan Rozhon
Thank you Anthony,

it worked, dumb me didnt noticed that validator.

Thanks again, Jan

On 30 zář, 19:39, Anthony abasta...@gmail.com wrote:
 Have you tried IS_EMPTY_OR(IS_IN_SET(...))?

 Seehttp://web2py.com/book/default/chapter/07#Validators

 Anthony



 On Friday, September 30, 2011 1:13:32 PM UTC-4, Jan Rozhon wrote:

  Hi all,

  as a newbie in web2py I have encountered a problem with my web2py
  application. I want one part of the form to be optional, but the form
  is created by the SQLFORM.factory and one of its optional fields is a
  dropdown list, which uses requires=IS_IN_SET..., thus forcing a user
  to choose a value, which is not desired behavior.
  The optional part of the form is connected with the checkbox, when it
  is checked the part appears and when it is unchecked it hides (using
  jquery), therefore the user in some cases doesnt even see the field.
  Could you please give me a hint how to bypass the validation, or how
  to do the trick differently?

  In controller i have:
  def index():
      form = SQLFORM.factory(
                  Field('uac', 'boolean', default=True),
                  Field('server_ip', requires=IS_IPV4()),
                  Field('local_ip_uac'),
                  Field('uac_scenario',
  requires=IS_IN_SET(functions.list_dir('/mnt/jro/ng/pbx/
  scenarios'),zero='Choose one')),

                  Field('uas', 'boolean', default=False),
                  Field('local_ip_uas'),
                  Field('uas_scenario',
  requires=IS_IN_SET(functions.list_dir('/mnt/jro/ng/pbx/
  scenarios'),zero='Choose one')),
                  

  In view I have this jquery code:
  script
  jQuery(document).ready(function(){
     jQuery('#input_form_local_ip_uas__row').hide();
     jQuery('#input_form_uas_scenario__row').hide();
     jQuery('#input_form_uas').change(function(){
          if(jQuery('#input_form_uas').attr('checked')) {
              jQuery('#input_form_local_ip_uas__row').show();
              jQuery('#input_form_uas_scenario__row').show();}
          else {
              jQuery('#input_form_local_ip_uas__row').hide();
              jQuery('#input_form_uas_scenario__row').attr('disabled',
  'disabled');}});
  });
  /script


[web2py] Disabling validation/part of form

2011-09-30 Thread Jan Rozhon
Hi all,

as a newbie in web2py I have encountered a problem with my web2py
application. I want one part of the form to be optional, but the form
is created by the SQLFORM.factory and one of its optional fields is a
dropdown list, which uses requires=IS_IN_SET..., thus forcing a user
to choose a value, which is not desired behavior.
The optional part of the form is connected with the checkbox, when it
is checked the part appears and when it is unchecked it hides (using
jquery), therefore the user in some cases doesnt even see the field.
Could you please give me a hint how to bypass the validation, or how
to do the trick differently?

In controller i have:
def index():
form = SQLFORM.factory(
Field('uac', 'boolean', default=True),
Field('server_ip', requires=IS_IPV4()),
Field('local_ip_uac'),
Field('uac_scenario',
requires=IS_IN_SET(functions.list_dir('/mnt/jro/ng/pbx/
scenarios'),zero='Choose one')),

Field('uas', 'boolean', default=False),
Field('local_ip_uas'),
Field('uas_scenario',
requires=IS_IN_SET(functions.list_dir('/mnt/jro/ng/pbx/
scenarios'),zero='Choose one')),


In view I have this jquery code:
script
jQuery(document).ready(function(){
   jQuery('#input_form_local_ip_uas__row').hide();
   jQuery('#input_form_uas_scenario__row').hide();
   jQuery('#input_form_uas').change(function(){
if(jQuery('#input_form_uas').attr('checked')) {
jQuery('#input_form_local_ip_uas__row').show();
jQuery('#input_form_uas_scenario__row').show();}
else {
jQuery('#input_form_local_ip_uas__row').hide();
jQuery('#input_form_uas_scenario__row').attr('disabled',
'disabled');}});
});
/script