[web2py] Reset password : invalid reset password

2015-03-13 Thread ajith c t
Hi,

This question is about the redirection for reset_password function.

my workflow is i click on the request_reset_password button which sends an 
email to the user with the reset_password url. 

I am using version 2.9

the problem is the reset_password form redirects to login page even before 
loading. when I click on the url from mail, it directly redirects to the 
login page.

I know , I have already faced this redirection problem and this forum have 
helped me solve it before, but its not working this time.
https://groups.google.com/forum/#!searchin/web2py/logout$20error/web2py/Zm-bpXVdwVs/HD4vjEK1FwMJ

def request_reset_password():
form = auth.request_reset_password()
return dict(form=form)

def reset_password():
try:
form = auth.reset_password()
return dict(form=form)
except HTTP, h:
logger.error(traceback.format_exc())
raise h 

these are the two functions that i use for password reset process.

and these are the respective errros i receive 
2015-03-13 05:50:32,679 - ERROR - app - Traceback (most recent call last):
  File 
/home/ajith/work/repositories/office/trustvouch/trustvouch_fe/trunk/applications/app/controllers/default.py,
 
line 776, in request_reset_password
form = auth.request_reset_password()
  File 
/home/ajith/work/repositories/office/trustvouch/trustvouch_fe/trunk/gluon/tools.py,
 
line 3140, in request_reset_password
redirect(next, client_side=self.settings.client_side)
  File 
/home/ajith/work/repositories/office/trustvouch/trustvouch_fe/trunk/gluon/http.py,
 
line 173, in redirect
**headers)
HTTP: 303 SEE OTHER


2015-03-13 05:51:06,041 - ERROR - app - Traceback (most recent call last):
  File 
/home/ajith/work/repositories/office/trustvouch/trustvouch_fe/trunk/applications/app/controllers/default.py,
 
line 765, in reset_password
form = auth.reset_password()
  File 
/home/ajith/work/repositories/office/trustvouch/trustvouch_fe/trunk/gluon/tools.py,
 
line 3038, in reset_password
redirect(next, client_side=self.settings.client_side)
  File 
/home/ajith/work/repositories/office/trustvouch/trustvouch_fe/trunk/gluon/http.py,
 
line 173, in redirect
**headers)
HTTP: 303 SEE OTHER


last time it was said that it is causing due to internal redirection and i 
need to catch it with an http exception. but dont know whats going wrong.


{{block center}}
body class=form full 
div class=wrapper step2
header
h2TrustID/h2
/header
section
div class=form-login
div class=box-form
form action= enctype=multipart/form-data method=post 
 name=reset_password id=reset_password 
input type=password id=no_table_new_password 
name=new_password placeholder=New Password class=text-input focus 
required /
input type=password id=no_table_new_password2 
name=new_password2 placeholder=Confirm Password class=text-input 
focus required  /
 input type=submit name=submit class=button big green 
id=submit value=Reset Password
{{=form.custom.end}}
/div 
/div
/section
/div
/body
{{end}}

the form just redirects to login page

body class=form full 
  5 div class=wrapper step2
  6 header
  7 h2TrustID/h2
  8 /header
  9 section
 10 div class=form-login
 11 div class=box-form
 12 form action= enctype=multipart/form-data 
method=post  name=request_reset_password id=request_reset_password   
  
 14 input type=text 
id=tv_auth_users_email name=email placeholder=email class=text-input 
focus required /  emPlease check your spam settings./em
 input type=submit name=submit 
class=button big green id=submit value=Request Password Reset
   pGo back to a href={{=URL('default' 
,'login')}}login/a./p
 23 {{=form.custom.end}}
 24 /div
 25 /div
 26 /section
 27 /div
 28 /body


what could be possibly wrong




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: logout error

2014-02-17 Thread ajith c t
Thank you LightDot, saved my day and work at the right time. Read in forums 
that redirect() is internally calling a 303 exception, but didn't realise 
that I was catching that too and redirecting to errorpage. Thanks for the 
support.

On Monday, 17 February 2014 17:02:41 UTC+5:30, LightDot wrote:

 Keep in mind that redirect() is an equivalent to raising an HTTP(303) 
 exception. In other words, an intentional exception is raised to create a 
 redirect.

 Looks like it's your own code doing a traceback and creating an error page 
 on every exception, including the cases of the intentional redirect(), 
 which is not what you want.

 Regards


 On Monday, February 17, 2014 8:23:57 AM UTC+1, ajith c t wrote:

 Hi Massimo, there is one more thing, it seems that the redirect problem 
 is not only with my login function. Every function where I use a redirect 
 call from my controller results in a error page with a log as 303 error.

 File /srv/trustvouch-fe/applications/app/controllers/default.py, line 
 480, in mrtusrMgr
 form = crud.update(db.tv_auth_users, request.args(1), 
 next=URL('mrtusrMgr'))
   File /srv/trustvouch-fe/gluon/tools.py, line 3906, in update
 redirect(next)
   File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
 Location=loc)
 HTTP: 303 SEE OTHER


 File /srv/trustvouch-fe/applications/app/controllers/reportmgr.py, line 
 85, in options
 redirect(URL('reportmgr', 'list'))
   File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
 Location=loc)
 HTTP: 303 SEE OTHER



 On Monday, 17 February 2014 11:57:29 UTC+5:30, ajith c t wrote:

 Sorry Massimo,  I commented both the requires_login() and 
 requires_permission() for both dashboard() and my index() functions, still 
 the error is same.

 2014-02-17 06:12:42,411 - ERROR - app - Traceback (most recent call 
 last):
   File /srv/trustvouch-fe/applications/app/controllers/default.py, 
 line 25, in login
 form = auth.login()
   File /srv/trustvouch-fe/gluon/tools.py, line 2393, in login
 redirect(next, client_side=settings.client_side)
   File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
 Location=loc)
 HTTP: 303 SEE OTHER

 got no idea on this. 

 On Sunday, 16 February 2014 13:35:20 UTC+5:30, Massimo Di Pierro wrote:

 Sorry I mean here:

 @auth.requires_login()
 @auth.requires_permission(request.function)
 def dashboard():

 you should NOT have both. Perhaps this was causing the problem?

 On Saturday, 15 February 2014 09:15:18 UTC-6, ajith c t wrote:

 Hi Massimo, 

  Thanks for the reply, but sorry to say this, but I didn't 
 understand what you meant there, which function should have both. I 
 wanted 
 every user to have login and logout functions, thats why I didn't add 
 auth.permission for them.   And can you explain why it is giving 303 
 error. 
 Is it something with the redirect(next).

 On Thursday, 13 February 2014 18:16:27 UTC+5:30, ajith c t wrote:


 Hi ,
   I am using web2py 2.5.1-stable+timestamp.2013.06.06.15.39.19 in my 
 production environment. I know it is old but thinking about the mysql 
 and 
 other folders and files structure changes I am little hesitant to update 
 it. My problem is this.

 My logout function doesn't work properly.  

 # Login function
 def login():
   
   try:  
 logger.debug(login page)
 form = auth.login()
 return dict(form = form)

   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 def index():

 try:
 if auth.has_membership('root'):
 logger.debug(auth.user.first_name + : logged in)
 redirect(URL('default', 'usrMgr')) 
 else:
 logger.debug(auth.user.first_name +: logged in)   

 redirect(URL('dashboard'))
 
 except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 @auth.requires_permission(request.function)
 def dashboard():

   try:
 logger.info(dashboard)
 ###Some Code###
   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

  def logout():
  
try:
  logger.debug(logout)
  auth.logout(next=URL(r=request, c='default', f='login'))
  return dict()
except Exception,e:
  logger.error(traceback.format_exc())
  redirect(URL(errorpage))


 The behavior is different in different browsers. In Chrome when I 
 select logout from the dashboard page, it remains in the same page. When 
 I 
 select the developer tools and check the network the urls are logout, 
 login, dashboard in order and its loaded from cache. But there is no 
 problem in firefox.

 My problem is the logut function doesnt redirect to login page. When 
 I clear the browser cache or delete all the sessions in the sessions 
 folder, it works neatly. But when the session file

[web2py] Re: logout error

2014-02-17 Thread ajith c t
I too raised the HTTP class and its working fine now, thank you to all for 
your continued support. 

I wrapped the code in try/ except so that I could log everything and save 
it in a file, and in case of an error redirect to another page. If there is 
a better workaround please let me know.

On Monday, 17 February 2014 19:16:07 UTC+5:30, Anthony wrote:

 To avoid catching the HTTP exceptions, you can do something like this:

 except Exception as e:
 if isinstance(e, HTTP):
 raise e

 Anyway, why are you wrapping all of your code in try/except statements -- 
 web2py already catches all exceptions?

 Anthony

 On Monday, February 17, 2014 6:44:16 AM UTC-5, ajith c t wrote:

 Thank you LightDot, saved my day and work at the right time. Read in 
 forums that redirect() is internally calling a 303 exception, but didn't 
 realise that I was catching that too and redirecting to errorpage. Thanks 
 for the support.

 On Monday, 17 February 2014 17:02:41 UTC+5:30, LightDot wrote:

 Keep in mind that redirect() is an equivalent to raising an HTTP(303) 
 exception. In other words, an intentional exception is raised to create a 
 redirect.

 Looks like it's your own code doing a traceback and creating an error 
 page on every exception, including the cases of the intentional redirect(), 
 which is not what you want.

 Regards


 On Monday, February 17, 2014 8:23:57 AM UTC+1, ajith c t wrote:

 Hi Massimo, there is one more thing, it seems that the redirect problem 
 is not only with my login function. Every function where I use a redirect 
 call from my controller results in a error page with a log as 303 error.

 File /srv/trustvouch-fe/applications/app/controllers/default.py, line 
 480, in mrtusrMgr
 form = crud.update(db.tv_auth_users, request.args(1), 
 next=URL('mrtusrMgr'))
   File /srv/trustvouch-fe/gluon/tools.py, line 3906, in update
 redirect(next)
   File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
 Location=loc)
 HTTP: 303 SEE OTHER


 File /srv/trustvouch-fe/applications/app/controllers/reportmgr.py, 
 line 85, in options
 redirect(URL('reportmgr', 'list'))
   File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
 Location=loc)
 HTTP: 303 SEE OTHER



 On Monday, 17 February 2014 11:57:29 UTC+5:30, ajith c t wrote:

 Sorry Massimo,  I commented both the requires_login() and 
 requires_permission() for both dashboard() and my index() functions, 
 still 
 the error is same.

 2014-02-17 06:12:42,411 - ERROR - app - Traceback (most recent call 
 last):
   File /srv/trustvouch-fe/applications/app/controllers/default.py, 
 line 25, in login
 form = auth.login()
   File /srv/trustvouch-fe/gluon/tools.py, line 2393, in login
 redirect(next, client_side=settings.client_side)
   File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
 Location=loc)
 HTTP: 303 SEE OTHER

 got no idea on this. 

 On Sunday, 16 February 2014 13:35:20 UTC+5:30, Massimo Di Pierro wrote:

 Sorry I mean here:

 @auth.requires_login()
 @auth.requires_permission(request.function)
 def dashboard():

 you should NOT have both. Perhaps this was causing the problem?

 On Saturday, 15 February 2014 09:15:18 UTC-6, ajith c t wrote:

 Hi Massimo, 

  Thanks for the reply, but sorry to say this, but I didn't 
 understand what you meant there, which function should have both. I 
 wanted 
 every user to have login and logout functions, thats why I didn't add 
 auth.permission for them.   And can you explain why it is giving 303 
 error. 
 Is it something with the redirect(next).

 On Thursday, 13 February 2014 18:16:27 UTC+5:30, ajith c t wrote:


 Hi ,
   I am using web2py 2.5.1-stable+timestamp.2013.06.06.15.39.19 in 
 my production environment. I know it is old but thinking about the 
 mysql 
 and other folders and files structure changes I am little hesitant to 
 update it. My problem is this.

 My logout function doesn't work properly.  

 # Login function
 def login():
   
   try:  
 logger.debug(login page)
 form = auth.login()
 return dict(form = form)

   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 def index():

 try:
 if auth.has_membership('root'):
 logger.debug(auth.user.first_name + : logged in)
 redirect(URL('default', 'usrMgr')) 
 else:
 logger.debug(auth.user.first_name +: logged in)   

 redirect(URL('dashboard'))
 
 except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 @auth.requires_permission(request.function)
 def dashboard():

   try:
 logger.info(dashboard)
 ###Some Code###
   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

  def logout():
  
try:
  logger.debug(logout

[web2py] Re: logout error

2014-02-17 Thread ajith c t
Thanks for the help , I will look into it. Anything that helps improve my 
code is always welcome.  

On Monday, 17 February 2014 22:26:42 UTC+5:30, Anthony wrote:

 I wrapped the code in try/ except so that I could log everything and save 
 it in a file, and in case of an error redirect to another page. If there is 
 a better workaround please let me know.


 See http://web2py.com/books/default/chapter/29/04/the-core#Routes-on-errorfor 
 more sophisticated error handling options. web2py already saves all 
 tracebacks along with other error related details in the error tickets. 
 Anyway, you might at least consider creating a decorator rather than 
 repeating the exact same try/except code in every single controller 
 function.

 Anthony


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: logout error

2014-02-16 Thread ajith c t
Sorry Massimo,  I commented both the requires_login() and 
requires_permission() for both dashboard() and my index() functions, still 
the error is same.

2014-02-17 06:12:42,411 - ERROR - app - Traceback (most recent call last):
  File /srv/trustvouch-fe/applications/app/controllers/default.py, line 
25, in login
form = auth.login()
  File /srv/trustvouch-fe/gluon/tools.py, line 2393, in login
redirect(next, client_side=settings.client_side)
  File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
Location=loc)
HTTP: 303 SEE OTHER

got no idea on this. 

On Sunday, 16 February 2014 13:35:20 UTC+5:30, Massimo Di Pierro wrote:

 Sorry I mean here:

 @auth.requires_login()
 @auth.requires_permission(request.function)
 def dashboard():

 you should NOT have both. Perhaps this was causing the problem?

 On Saturday, 15 February 2014 09:15:18 UTC-6, ajith c t wrote:

 Hi Massimo, 

  Thanks for the reply, but sorry to say this, but I didn't understand 
 what you meant there, which function should have both. I wanted every user 
 to have login and logout functions, thats why I didn't add auth.permission 
 for them.   And can you explain why it is giving 303 error. Is it something 
 with the redirect(next).

 On Thursday, 13 February 2014 18:16:27 UTC+5:30, ajith c t wrote:


 Hi ,
   I am using web2py 2.5.1-stable+timestamp.2013.06.06.15.39.19 in my 
 production environment. I know it is old but thinking about the mysql and 
 other folders and files structure changes I am little hesitant to update 
 it. My problem is this.

 My logout function doesn't work properly.  

 # Login function
 def login():
   
   try:  
 logger.debug(login page)
 form = auth.login()
 return dict(form = form)

   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 def index():

 try:
 if auth.has_membership('root'):
 logger.debug(auth.user.first_name + : logged in)
 redirect(URL('default', 'usrMgr')) 
 else:
 logger.debug(auth.user.first_name +: logged in)   

 redirect(URL('dashboard'))
 
 except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 @auth.requires_permission(request.function)
 def dashboard():

   try:
 logger.info(dashboard)
 ###Some Code###
   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

  def logout():
  
try:
  logger.debug(logout)
  auth.logout(next=URL(r=request, c='default', f='login'))
  return dict()
except Exception,e:
  logger.error(traceback.format_exc())
  redirect(URL(errorpage))


 The behavior is different in different browsers. In Chrome when I select 
 logout from the dashboard page, it remains in the same page. When I select 
 the developer tools and check the network the urls are logout, login, 
 dashboard in order and its loaded from cache. But there is no problem in 
 firefox.

 My problem is the logut function doesnt redirect to login page. When I 
 clear the browser cache or delete all the sessions in the sessions folder, 
 it works neatly. But when the session file or the cache gets filled up, 
 everything goes wrong.  Let me know if I wasn't specific, so I can clear 
 this problem.

 Thanks and Regards,

 Ajith



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: logout error

2014-02-16 Thread ajith c t
Hi Massimo, there is one more thing, it seems that the redirect problem is 
not only with my login function. Every function where I use a redirect call 
from my controller results in a error page with a log as 303 error.

File /srv/trustvouch-fe/applications/app/controllers/default.py, line 
480, in mrtusrMgr
form = crud.update(db.tv_auth_users, request.args(1), 
next=URL('mrtusrMgr'))
  File /srv/trustvouch-fe/gluon/tools.py, line 3906, in update
redirect(next)
  File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
Location=loc)
HTTP: 303 SEE OTHER


File /srv/trustvouch-fe/applications/app/controllers/reportmgr.py, line 
85, in options
redirect(URL('reportmgr', 'list'))
  File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
Location=loc)
HTTP: 303 SEE OTHER



On Monday, 17 February 2014 11:57:29 UTC+5:30, ajith c t wrote:

 Sorry Massimo,  I commented both the requires_login() and 
 requires_permission() for both dashboard() and my index() functions, still 
 the error is same.

 2014-02-17 06:12:42,411 - ERROR - app - Traceback (most recent call last):
   File /srv/trustvouch-fe/applications/app/controllers/default.py, line 
 25, in login
 form = auth.login()
   File /srv/trustvouch-fe/gluon/tools.py, line 2393, in login
 redirect(next, client_side=settings.client_side)
   File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
 Location=loc)
 HTTP: 303 SEE OTHER

 got no idea on this. 

 On Sunday, 16 February 2014 13:35:20 UTC+5:30, Massimo Di Pierro wrote:

 Sorry I mean here:

 @auth.requires_login()
 @auth.requires_permission(request.function)
 def dashboard():

 you should NOT have both. Perhaps this was causing the problem?

 On Saturday, 15 February 2014 09:15:18 UTC-6, ajith c t wrote:

 Hi Massimo, 

  Thanks for the reply, but sorry to say this, but I didn't 
 understand what you meant there, which function should have both. I wanted 
 every user to have login and logout functions, thats why I didn't add 
 auth.permission for them.   And can you explain why it is giving 303 error. 
 Is it something with the redirect(next).

 On Thursday, 13 February 2014 18:16:27 UTC+5:30, ajith c t wrote:


 Hi ,
   I am using web2py 2.5.1-stable+timestamp.2013.06.06.15.39.19 in my 
 production environment. I know it is old but thinking about the mysql and 
 other folders and files structure changes I am little hesitant to update 
 it. My problem is this.

 My logout function doesn't work properly.  

 # Login function
 def login():
   
   try:  
 logger.debug(login page)
 form = auth.login()
 return dict(form = form)

   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 def index():

 try:
 if auth.has_membership('root'):
 logger.debug(auth.user.first_name + : logged in)
 redirect(URL('default', 'usrMgr')) 
 else:
 logger.debug(auth.user.first_name +: logged in)   

 redirect(URL('dashboard'))
 
 except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 @auth.requires_permission(request.function)
 def dashboard():

   try:
 logger.info(dashboard)
 ###Some Code###
   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

  def logout():
  
try:
  logger.debug(logout)
  auth.logout(next=URL(r=request, c='default', f='login'))
  return dict()
except Exception,e:
  logger.error(traceback.format_exc())
  redirect(URL(errorpage))


 The behavior is different in different browsers. In Chrome when I 
 select logout from the dashboard page, it remains in the same page. When I 
 select the developer tools and check the network the urls are logout, 
 login, dashboard in order and its loaded from cache. But there is no 
 problem in firefox.

 My problem is the logut function doesnt redirect to login page. When I 
 clear the browser cache or delete all the sessions in the sessions folder, 
 it works neatly. But when the session file or the cache gets filled up, 
 everything goes wrong.  Let me know if I wasn't specific, so I can clear 
 this problem.

 Thanks and Regards,

 Ajith



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: logout error

2014-02-15 Thread ajith c t
Hi Massimo, 
   
 Thanks for the reply, but sorry to say this, but I didn't understand 
what you meant there, which function should have both. I wanted every user 
to have login and logout functions, thats why I didn't add auth.permission 
for them.   And can you explain why it is giving 303 error. Is it something 
with the redirect(next).

On Thursday, 13 February 2014 18:16:27 UTC+5:30, ajith c t wrote:


 Hi ,
   I am using web2py 2.5.1-stable+timestamp.2013.06.06.15.39.19 in my 
 production environment. I know it is old but thinking about the mysql and 
 other folders and files structure changes I am little hesitant to update 
 it. My problem is this.

 My logout function doesn't work properly.  

 # Login function
 def login():
   
   try:  
 logger.debug(login page)
 form = auth.login()
 return dict(form = form)

   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 def index():

 try:
 if auth.has_membership('root'):
 logger.debug(auth.user.first_name + : logged in)
 redirect(URL('default', 'usrMgr')) 
 else:
 logger.debug(auth.user.first_name +: logged in)   

 redirect(URL('dashboard'))
 
 except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

 @auth.requires_login()
 @auth.requires_permission(request.function)
 def dashboard():

   try:
 logger.info(dashboard)
 ###Some Code###
   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))

  def logout():
  
try:
  logger.debug(logout)
  auth.logout(next=URL(r=request, c='default', f='login'))
  return dict()
except Exception,e:
  logger.error(traceback.format_exc())
  redirect(URL(errorpage))


 The behavior is different in different browsers. In Chrome when I select 
 logout from the dashboard page, it remains in the same page. When I select 
 the developer tools and check the network the urls are logout, login, 
 dashboard in order and its loaded from cache. But there is no problem in 
 firefox.

 My problem is the logut function doesnt redirect to login page. When I 
 clear the browser cache or delete all the sessions in the sessions folder, 
 it works neatly. But when the session file or the cache gets filled up, 
 everything goes wrong.  Let me know if I wasn't specific, so I can clear 
 this problem.

 Thanks and Regards,

 Ajith


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: logout error

2014-02-14 Thread ajith c t
Hi I updated web2py 2.5 to 2.8,

now the login and logout seems to work but with a problem, 

the login page redirects to errorpage and logout correctly redirects to 
login page.
But my logs are:

***
2014-02-14 10:18:45,224 - DEBUG - web2py.scheduler.ip-10-0-0-175#25487 - 
defining tables (migrate=True)
2014-02-14 10:18:45,274 - DEBUG - app - login page
2014-02-14 10:18:45,315 - ERROR - app - Traceback (most recent call last):
  File /srv/trustvouch-fe/applications/app/controllers/default.py, line 
25, in login
form = auth.login()
  File /srv/trustvouch-fe/gluon/tools.py, line 2393, in login
redirect(next, client_side=settings.client_side)
  File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
Location=loc)
HTTP: 303 SEE OTHER

2014-02-14 10:18:45,515 - DEBUG - web2py.scheduler.ip-10-0-0-175#25487 - 
defining tables (migrate=True)


2014-02-14 10:19:08,879 - DEBUG - web2py.scheduler.ip-10-0-0-175#25487 - 
defining tables (migrate=True)
2014-02-14 10:19:08,932 - DEBUG - app - logout
2014-02-14 10:19:08,934 - ERROR - app - Traceback (most recent call last):
  File /srv/trustvouch-fe/applications/app/controllers/default.py, line 
38, in logout
auth.logout(next=URL(r=request, c='default', f='index'))
  File /srv/trustvouch-fe/gluon/tools.py, line 2434, in logout
redirect(next)
  File /srv/trustvouch-fe/gluon/http.py, line 147, in redirect
Location=loc)
HTTP: 303 SEE OTHER


both of them shows http 303 error, seems both have tools.py error, what am 
I doing wrong.
Can anyone help me here, because I need to push live data to my app very 
soon

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] logout error

2014-02-13 Thread ajith c t

Hi ,
  I am using web2py 2.5.1-stable+timestamp.2013.06.06.15.39.19 in my 
production environment. I know it is old but thinking about the mysql and 
other folders and files structure changes I am little hesitant to update 
it. My problem is this.

My logout function doesn't work properly.  

# Login function
def login():
  
  try:  
logger.debug(login page)
form = auth.login()
return dict(form = form)

  except Exception,e:
logger.error(traceback.format_exc())
redirect(URL(errorpage))

@auth.requires_login()
def index():

try:
if auth.has_membership('root'):
logger.debug(auth.user.first_name + : logged in)
redirect(URL('default', 'usrMgr')) 
else:
logger.debug(auth.user.first_name +: logged in)   

redirect(URL('dashboard'))

except Exception,e:
logger.error(traceback.format_exc())
redirect(URL(errorpage))

@auth.requires_login()
@auth.requires_permission(request.function)
def dashboard():

  try:
logger.info(dashboard)
###Some Code###
  except Exception,e:
logger.error(traceback.format_exc())
redirect(URL(errorpage))

 def logout():
 
   try:
 logger.debug(logout)
 auth.logout(next=URL(r=request, c='default', f='login'))
 return dict()
   except Exception,e:
 logger.error(traceback.format_exc())
 redirect(URL(errorpage))


The behavior is different in different browsers. In Chrome when I select 
logout from the dashboard page, it remains in the same page. When I select 
the developer tools and check the network the urls are logout, login, 
dashboard in order and its loaded from cache. But there is no problem in 
firefox.

My problem is the logut function doesnt redirect to login page. When I 
clear the browser cache or delete all the sessions in the sessions folder, 
it works neatly. But when the session file or the cache gets filled up, 
everything goes wrong.  Let me know if I wasn't specific, so I can clear 
this problem.

Thanks and Regards,

Ajith

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] getting current logged user in a model file used as a scheduler

2013-09-25 Thread ajith c t
Hi,

I have a scheduler which is setup in a model file. A set of task is 
written in the scheduler.py which is queued from the controller. My problem 
is I need to get the current logged in user in this scheduler.py file so 
that I can write query with respect to the logged in user.

I can obtain the current logged in user using the command auth.user in the 
scheduler.py file. But when I call auth.user from a task defined in the 
same scheduler.py , file it returns none.

scheduler.py file

print auth.user

def task1():
  logger.debug(current user: %s, auth.user)
  return 


the output in the first case is row of the  logged in user  while none in 
second case.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [web2py] getting current logged user in a model file used as a scheduler

2013-09-25 Thread ajith c t
is there any update or modification in comet_messenger, because I cannot 
see a file comet_messenger in the contrib folder. And I am not sure whether 
it is the solution, It seems like a websocket thing.

What I need is how to find the current logged in user in scheduler task.

I tried passing the user id from the controller in the queue_task call as 
parameter but it fails when I login with different user as queue_task is 
only called once when the app starts.

On Wednesday, 25 September 2013 19:05:00 UTC+5:30, Richard wrote:

 I don't think you can be sure you have logged user except by using 
 comet_messenger.py contrib and tornado. There is many thread about this. 

 Richard


 On Wed, Sep 25, 2013 at 9:04 AM, ajith c t ajith...@gmail.comjavascript:
  wrote:

 Hi,

 I have a scheduler which is setup in a model file. A set of task is 
 written in the scheduler.py which is queued from the controller. My problem 
 is I need to get the current logged in user in this scheduler.py file so 
 that I can write query with respect to the logged in user.

 I can obtain the current logged in user using the command auth.user in 
 the scheduler.py file. But when I call auth.user from a task defined in the 
 same scheduler.py , file it returns none.

 scheduler.py file

 print auth.user

 def task1():
   logger.debug(current user: %s, auth.user)
   return 


 the output in the first case is row of the  logged in user  while none in 
 second case.

  -- 
 Resources:
 - http://web2py.com
 - http://web2py.com/book (Documentation)
 - http://github.com/web2py/web2py (Source code)
 - https://code.google.com/p/web2py/issues/list (Report Issues)
 --- 
 You received this message because you are subscribed to the Google Groups 
 web2py-users group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to web2py+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-17 Thread ajith c t
Hi Niphlod, 
  Got my scheduler working correctly.
 I updated my web2py version to 2.5.1 from 2.2.1 as you mentioned 
earlier. After that started two upstart jobs, one for my app and another 
for the scheduler. Still it returned an error error cleaning up..
 I couldn't find an appropriate solution for it net so checked the code 
of scheduler.py file in gluon folder. Found that an exception raises this 
error at line number 797. The exception doesn't say anything about the 
error, just prints the message. After calling the Exception class and 
printing the exception, found out that it was a permission problem. I had 
not given the DELETE permission to the user. Once that was corrected, 
everything worked fine as I needed,

It would be helpful if you could also log the exception that displays the 
message from the scheduler.py file. I had to spend lot of time to find this 
error, maybe my mistake as I am a web2py beginner, but it would really help 
if the cause of the exception is also logged, 

On Thursday, 12 September 2013 12:36:33 UTC+5:30, ajith c t wrote:

 Thank you for the response, will try everything you said and post it if 
 every thing goes correct

 On Thursday, 12 September 2013 00:34:31 UTC+5:30, Niphlod wrote:



 On Wednesday, September 11, 2013 5:44:00 PM UTC+2, ajith c t wrote:

 sorry I am not executing the code in the load balancer. Let me say once 
 more, so it will be clear.

 I dont have any web2py code in the load balancer. 

 What I  meant is I have my code in another server(say X) , to which the 
 user is redirected by the load balancer(say Y). 

 when I execute the webpy application from server X , the index function 
 , where my scheduler.queue_task call comes,in the default.py controller 
 will not be called as I cant access it from X. That is expected. So what I 
 asked was , for breaking down purpose shouldn't I move that call into the 
 scheduler.py file in the models folder as the model file will be called.


 I really don't get this part. Every controller in web2py gets executed as 
 long as the request comes to the server. If you can reach a page and in 
 your controller for that page you use queue_task(), you should definitely 
 be able to enqueue a task. queue_task() is NOT meant to be used in models, 
 because you'd queue a task for EACH and EVERY request coming in.
  


 And I will use the seperation of duties approach. but can you just 
 confirm that the commands are correct.


 web part:
 python web2py.py -a yourpassword -p 8000 -i 0.0.0.0

 scheduler
 python web2py.py -K appname

 let me stress it out once more: serving a web app in production with the 
 included webserver is not going to provide stellar performances, although 
 it definitely works.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-17 Thread ajith c t
I got the error cleaning up message after updating the web2py. I had set 
user specific permissions, thats what happened. Well its resolved now. 
Thanks for all the support given by the web2py group.

On Tuesday, 17 September 2013 17:50:58 UTC+5:30, Niphlod wrote:

 catching those kind of errors is going to be a real PITA... every backend 
 (i.e. database engine) logs the error as it wishes, so we don't have a 
 method for pointing what is going wrong. No logs you reported included 
 error cleaning up: if you told me earlier, I would have pointed you in 
 the right direction.

 PS: every web2py part is kinda required to have read and write 
 permission everywhere nobody really had any problem with it ^_^

 On Tuesday, September 17, 2013 1:47:34 PM UTC+2, ajith c t wrote:

 Hi Niphlod, 
   Got my scheduler working correctly.
  I updated my web2py version to 2.5.1 from 2.2.1 as you mentioned 
 earlier. After that started two upstart jobs, one for my app and another 
 for the scheduler. Still it returned an error error cleaning up..
  I couldn't find an appropriate solution for it net so checked the 
 code of scheduler.py file in gluon folder. Found that an exception raises 
 this error at line number 797. The exception doesn't say anything about the 
 error, just prints the message. After calling the Exception class and 
 printing the exception, found out that it was a permission problem. I had 
 not given the DELETE permission to the user. Once that was corrected, 
 everything worked fine as I needed,

 It would be helpful if you could also log the exception that displays the 
 message from the scheduler.py file. I had to spend lot of time to find this 
 error, maybe my mistake as I am a web2py beginner, but it would really help 
 if the cause of the exception is also logged, 

 On Thursday, 12 September 2013 12:36:33 UTC+5:30, ajith c t wrote:

 Thank you for the response, will try everything you said and post it if 
 every thing goes correct

 On Thursday, 12 September 2013 00:34:31 UTC+5:30, Niphlod wrote:



 On Wednesday, September 11, 2013 5:44:00 PM UTC+2, ajith c t wrote:

 sorry I am not executing the code in the load balancer. Let me say 
 once more, so it will be clear.

 I dont have any web2py code in the load balancer. 

 What I  meant is I have my code in another server(say X) , to which 
 the user is redirected by the load balancer(say Y). 

 when I execute the webpy application from server X , the index 
 function , where my scheduler.queue_task call comes,in the default.py 
 controller will not be called as I cant access it from X. That is 
 expected. 
 So what I asked was , for breaking down purpose shouldn't I move that 
 call 
 into the scheduler.py file in the models folder as the model file will be 
 called.


 I really don't get this part. Every controller in web2py gets executed 
 as long as the request comes to the server. If you can reach a page and in 
 your controller for that page you use queue_task(), you should definitely 
 be able to enqueue a task. queue_task() is NOT meant to be used in models, 
 because you'd queue a task for EACH and EVERY request coming in.
  


 And I will use the seperation of duties approach. but can you just 
 confirm that the commands are correct.


 web part:
 python web2py.py -a yourpassword -p 8000 -i 0.0.0.0

 scheduler
 python web2py.py -K appname

 let me stress it out once more: serving a web app in production with 
 the included webserver is not going to provide stellar performances, 
 although it definitely works.



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-12 Thread ajith c t
Thank you for the response, will try everything you said and post it if 
every thing goes correct

On Thursday, 12 September 2013 00:34:31 UTC+5:30, Niphlod wrote:



 On Wednesday, September 11, 2013 5:44:00 PM UTC+2, ajith c t wrote:

 sorry I am not executing the code in the load balancer. Let me say once 
 more, so it will be clear.

 I dont have any web2py code in the load balancer. 

 What I  meant is I have my code in another server(say X) , to which the 
 user is redirected by the load balancer(say Y). 

 when I execute the webpy application from server X , the index function , 
 where my scheduler.queue_task call comes,in the default.py controller will 
 not be called as I cant access it from X. That is expected. So what I asked 
 was , for breaking down purpose shouldn't I move that call into the 
 scheduler.py file in the models folder as the model file will be called.


 I really don't get this part. Every controller in web2py gets executed as 
 long as the request comes to the server. If you can reach a page and in 
 your controller for that page you use queue_task(), you should definitely 
 be able to enqueue a task. queue_task() is NOT meant to be used in models, 
 because you'd queue a task for EACH and EVERY request coming in.
  


 And I will use the seperation of duties approach. but can you just 
 confirm that the commands are correct.


 web part:
 python web2py.py -a yourpassword -p 8000 -i 0.0.0.0

 scheduler
 python web2py.py -K appname

 let me stress it out once more: serving a web app in production with the 
 included webserver is not going to provide stellar performances, although 
 it definitely works.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-11 Thread ajith c t
Hi Niphlod,

 I changed my .conf file a littile by reading the web2py online book,



Created a new web2py-scheduler.conf file

   
start on runlevel [2345]

stop on runlevel [016]
respawn limit 8 60
   
script
  exec sudo -u root python /srv/tv-fe/web2py.py -K app
end script
  
respawn

   and another conf file tv-fe.conf

 
  start on runlevel [2345]
  # When to stop the service
  stop on runlevel [016]
   
  # Automatically restart process if crashed
  respawn
  respawn limit 5 60
  
  # Specify resource limits
  # Make sure you have set the system limits accordingly
  limit nofile 65536 65536
  
  # Modify scheduling priority, ranges from -20 (most favorable) to 19 
(least
  # favorable)
  nice -10
  
  # Out Of Memory (OOM) killing score, ranges from -999 (very unlikely to be
  # killed by OOM killer) to 1000 (very likely) or 'never'
  oom score -555
  
  # Essentially lets upstart know the process will detach itself to the 
background
  expect fork
  expect daemon
  
  # Run before process
  pre-start script
  [ -d /var/log/tv/frontend ] || mkdir -p /var/log/tv/frontend
  end script
  
  # Start the process
  script
  exec python -- /srv/tv-fe/web2py.py --nogui -a '' -p 8000 -i 0.0.0.0  

  end script

The log from the upstart web2py-scheduler.log is 
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.2.1 (2012-10-21 16:57:04) stable
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), IMAP(imaplib)
starting single-scheduler for app...
/usr/local/lib/python2.7/dist-packages/riak-2.0.1.post5-py2.7.egg/riak/util.py:148:
 
UserWarning: ``solr`` is deprecated, use ``fulltext_search``, 
``fulltext_add`` and ``fulltext_delete`` directly
  value = self.fget(obj)


the tv-fe.log is 

ubuntu@ip-XX-X-X-XX:/var/log/upstart$ sudo tail -f tv-fe.log
  value = self.fget(obj)
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.2.1 (2012-10-21 16:57:04) stable
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), IMAP(imaplib)
2013-09-11 11:38:54,936 - WARNING - web2py - GUI not available because Tk 
library is not installed
no password, no admin interface
please visit:
http://0.0.0.0:8000
use kill -SIGTERM 11998 to shutdown the web2py server



/usr/local/lib/python2.7/dist-packages/riak-2.0.1.post5-py2.7.egg/riak/util.py:148:
 
UserWarning: ``solr`` is deprecated, use ``fulltext_search``, 
``fulltext_add`` and ``fulltext_delete`` directly
  value = self.fget(obj)

Entry in the scheduler worker table
 workers = db(db.scheduler_worker).select()
 for each in workers:
...   print each
... 
Row {'status': 'ACTIVE', 'first_heartbeat': datetime.datetime(2013, 9, 11, 
11, 39, 10), 'is_ticker': False, 'worker_name': 'ip-10-0-0-13#12026', 
'group_names': ['main'], 'last_heartbeat': datetime.datetime(2013, 9, 11, 
11, 43, 46), 'id': 1}


Entry in the scheduler_task table

Row {'vars': '{}', 'period': 600, 'group_name': 'main', 'times_failed': 0, 
'id': 1, 'last_run_time': None, 'uuid': 
'67263a73-c086-45e0-9c38-23c892af95c7', 'stop_time': None, 'retry_failed': 
3, 'function_name': 'total_devices', 'status': 'QUEUED', 'timeout': 300, 
'start_time': datetime.datetime(2013, 9, 11, 11, 41), 'args': '[]', 
'next_run_time': datetime.datetime(2013, 9, 11, 11, 43, 10), 'enabled': 
True, 'sync_output': 0, 'times_run': 0, 'task_name': 'total_devices', 
'application_name': 'app/default', 'repeats': 0, 'assigned_worker_name': 
''}


am I doing it the correct order, if yes then why doesnt the worker pickup 
the task. I am not sure whether the conf files I have created is right.

I run the services as 

sudo service tv-fe start
sudo service web2py-scheduler start





On Tuesday, 10 September 2013 23:34:56 UTC+5:30, Niphlod wrote:

 you may be missing some bits. on production nginx acts as a proxy 
 between uwsgi and the webyou don't need (again, usually) web2py to 
 start its own webserver the -X switch is only useful if you want a 
 single commandline to start BOTH the scheduler and the webserver, and it's 
 meant to be used only in development.

 Usually you'd have uwsgi serving the web part and a script to run the 
 scheduler (hence, just web2py.py -K appname) .
 BTW, upstart creates logs by default that are named after the servicename, 
 so something like /var/log/upstart/yourservicename.log gets created: you 
 may inspect that to see what is going on your server.

 On Tuesday, September 10, 2013 3:28:13 PM UTC+2, ajith c t wrote:

 ok i will try making two separate services. and which log are you 
 checking out, I maintain my custom logging mechanism. The only thing that 
 comes in it is 

 DEBUG - web2py.scheduler - defining tables (migrate=True)

 the app doesnt assign a worker in the scheduler_task table. The column 
 shows a NULL value. 

 I am using nginx, when I remove the -X parameter it results in a bad 
 gateway,



 On Tuesday, 10

[web2py] Re: Scheduler as upstart job

2013-09-11 Thread ajith c t
Sorry missed the issue, the issue is the task just doesnt get called up. I 
believe the scheduler_task will have the worker that picked up the task in 
the assigned_worker_name field. In my case it remains empty

On Wednesday, 11 September 2013 17:45:11 UTC+5:30, Niphlod wrote:

 what you posted doesn't indicate any issues. The task is there and the 
 worker too.
 What are you experiencing instead ?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-11 Thread ajith c t


When I start directly from the web2py folder, my load balancer gives me a 
bad gateway error. When I run the web2py shell , I see the scheduler tables 
are created. 

ubuntu@ip-10-0-0-13:/srv/tv-fe$ sudo python web2py.py -K app
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.2.1 (2012-10-21 16:57:04) stable
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), IMAP(imaplib)
starting single-scheduler for app...
/usr/local/lib/python2.7/dist-packages/riak-2.0.1.post5-py2.7.egg/riak/util.py:148:
 
UserWarning: ``solr`` is deprecated, use ``fulltext_search``, 
``fulltext_add`` and ``fulltext_delete`` directly
  value = self.fget(obj)



The scheduler_worker has record

Row {'status': 'ACTIVE', 'first_heartbeat': datetime.datetime(2013, 9, 11, 
13, 45, 18), 'is_ticker': False, 'worker_name': 'ip-10-0-0-13#13064', 
'group_names': ['main'], 'last_heartbeat': datetime.datetime(2013, 9, 11, 
13, 45, 45), 'id': 1}


But other tables are empty as expected for me.

My apps workflow is as follows, I dont understand if that is creating the 
problem,

I have a load balancer at a public ip, which has the nginx that acts as a 
reverse proxy for the  frontend server. The web2py folder is in this server 
and the models folder contains a scheduler.py file in which the tasks are 
defined and the scheduler class is called. Now in the controller 
default.py, index function calls the scheduler.queue_task. 

Since I started it from the web2py folder and it resulted in a bad gateway, 
the index function could not be called so the tasks is not scheduled.

But when I am using with upstart, there is no bad gateway error, everything 
goes fine except that the tasks in the  scheduler_task is not assigned a 
worker.


On Wednesday, 11 September 2013 19:03:19 UTC+5:30, Niphlod wrote:

 and when you start it without using upstart it works or not ?

 On Wednesday, September 11, 2013 2:22:32 PM UTC+2, ajith c t wrote:

 Sorry missed the issue, the issue is the task just doesnt get called up. 
 I believe the scheduler_task will have the worker that picked up the task 
 in the assigned_worker_name field. In my case it remains empty

 On Wednesday, 11 September 2013 17:45:11 UTC+5:30, Niphlod wrote:

 what you posted doesn't indicate any issues. The task is there and the 
 worker too.
 What are you experiencing instead ?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-11 Thread ajith c t
ubuntu@ip-10-0-0-13:/srv/trustvouch-fe$ sudo python web2py.py -K app -D 0
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2013
Version 2.2.1 (2012-10-21 16:57:04) stable
Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
PostgreSQL(pg8000), IMAP(imaplib)
starting single-scheduler for app...
/usr/local/lib/python2.7/dist-packages/riak-2.0.1.post5-py2.7.egg/riak/util.py:148:
 
UserWarning: ``solr`` is deprecated, use ``fulltext_search``, 
``fulltext_add`` and ``fulltext_delete`` directly
  value = self.fget(obj)




2013-09-11 14:21:20,236 - DEBUG - web2py.scheduler - defining tables 
(migrate=True)
2013-09-11 14:21:20,242 - DEBUG - web2py.scheduler - looping...
2013-09-11 14:21:20,246 - DEBUG - web2py.scheduler - nothing to do
2013-09-11 14:21:20,246 - DEBUG - web2py.scheduler - sleeping...
2013-09-11 14:21:20,246 - DEBUG - web2py.scheduler - thread building own 
DAL object
2013-09-11 14:21:20,249 - DEBUG - web2py.scheduler - defining tables 
(migrate=False)
2013-09-11 14:21:20,254 - DEBUG - web2py.scheduler - freeing workers 
that have not sent heartbeat
2013-09-11 14:21:23,249 - DEBUG - web2py.scheduler - looping...
2013-09-11 14:21:23,254 - DEBUG - web2py.scheduler - nothing to do
2013-09-11 14:21:23,254 - DEBUG - web2py.scheduler - sleeping...
2013-09-11 14:21:23,263 - DEBUG - web2py.scheduler - recording 
heartbeat
2013-09-11 14:21:26,257 - DEBUG - web2py.scheduler - looping...
2013-09-11 14:21:26,261 - DEBUG - web2py.scheduler - nothing to do
2013-09-11 14:21:26,262 - DEBUG - web2py.scheduler - sleeping...
2013-09-11 14:21:26,270 - DEBUG - web2py.scheduler - recording 
heartbeat
2013-09-11 14:21:29,265 - DEBUG - web2py.scheduler - looping...
2013-09-11 14:21:29,269 - DEBUG - web2py.scheduler - nothing to do
2013-09-11 14:21:29,269 - DEBUG - web2py.scheduler - sleeping...
2013-09-11 14:21:29,277 - DEBUG - web2py.scheduler - recording 
heartbeat


above the out put  of the log,

On Wednesday, 11 September 2013 19:48:06 UTC+5:30, Niphlod wrote:

 let's solve an issue at a time. If your scheduler can't process the tasks 
 that are in the queue when you launch it from the console, something is 
 wrong with it and there's nothing that upstart can fix. 
 If you launch your scheduler from the console with 
 web2py.py -K yourappname -D 0 
 what is the result ?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-11 Thread ajith c t
Thanks for the support. Yeah I will workout the steps you said one by one 
and breakdown the problem.

Just a  doubt, 

 ok. the scheduler from the console runs right. Now you have to test if 
queuing a task from web2py gets the task processed. 

Since I am having a load balancer, and the web2py folder is in another 
server, when running directly, I believe I will have to queue the task from 
the model file itself. Am I correct (as I wont be getting the controller of 
the app browser)


  Then you can do the same thing with the scheduler started by upstart, 
and verify that it's working 

Which will be the better one, using the command 
  exec python -- /srv/trustvouch-fe/web2py.py --nogui -a  -p 8000 -i 
0.0.0.0 -K app -X  

or having two upstart jobs (and I am not sure if these are the commands to 
start, can you confirm it also)
 one to run the app
  exec python -- /srv/trustvouch-fe/web2py.py --nogui -a  -p 8000 -i 
0.0.0.0 

 and one to start the scheduler
 exec python -- /srv/trustvouch-fe/web2py.py  -K app


On Wednesday, 11 September 2013 20:35:25 UTC+5:30, Niphlod wrote:

 ok. the scheduler from the console runs right. Now you have to test if 
 queuing a task from web2py gets the task processed. Then you can do the 
 same thing with the scheduler started by upstart, and verify that it's 
 working.
 Next is to verify that you can queue tasks from the web2py web server 
 started by upstart.
 Next to verify that the task queued gets processed by the scheduler in the 
 console
 Next to verify that it gets processed by the scheduler in upstart

 Something along the way should reveal where the breakage that you 
 experiment using both the webserver and the scheduler in upstart ^_^


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-11 Thread ajith c t
sorry I am not executing the code in the load balancer. Let me say once 
more, so it will be clear.

I dont have any web2py code in the load balancer. 

What I  meant is I have my code in another server(say X) , to which the 
user is redirected by the load balancer(say Y). 

when I execute the webpy application from server X , the index function , 
where my scheduler.queue_task call comes,in the default.py controller will 
not be called as I cant access it from X. That is expected. So what I asked 
was , for breaking down purpose shouldn't I move that call into the 
scheduler.py file in the models folder as the model file will be called.


And I will use the seperation of duties approach. but can you just 
confirm that the commands are correct.

On Wednesday, 11 September 2013 21:02:05 UTC+5:30, Niphlod wrote:




 Just a  doubt, 

  ok. the scheduler from the console runs right. Now you have to test if 
 queuing a task from web2py gets the task processed. 

 Since I am having a load balancer, and the web2py folder is in another 
 server, when running directly, I believe I will have to queue the task from 
 the model file itself. Am I correct (as I wont be getting the controller of 
 the app browser)

 you can't execute any web2py activity in any server that doesn't have 
 web2py code. The load balancer is NOT the place to open a console or to 
 configure an upstart job. It just load-balance all requests and splits them 
 on one server or the other. That is what load balancers are for. when you 
 reach the loadbalancer address the loadbalancer redirects the requests to 
 the backends, so it is on those servers that the activity takes place.
  


   Then you can do the same thing with the scheduler started by upstart, 
 and verify that it's working 

 Which will be the better one, using the command 
   exec python -- /srv/trustvouch-fe/web2py.py --nogui -a  -p 8000 -i 
 0.0.0.0 -K app -X  

 or having two upstart jobs (and I am not sure if these are the commands 
 to start, can you confirm it also)
  one to run the app
   exec python -- /srv/trustvouch-fe/web2py.py --nogui -a  -p 8000 -i 
 0.0.0.0 

  and one to start the scheduler
  exec python -- /srv/trustvouch-fe/web2py.py  -K app



 definitely the second one, for separation of duties.
  


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-11 Thread ajith c t
Agreed on the first point. Here  the tasks are not getting assigned because 
I am calling the queue_task from the controller. I believe the controller 
function 'index' didn't not load as app cannot be opened in the browser.

And the second point, yes the web2py version is a bit old, I had a little 
fear if I update the app midway. Well I will update it tonight .

On Wednesday, 11 September 2013 20:16:46 UTC+5:30, Niphlod wrote:

 so, the scheduler is working pretty fine: it just doesn't find any task to 
 process.

 PS: you are on a really old release (2.2.1). That's almost a year ago!

 On Wednesday, September 11, 2013 4:23:07 PM UTC+2, ajith c t wrote:

 ubuntu@ip-10-0-0-13:/srv/trustvouch-fe$ sudo python web2py.py -K app -D 0
 web2py Web Framework
 Created by Massimo Di Pierro, Copyright 2007-2013
 Version 2.2.1 (2012-10-21 16:57:04) stable
 Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
 PostgreSQL(pg8000), IMAP(imaplib)
 starting single-scheduler for app...
 /usr/local/lib/python2.7/dist-packages/riak-2.0.1.post5-py2.7.egg/riak/util.py:148:
  
 UserWarning: ``solr`` is deprecated, use ``fulltext_search``, 
 ``fulltext_add`` and ``fulltext_delete`` directly
   value = self.fget(obj)




 2013-09-11 14:21:20,236 - DEBUG - web2py.scheduler - defining tables 
 (migrate=True)
 2013-09-11 14:21:20,242 - DEBUG - web2py.scheduler - looping...
 2013-09-11 14:21:20,246 - DEBUG - web2py.scheduler - nothing to do
 2013-09-11 14:21:20,246 - DEBUG - web2py.scheduler - sleeping...
 2013-09-11 14:21:20,246 - DEBUG - web2py.scheduler - thread building own 
 DAL object
 2013-09-11 14:21:20,249 - DEBUG - web2py.scheduler - defining tables 
 (migrate=False)
 2013-09-11 14:21:20,254 - DEBUG - web2py.scheduler - freeing workers 
 that have not sent heartbeat
 2013-09-11 14:21:23,249 - DEBUG - web2py.scheduler - looping...
 2013-09-11 14:21:23,254 - DEBUG - web2py.scheduler - nothing to do
 2013-09-11 14:21:23,254 - DEBUG - web2py.scheduler - sleeping...
 2013-09-11 14:21:23,263 - DEBUG - web2py.scheduler - recording 
 heartbeat
 2013-09-11 14:21:26,257 - DEBUG - web2py.scheduler - looping...
 2013-09-11 14:21:26,261 - DEBUG - web2py.scheduler - nothing to do
 2013-09-11 14:21:26,262 - DEBUG - web2py.scheduler - sleeping...
 2013-09-11 14:21:26,270 - DEBUG - web2py.scheduler - recording 
 heartbeat
 2013-09-11 14:21:29,265 - DEBUG - web2py.scheduler - looping...
 2013-09-11 14:21:29,269 - DEBUG - web2py.scheduler - nothing to do
 2013-09-11 14:21:29,269 - DEBUG - web2py.scheduler - sleeping...
 2013-09-11 14:21:29,277 - DEBUG - web2py.scheduler - recording 
 heartbeat


 above the out put  of the log,

 On Wednesday, 11 September 2013 19:48:06 UTC+5:30, Niphlod wrote:

 let's solve an issue at a time. If your scheduler can't process the 
 tasks that are in the queue when you launch it from the console, something 
 is wrong with it and there's nothing that upstart can fix. 
 If you launch your scheduler from the console with 
 web2py.py -K yourappname -D 0 
 what is the result ?



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Scheduler as upstart job

2013-09-10 Thread ajith c t
Hi All,

  I have a scheduler in my app in the models folder with some specific 
task. I need to run the app as a service in the server. I cant figure out 
how to run start the web2py with the arguments.


script
 exec python -- /srv/tv-fe/web2py.py -K app -X --nogui -p 8000 -i 
0.0.0.0 -a ''   
end script

The above script is used to run the app. Upon running it , it doesnt 
generate error, but the worker is not created in the scheduler_worker 
table. So none of my task gets executed.

Where am I getting wrong with the parameters

Thanks and regards
Ajith

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Scheduler as upstart job

2013-09-10 Thread ajith c t
ok i will try making two separate services. and which log are you checking 
out, I maintain my custom logging mechanism. The only thing that comes in 
it is 

DEBUG - web2py.scheduler - defining tables (migrate=True)

the app doesnt assign a worker in the scheduler_task table. The column 
shows a NULL value. 

I am using nginx, when I remove the -X parameter it results in a bad 
gateway,



On Tuesday, 10 September 2013 18:21:36 UTC+5:30, Niphlod wrote:

 why don't you schedule two separate services (the webserver and the 
 scheduler), so the issues will be easier to track down ? what's in the logs 
 ?

 On Tuesday, September 10, 2013 1:42:11 PM UTC+2, ajith c t wrote:

 Hi All,

   I have a scheduler in my app in the models folder with some 
 specific task. I need to run the app as a service in the server. I cant 
 figure out how to run start the web2py with the arguments.


 script
  exec python -- /srv/tv-fe/web2py.py -K app -X --nogui -p 8000 -i 
 0.0.0.0 -a ''   
 end script

 The above script is used to run the app. Upon running it , it doesnt 
 generate error, but the worker is not created in the scheduler_worker 
 table. So none of my task gets executed.

 Where am I getting wrong with the parameters

 Thanks and regards
 Ajith



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] loading auth tables with custom names from a dump file into mysql database

2013-08-16 Thread ajith c t
Hi,
  I have defined my auth_tables in a mysql file along with some 
initial row for my app. The name of this file is '*dump.sql*'. 
 
I have renamed the tables, for example auth_users is changed to 
t_auth_users, similarly the other auth_tables too.

So when the app is hosted the db is created from this file. 

In the db.py file before the db.define_tables(), i have renamed the 
auth_tables, for example: 

  *auth.settings.table_user_name = 't_auth_users' *
 
and similarly others too. My question is how to efficiently handle this 
migration. I cannot get my auth tables modified according to the defintion 
in the dump.sql file.

Instead the table is created with default fields only. I have around 20 
fields for the t_auth_users table in dump.sql but only the 9 defaults 
fields can be seen in webp2y shell db.t_auth_users command.

this is the order:

1. First I clear all the files in databases folder for a fresh start.
2. Then load the dump.sql file into the database '*tv*' 
3.  in db.py
   *db = DAL('mysql://root:root@localhost/trustvouch', migrate=True)
*
*   *
*auth.settings.table_user_name = 't_auth_users'*
*   *
***auth.define_tables(username=True, migrate=True)*
4. It give me this error,
*   class '_mysql_exceptions.OperationalError' (1050, Table 
'tv_auth_users' already exists)*
*
*
*
*
Can you help how to get the correct migration of the tables.

What I actually need to do is load my  table definitions from another mysql 
dump file ,  use the tables defined there as my auth tables.
   
*
*

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: loading auth tables with custom names from a dump file into mysql database

2013-08-16 Thread ajith c t
So does that mean I dont have to specify any migrate keyword?  I just have 
a file with custom auth table definitons and need to use it. 

On Friday, 16 August 2013 17:49:29 UTC+5:30, Niphlod wrote:

 if you create your tables you can't enable migrations in web2py, 'cause 
 web2py will try to create them.

 On Friday, August 16, 2013 2:11:44 PM UTC+2, ajith c t wrote:

 Hi,
   I have defined my auth_tables in a mysql file along with some 
 initial row for my app. The name of this file is '*dump.sql*'. 
  
 I have renamed the tables, for example auth_users is changed to 
 t_auth_users, similarly the other auth_tables too.

 So when the app is hosted the db is created from this file. 

 In the db.py file before the db.define_tables(), i have renamed the 
 auth_tables, for example: 

   *auth.settings.table_user_name = 't_auth_users' *
  
 and similarly others too. My question is how to efficiently handle this 
 migration. I cannot get my auth tables modified according to the defintion 
 in the dump.sql file.

 Instead the table is created with default fields only. I have around 20 
 fields for the t_auth_users table in dump.sql but only the 9 defaults 
 fields can be seen in webp2y shell db.t_auth_users command.

 this is the order:

 1. First I clear all the files in databases folder for a fresh start.
 2. Then load the dump.sql file into the database '*tv*' 
 3.  in db.py
*db = DAL('mysql://root:root@localhost/trustvouch', 
 migrate=True)*
 *   *
 *auth.settings.table_user_name = 't_auth_users'*
 *   *
 ***auth.define_tables(username=True, migrate=True)*
 4. It give me this error,
 *   class '_mysql_exceptions.OperationalError' (1050, Table 
 'tv_auth_users' already exists)*
 *
 *
 *
 *
 Can you help how to get the correct migration of the tables.

 What I actually need to do is load my  table definitions from another 
 mysql dump file ,  use the tables defined there as my auth tables.

 *
 *



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: loading auth tables with custom names from a dump file into mysql database

2013-08-16 Thread ajith c t
Ok I tried the first request with fake_migrate = True, then everything 
works fine. The app runs. I open the web2py shell and run the db.tables 
command it list the default auth tables only,  with the customized names.
But these tables contains only the default auth fields in it, but in my 
dump file I have quite a number of fields.
I then remove the fake_migrate argument and run the app. The same result is 
found. Only the default fields are there with the values.

Isnt the web2py shell supposed to show all the fields in the database.

On Friday, 16 August 2013 17:57:57 UTC+5:30, Niphlod wrote:

 if your models match the tables you're creating on mysql manually, then 
 what do you need migration for ?
 set migrate=False ... you did manually what web2py usually does 
 automatically.
 I'd also use fake_migrate=True for the first request (then remove it) just 
 to update the relevant .table files in the databases/* folder.

 On Friday, August 16, 2013 2:25:13 PM UTC+2, ajith c t wrote:

 So does that mean I dont have to specify any migrate keyword?  I just 
 have a file with custom auth table definitons and need to use it. 

 On Friday, 16 August 2013 17:49:29 UTC+5:30, Niphlod wrote:

 if you create your tables you can't enable migrations in web2py, 'cause 
 web2py will try to create them.

 On Friday, August 16, 2013 2:11:44 PM UTC+2, ajith c t wrote:

 Hi,
   I have defined my auth_tables in a mysql file along with some 
 initial row for my app. The name of this file is '*dump.sql*'. 
  
 I have renamed the tables, for example auth_users is changed to 
 t_auth_users, similarly the other auth_tables too.

 So when the app is hosted the db is created from this file. 

 In the db.py file before the db.define_tables(), i have renamed the 
 auth_tables, for example: 

   *auth.settings.table_user_name = 't_auth_users' *
  
 and similarly others too. My question is how to efficiently handle this 
 migration. I cannot get my auth tables modified according to the defintion 
 in the dump.sql file.

 Instead the table is created with default fields only. I have around 20 
 fields for the t_auth_users table in dump.sql but only the 9 defaults 
 fields can be seen in webp2y shell db.t_auth_users command.

 this is the order:

 1. First I clear all the files in databases folder for a fresh start.
 2. Then load the dump.sql file into the database '*tv*' 
 3.  in db.py
*db = DAL('mysql://root:root@localhost/trustvouch', 
 migrate=True)*
 *   *
 *auth.settings.table_user_name = 't_auth_users'*
 *   *
 ***auth.define_tables(username=True, migrate=True)*
 4. It give me this error,
 *   class '_mysql_exceptions.OperationalError' (1050, Table 
 'tv_auth_users' already exists)*
 *
 *
 *
 *
 Can you help how to get the correct migration of the tables.

 What I actually need to do is load my  table definitions from another 
 mysql dump file ,  use the tables defined there as my auth tables.

 *
 *



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: loading auth tables with custom names from a dump file into mysql database

2013-08-16 Thread ajith c t
so does that mean if I add the changes for  default auth table 
definition  in my db.py file with respect to the auth table in the dump 
file, then only it will be reflected in the web2py shell. And once both the 
definitions matches then there is no need migration also.
The change is only in the auth_user table. So I will have to add extra 
fields to the t_auth_users tables in db.py.



On Friday, 16 August 2013 18:40:47 UTC+5:30, Niphlod wrote:

 web2py shell shows you your tables as they are defined in models. What is 
 there on the database usually matches (when migrate=True or when you're 
 totally and absolutely sure that your models match the underlying table 
 definitions). 
 If you see in web2py shell something different from your underiyng tables, 
 then the difference is to be found in your models, meaning that your 
 table definitions DON'T match your underlying schema.

 On Friday, August 16, 2013 2:43:22 PM UTC+2, ajith c t wrote:

 Ok I tried the first request with fake_migrate = True, then everything 
 works fine. The app runs. I open the web2py shell and run the db.tables 
 command it list the default auth tables only,  with the customized names.
 But these tables contains only the default auth fields in it, but in my 
 dump file I have quite a number of fields.
 I then remove the fake_migrate argument and run the app. The same result 
 is found. Only the default fields are there with the values.

 Isnt the web2py shell supposed to show all the fields in the database.

 On Friday, 16 August 2013 17:57:57 UTC+5:30, Niphlod wrote:

 if your models match the tables you're creating on mysql manually, then 
 what do you need migration for ?
 set migrate=False ... you did manually what web2py usually does 
 automatically.
 I'd also use fake_migrate=True for the first request (then remove it) 
 just to update the relevant .table files in the databases/* folder.

 On Friday, August 16, 2013 2:25:13 PM UTC+2, ajith c t wrote:

 So does that mean I dont have to specify any migrate keyword?  I just 
 have a file with custom auth table definitons and need to use it. 

 On Friday, 16 August 2013 17:49:29 UTC+5:30, Niphlod wrote:

 if you create your tables you can't enable migrations in web2py, 
 'cause web2py will try to create them.

 On Friday, August 16, 2013 2:11:44 PM UTC+2, ajith c t wrote:

 Hi,
   I have defined my auth_tables in a mysql file along with 
 some initial row for my app. The name of this file is '*dump.sql*'. 
  
 I have renamed the tables, for example auth_users is changed to 
 t_auth_users, similarly the other auth_tables too.

 So when the app is hosted the db is created from this file. 

 In the db.py file before the db.define_tables(), i have renamed the 
 auth_tables, for example: 

   *auth.settings.table_user_name = 't_auth_users' *
  
 and similarly others too. My question is how to efficiently handle 
 this migration. I cannot get my auth tables modified according to the 
 defintion in the dump.sql file.

 Instead the table is created with default fields only. I have around 
 20 fields for the t_auth_users table in dump.sql but only the 9 defaults 
 fields can be seen in webp2y shell db.t_auth_users command.

 this is the order:

 1. First I clear all the files in databases folder for a fresh start.
 2. Then load the dump.sql file into the database '*tv*' 
 3.  in db.py
*db = DAL('mysql://root:root@localhost/trustvouch', 
 migrate=True)*
 *   *
 *auth.settings.table_user_name = 't_auth_users'*
 *   *
 ***auth.define_tables(username=True, migrate=True)*
 4. It give me this error,
 *   class '_mysql_exceptions.OperationalError' (1050, 
 Table 'tv_auth_users' already exists)*
 *
 *
 *
 *
 Can you help how to get the correct migration of the tables.

 What I actually need to do is load my  table definitions from another 
 mysql dump file ,  use the tables defined there as my auth tables.

 *
 *



-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: loading auth tables with custom names from a dump file into mysql database

2013-08-16 Thread ajith c t
Ok thanks. Just one more thing, so if there are around 10 tables in my dump 
file which is loaded into the database and I have set migrate = False, as I 
dont make any modifications or table alterations in the db.py. How can I 
get these tables listed in the db.tables command in the web2py shell. Its 
really confusing me. I ran my  app with migrate = False, since the table 
definitions are all there in dump file. But in the web2py shell it just 
shows the auth_tables with the default declerations only.  

On Friday, 16 August 2013 19:18:56 UTC+5:30, Niphlod wrote:

 that's basically the deal. Either you let web2py manage the database 
 (migrate=True), or you do it by hand (migrate=False). There's no need to 
 have migrate=True unless you modified your models, and in fact in 
 production is recommended to turn migrations off to gain speed. But what 
 you see in web2py is always only relative to your code, because web2py 
 doesn't engage in any kind of introspection of what tables really are in 
 your backend.

 On Friday, August 16, 2013 3:30:18 PM UTC+2, ajith c t wrote:

 so does that mean if I add the changes for  default auth table 
 definition  in my db.py file with respect to the auth table in the dump 
 file, then only it will be reflected in the web2py shell. And once both the 
 definitions matches then there is no need migration also.
 The change is only in the auth_user table. So I will have to add extra 
 fields to the t_auth_users tables in db.py.



 On Friday, 16 August 2013 18:40:47 UTC+5:30, Niphlod wrote:

 web2py shell shows you your tables as they are defined in models. What 
 is there on the database usually matches (when migrate=True or when you're 
 totally and absolutely sure that your models match the underlying table 
 definitions). 
 If you see in web2py shell something different from your underiyng 
 tables, then the difference is to be found in your models, meaning that 
 your table definitions DON'T match your underlying schema.

 On Friday, August 16, 2013 2:43:22 PM UTC+2, ajith c t wrote:

 Ok I tried the first request with fake_migrate = True, then everything 
 works fine. The app runs. I open the web2py shell and run the db.tables 
 command it list the default auth tables only,  with the customized names.
 But these tables contains only the default auth fields in it, but in my 
 dump file I have quite a number of fields.
 I then remove the fake_migrate argument and run the app. The same 
 result is found. Only the default fields are there with the values.

 Isnt the web2py shell supposed to show all the fields in the database.

 On Friday, 16 August 2013 17:57:57 UTC+5:30, Niphlod wrote:

 if your models match the tables you're creating on mysql manually, 
 then what do you need migration for ?
 set migrate=False ... you did manually what web2py usually does 
 automatically.
 I'd also use fake_migrate=True for the first request (then remove it) 
 just to update the relevant .table files in the databases/* folder.

 On Friday, August 16, 2013 2:25:13 PM UTC+2, ajith c t wrote:

 So does that mean I dont have to specify any migrate keyword?  I just 
 have a file with custom auth table definitons and need to use it. 

 On Friday, 16 August 2013 17:49:29 UTC+5:30, Niphlod wrote:

 if you create your tables you can't enable migrations in web2py, 
 'cause web2py will try to create them.

 On Friday, August 16, 2013 2:11:44 PM UTC+2, ajith c t wrote:

 Hi,
   I have defined my auth_tables in a mysql file along with 
 some initial row for my app. The name of this file is '*dump.sql*
 '. 
  
 I have renamed the tables, for example auth_users is changed to 
 t_auth_users, similarly the other auth_tables too.

 So when the app is hosted the db is created from this file. 

 In the db.py file before the db.define_tables(), i have renamed the 
 auth_tables, for example: 

   *auth.settings.table_user_name = 't_auth_users' *
  
 and similarly others too. My question is how to efficiently handle 
 this migration. I cannot get my auth tables modified according to the 
 defintion in the dump.sql file.

 Instead the table is created with default fields only. I have 
 around 20 fields for the t_auth_users table in dump.sql but only the 9 
 defaults fields can be seen in webp2y shell db.t_auth_users command.

 this is the order:

 1. First I clear all the files in databases folder for a fresh 
 start.
 2. Then load the dump.sql file into the database '*tv*' 
 3.  in db.py
*db = DAL('mysql://root:root@localhost/trustvouch', 
 migrate=True)*
 *   *
 *auth.settings.table_user_name = 't_auth_users'*
 *   *
 ***auth.define_tables(username=True, migrate=True)*
 4. It give me this error,
 *   class '_mysql_exceptions.OperationalError' (1050, 
 Table 'tv_auth_users' already exists)*
 *
 *
 *
 *
 Can you help how to get the correct migration of the tables.

 What I actually need to do is load my  table definitions from 
 another mysql

[web2py] Re: loading auth tables with custom names from a dump file into mysql database

2013-08-16 Thread ajith c t
Thank you Niphold for your time and patience. So actually there isnt any 
particular benefit in writing in a dump file and loading. Its better to 
write these definitions in another db.py (like mydb.py) file and load. Then 
I would be able to get it in the db.py. Thanks

On Friday, 16 August 2013 19:56:29 UTC+5:30, Niphlod wrote:

 Again, web2py shell doesn't know anything that is not in your models. 
 Whatever dump you loaded into your database, web2py doesn't know anything 
 about it. 
 Web2py can only access what you set in your db.py: of course what is there 
 must match what is in the database, because at the first time you'll try to 
 select() data from those tables, if column names and types don't match, an 
 exception will be raised.

 On Friday, August 16, 2013 4:10:35 PM UTC+2, ajith c t wrote:

 Ok thanks. Just one more thing, so if there are around 10 tables in my 
 dump file which is loaded into the database and I have set migrate = False, 
 as I dont make any modifications or table alterations in the db.py. How can 
 I get these tables listed in the db.tables command in the web2py shell. Its 
 really confusing me. I ran my  app with migrate = False, since the table 
 definitions are all there in dump file. But in the web2py shell it just 
 shows the auth_tables with the default declerations only.  

 On Friday, 16 August 2013 19:18:56 UTC+5:30, Niphlod wrote:

 that's basically the deal. Either you let web2py manage the database 
 (migrate=True), or you do it by hand (migrate=False). There's no need to 
 have migrate=True unless you modified your models, and in fact in 
 production is recommended to turn migrations off to gain speed. But what 
 you see in web2py is always only relative to your code, because web2py 
 doesn't engage in any kind of introspection of what tables really are in 
 your backend.

 On Friday, August 16, 2013 3:30:18 PM UTC+2, ajith c t wrote:

 so does that mean if I add the changes for  default auth table 
 definition  in my db.py file with respect to the auth table in the dump 
 file, then only it will be reflected in the web2py shell. And once both 
 the 
 definitions matches then there is no need migration also.
 The change is only in the auth_user table. So I will have to add extra 
 fields to the t_auth_users tables in db.py.



 On Friday, 16 August 2013 18:40:47 UTC+5:30, Niphlod wrote:

 web2py shell shows you your tables as they are defined in models. What 
 is there on the database usually matches (when migrate=True or when 
 you're 
 totally and absolutely sure that your models match the underlying table 
 definitions). 
 If you see in web2py shell something different from your underiyng 
 tables, then the difference is to be found in your models, meaning that 
 your table definitions DON'T match your underlying schema.

 On Friday, August 16, 2013 2:43:22 PM UTC+2, ajith c t wrote:

 Ok I tried the first request with fake_migrate = True, then 
 everything works fine. The app runs. I open the web2py shell and run the 
 db.tables command it list the default auth tables only,  with the 
 customized names.
 But these tables contains only the default auth fields in it, but in 
 my dump file I have quite a number of fields.
 I then remove the fake_migrate argument and run the app. The same 
 result is found. Only the default fields are there with the values.

 Isnt the web2py shell supposed to show all the fields in the database.

 On Friday, 16 August 2013 17:57:57 UTC+5:30, Niphlod wrote:

 if your models match the tables you're creating on mysql manually, 
 then what do you need migration for ?
 set migrate=False ... you did manually what web2py usually does 
 automatically.
 I'd also use fake_migrate=True for the first request (then remove 
 it) just to update the relevant .table files in the databases/* folder.

 On Friday, August 16, 2013 2:25:13 PM UTC+2, ajith c t wrote:

 So does that mean I dont have to specify any migrate keyword?  I 
 just have a file with custom auth table definitons and need to use it. 

 On Friday, 16 August 2013 17:49:29 UTC+5:30, Niphlod wrote:

 if you create your tables you can't enable migrations in web2py, 
 'cause web2py will try to create them.

 On Friday, August 16, 2013 2:11:44 PM UTC+2, ajith c t wrote:

 Hi,
   I have defined my auth_tables in a mysql file along 
 with some initial row for my app. The name of this file is '*
 dump.sql*'. 
  
 I have renamed the tables, for example auth_users is changed to 
 t_auth_users, similarly the other auth_tables too.

 So when the app is hosted the db is created from this file. 

 In the db.py file before the db.define_tables(), i have renamed 
 the auth_tables, for example: 

   *auth.settings.table_user_name = 't_auth_users' *
  
 and similarly others too. My question is how to efficiently 
 handle this migration. I cannot get my auth tables modified 
 according to 
 the defintion in the dump.sql file.

 Instead the table is created with default fields only. I have

[web2py] Re: loading auth tables with custom names from a dump file into mysql database

2013-08-16 Thread ajith c t
what I actually wanted to do is this. when my app runs for the first time 
it has the auth user table (renamed to tv_auth_users), around 20 columns 
and 2 records. the structure of other auth_tables remains same. But the 
tv_auth_permissions table has around 40 records and tv_auth_membership and 
the tv_auth_groups have 3 records each. So I thought if I put these in a 
seperate file it would speed up the app. I didnt know how to write the 
db.py file for such a scenario.

On Friday, 16 August 2013 20:38:00 UTC+5:30, Niphlod wrote:



 On Friday, August 16, 2013 4:32:26 PM UTC+2, ajith c t wrote:

 Thank you Niphold for your time and patience. So actually there isnt any 
 particular benefit in writing in a dump file and loading. Its better to 
 write these definitions in another db.py (like mydb.py) file and load. Then 
 I would be able to get it in the db.py. Thanks

 Not sure of what you mean, but if you don't need to restore any data (so, 
 you need only the schema) is definitely faster to let web2py manage it on 
 an empty database. 


-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Use reserved keywords of mysql

2013-06-18 Thread ajith c t
Hi,
 Is there is any update on the usage of reserved keywords in the table 
definition. In this thread 

https://groups.google.com/forum/?fromgroups=#!newtopic/web2py/web2py/hCsxVaDLfT4
 Massimo 
says we need to change it in dal.py.

I need to create a table in mysql db as:

db.define_table('rms_rule', 
Field('condition', 
requires=IS_IN_SET(['IsEqual','IsNotEqual','IsGreater','IsLesser','IsNull','IsNotNull','Likeliness','IsMatch','IsNotMatch','In'])),
)

I tried with backticks(`) as mysql stats and different combinations of 
qoutes.

If I use it as given above the error is a mysql programming error:

ProgrammingError: (1064, You have an error in your SQL syntax; check the 
manual that corresponds to your MySQL server version for the right syntax 
to use near 'condition VARCHAR(255),\ndescription VARCHAR(255) NOT 
NULL,\nparams VARCHA' at line 13)

So it passed DAL but escaping might be the problem. But using the backticks 
as mysql says, it generates syntax error which is caught by DAL. 

db.define_table('rms_rule', 
Field('`condition`', 
requires=IS_IN_SET(['IsEqual','IsNotEqual','IsGreater','IsLesser','IsNull','IsNotNull','Likeliness','IsMatch','IsNotMatch','In'])),
)

SyntaxError: invalid table or field name: `condition`

is there any way in escaping these reserve keywords. Its difficult to 
change the field name as its already defined by third party in mysql.

The above thread was one year back.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: nothing happens after custom form submission

2013-01-04 Thread ajith c t
Hi all, I got the solution.  I changed the def myregister() function into 
def register(). Its working  fine now. 
Previously it wasn't working, and the only thing I did new was just doing a 
clean from admin site menu. There is no point in clearing your browser 
history or restarting your shell. The clean helped me a lot. 

To howesc, you can use the normal form tag and close it using 
 {{form.custom.end}}. This is helpful when you have lot of customization in 
your form especially with css. And you get the hidden form fields generated 
automatically using the form.custom.end. 

On Friday, 4 January 2013 06:17:44 UTC+5:30, Anthony wrote:

 form.custom.end is what includes the hidden fields, and that has been 
 included in the code.

 Anthony

 On Thursday, January 3, 2013 6:59:20 PM UTC-5, howesc wrote:

 i don't see a {{=form.custom.begin}} in your view.  this is required to 
 output the hidden fields that web2py uses to validate the form submission.

 On Wednesday, January 2, 2013 8:03:47 AM UTC-8, ajith c t wrote:

 This is my form and controller function. My problem is nothing happens 
 (redirection) after the register button is clicked. 

 def myregister():
   select all roles greater than 1. root is always 1 
   print in myregister
   
   form = auth.register(next='index')
   
   print form.vars
   return dict(form = form)   

 the above is my custom myregister() function.

 {{extend 'layout.html'}}
 h1This is the default/myregister.html template/h1

 form action= enctype=multipart/form-data method=post 
 class=form-horizontal
 
 username:
 {{=form.custom.widget.username}}
 email:
 {{=form.custom.widget.email}}

 password:
 {{=form.custom.widget.password}}
 confirm password:
 {{=form.custom.widget.password_two}}
 
 account_id:
  {{=form.custom.widget.account_id}}

 role_id:
 {{=form.custom.widget.role_id}}

 {{=form.custom.submit}}
 

 {{=form.custom.end}}
 {{pass}}

 above code is my custom register view myregister.html

 i am using auth_user table after adding extra fields:

 auth.settings.extra_fields['auth_user']= [
 Field('account_id', 'integer', notnull=True),  # (`account_id` 
 int(11) NOT NULL,)
 Field('organisation_id', 'integer'),   # (`organisation_id` 
 int(11) DEFAULT '0',)
 Field('role_id', 'integer', notnull=True, requires = IS_IN_SET([(2, 
 'admin'), (3, 'merchant'), (4, 'guest')])),  # (`role_id` int(11) NOT NULL 
 DEFAULT '0',)
 Field('username', 'string'),   # (`username` varchar(64) 
 COLLATE utf8_bin DEFAULT NULL,)
 Field('telephone', 'string'),  # (`telephone` 
 varchar(16) COLLATE utf8_bin DEFAULT NULL,)
 Field('mobile', 'string'), # (`mobile` varchar(16) 
 COLLATE utf8_bin DEFAULT NULL,)
 Field('gender', 'string'), # (`gender` char(1) 
 COLLATE utf8_bin DEFAULT NULL,)
 Field('about', 'text'),# (`about` text COLLATE 
 utf8_bin,)
 Field('addr_1', 'string'), # (`addr_1` varchar(128) 
 COLLATE utf8_bin DEFAULT NULL,)
 Field('addr_2', 'string'), # (`addr_2` varchar(128) 
 COLLATE utf8_bin DEFAULT NULL,)
 Field('addr_3', 'string'), # (`addr_3` varchar(128) 
 COLLATE utf8_bin DEFAULT NULL,)
 Field('city', 'string'),   # (`city` varchar(64) 
 COLLATE utf8_bin DEFAULT NULL,)
 Field('region', 'string'), # (`region` varchar(32) 
 COLLATE utf8_bin DEFAULT NULL,)
 Field('country', 'string'),# (`country` char(2) 
 COLLATE utf8_bin DEFAULT NULL,)
 Field('post_code', 'string'),  # (`post_code` 
 varchar(16) COLLATE utf8_bin DEFAULT NULL,)
 Field('is_email_public', 'integer'),   # (`is_email_public` 
 smallint(6) DEFAULT NULL,)
 Field('is_acct_active', 'integer'),# (`is_acct_active` 
 smallint(6) DEFAULT NULL,)
 Field('security_question', 'integer'), # (`security_question` 
 smallint(6) DEFAULT NULL,)
 Field('security_answer', 'string'),# (`security_answer` 
 varchar(128) COLLATE utf8_bin DEFAULT NULL,)
 Field('date_created', 'datetime'), # (`date_created` 
 datetime DEFAULT NULL,)
 Field('created_by', 'integer'),# (`created_by` int(11) 
 DEFAULT NULL,)
 Field('last_updated', 'datetime'), # (`last_updated` 
 datetime DEFAULT NULL,)
 Field('updated_by', 'integer')

 ]
 
 auth.settings.registration_requires_verification = False
 auth.settings.registration_requires_approval = False
 auth.settings.reset_password_requires_verification = True
 auth.settings.login_after_registration = True
 auth.settings.create_user_groups = False

 def onaccept(form): # form accepted
 auth.add_membership(form.vars.role_id, form.vars.id)
 
 auth.settings.register_onaccept.append(onaccept)


 I dont know what is going wrong.
 I have gone through similar questions in this forum but could solve

[web2py] nothing happens after custom form submission

2013-01-02 Thread ajith c t
This is my form and controller function. My problem is nothing happens 
(redirection) after the register button is clicked. 

def myregister():
  select all roles greater than 1. root is always 1 
  print in myregister
  
  form = auth.register(next='index')
  
  print form.vars
  return dict(form = form)   

the above is my custom myregister() function.

{{extend 'layout.html'}}
h1This is the default/myregister.html template/h1

form action= enctype=multipart/form-data method=post 
class=form-horizontal

username:
{{=form.custom.widget.username}}
email:
{{=form.custom.widget.email}}

password:
{{=form.custom.widget.password}}
confirm password:
{{=form.custom.widget.password_two}}

account_id:
 {{=form.custom.widget.account_id}}

role_id:
{{=form.custom.widget.role_id}}

{{=form.custom.submit}}


{{=form.custom.end}}
{{pass}}

above code is my custom register view myregister.html

i am using auth_user table after adding extra fields:

auth.settings.extra_fields['auth_user']= [
Field('account_id', 'integer', notnull=True),  # (`account_id` int(11) 
NOT NULL,)
Field('organisation_id', 'integer'),   # (`organisation_id` int(11) 
DEFAULT '0',)
Field('role_id', 'integer', notnull=True, requires = IS_IN_SET([(2, 
'admin'), (3, 'merchant'), (4, 'guest')])),  # (`role_id` int(11) NOT NULL 
DEFAULT '0',)
Field('username', 'string'),   # (`username` varchar(64) 
COLLATE utf8_bin DEFAULT NULL,)
Field('telephone', 'string'),  # (`telephone` varchar(16) 
COLLATE utf8_bin DEFAULT NULL,)
Field('mobile', 'string'), # (`mobile` varchar(16) 
COLLATE utf8_bin DEFAULT NULL,)
Field('gender', 'string'), # (`gender` char(1) COLLATE 
utf8_bin DEFAULT NULL,)
Field('about', 'text'),# (`about` text COLLATE 
utf8_bin,)
Field('addr_1', 'string'), # (`addr_1` varchar(128) 
COLLATE utf8_bin DEFAULT NULL,)
Field('addr_2', 'string'), # (`addr_2` varchar(128) 
COLLATE utf8_bin DEFAULT NULL,)
Field('addr_3', 'string'), # (`addr_3` varchar(128) 
COLLATE utf8_bin DEFAULT NULL,)
Field('city', 'string'),   # (`city` varchar(64) 
COLLATE utf8_bin DEFAULT NULL,)
Field('region', 'string'), # (`region` varchar(32) 
COLLATE utf8_bin DEFAULT NULL,)
Field('country', 'string'),# (`country` char(2) COLLATE 
utf8_bin DEFAULT NULL,)
Field('post_code', 'string'),  # (`post_code` varchar(16) 
COLLATE utf8_bin DEFAULT NULL,)
Field('is_email_public', 'integer'),   # (`is_email_public` 
smallint(6) DEFAULT NULL,)
Field('is_acct_active', 'integer'),# (`is_acct_active` 
smallint(6) DEFAULT NULL,)
Field('security_question', 'integer'), # (`security_question` 
smallint(6) DEFAULT NULL,)
Field('security_answer', 'string'),# (`security_answer` 
varchar(128) COLLATE utf8_bin DEFAULT NULL,)
Field('date_created', 'datetime'), # (`date_created` datetime 
DEFAULT NULL,)
Field('created_by', 'integer'),# (`created_by` int(11) 
DEFAULT NULL,)
Field('last_updated', 'datetime'), # (`last_updated` datetime 
DEFAULT NULL,)
Field('updated_by', 'integer')
   
]

auth.settings.registration_requires_verification = False
auth.settings.registration_requires_approval = False
auth.settings.reset_password_requires_verification = True
auth.settings.login_after_registration = True
auth.settings.create_user_groups = False

def onaccept(form): # form accepted
auth.add_membership(form.vars.role_id, form.vars.id)

auth.settings.register_onaccept.append(onaccept)


I dont know what is going wrong.
I have gone through similar questions in this forum but could solve this. 
any help would be appreciated

-- 





[web2py] enum datatype in table definition

2012-12-27 Thread ajith c t


 Field('condition', 
enum('IsEqual','IsNotEqual','IsGreater','IsLesser','IsNull','IsNotNull','Likeliness','IsMatch','IsNotMatch','In','NotIn','Found','NotFound'),
 
notnull=True), 

the above syntax gives me error while defining the table in web2py.  how 
can one specify an enum datatype in web2py table definition

-- 





[web2py] Re: enum datatype in table definition

2012-12-27 Thread ajith c t
Thanks Niphold, I used your code but now it is showing another error, I 
have seen this error before also but dont know whats exactly wrong here,
Below is my table definition, 

db.define_table('some_rule', 
Field('rule_id', 'integer', notnull=True),  # (`rule_id` smallint(8) 
unsigned NOT NULL,)
Field('created_on', 'datetime', notnull=True),  # (`created_on` 
datetime NOT NULL,)
Field('modified_on', 'datetime', notnull=True),  # (`modified_on` 
datetime NOT NULL,)
Field('created_by', 'integer', notnull=True),  # (`created_by` int(11) 
NOT NULL,)
Field('category_id', 'integer', notnull=True),  # (`category_id` 
int(11) NOT NULL,)
Field('is_active', 'integer', notnull=True),  # (`is_active` tinyint(4) 
unsigned NOT NULL,)
Field('action', 'string', notnull=True),   # (`action` 
enum('None','Review','Approve','Reject') NOT NULL,)
Field('score', 'integer', notnull=True),   # (`score` smallint(6) NOT 
NULL DEFAULT '0',)
Field('field_id', 'integer', notnull=True),  # (`field_id` smallint(5) 
unsigned NOT NULL,)
Field('params_type', 'integer', notnull=True),  # (`params_type` 
tinyint(3) unsigned NOT NULL,)
Field('condition', 
requires=IS_IN_SET(['IsEqual','IsNotEqual','IsGreater','IsLesser','IsNull','IsNotNull','Likeliness','IsMatch','IsNotMatch','In','NotIn','Found','NotFound'])),
 
 
Field('description', 'string', notnull=True),  # (`description` 
varchar(255) NOT NULL,)
Field('params', 'string', notnull=True),   # (`params` varchar(255) NOT 
NULL,)
migrate='some_rule.table'
)

But this one gives me an error as,

  class '_mysql_exceptions.ProgrammingError' (1064, You have an error in 
your SQL syntax; check the manual that corresponds to your MySQL server 
version for the right syntax to use near 'condition VARCHAR(255)' at line 
1)

I checked the sql log,
 the last statement at the time of error is 

timestamp: 2012-12-28T12:07:19.578109
ALTER TABLE rms_rule ADD condition VARCHAR(255);

I am developing this application and is stuck at this point please help me


On Thursday, 27 December 2012 19:12:58 UTC+5:30, Niphlod wrote:

 Field('condition', requires=IS_IN_SET(['IsEqual','IsNotEqual','IsGreater',
 'IsLesser','IsNull','IsNotNull','Likeliness','IsMatch','IsNotMatch','In',
 'NotIn','Found','NotFound']))



 Il giorno giovedì 27 dicembre 2012 13:30:04 UTC+1, ajith c t ha scritto:



  Field('condition', 
 enum('IsEqual','IsNotEqual','IsGreater','IsLesser','IsNull','IsNotNull','Likeliness','IsMatch','IsNotMatch','In','NotIn','Found','NotFound'),
  
 notnull=True), 

 the above syntax gives me error while defining the table in web2py.  how 
 can one specify an enum datatype in web2py table definition



-- 





Re: [web2py] Re: enum datatype in table definition

2012-12-27 Thread ajith c t
Does it mean that i need to change the field name from condition to 
anything else...or the argument check_reserved=['all'] allows to use the 
reserved keywords. 
The manual says it checks for the reserved keywords, but didn't understand 
whether it will block or skip these keywords.

And one more thing this table is part of a working mysql database. I am 
integrating it into web2py. 

On Friday, 28 December 2012 12:19:22 UTC+5:30, rochacbruno wrote:



 On Fri, Dec 28, 2012 at 4:46 AM, ajith c t ajith...@gmail.comjavascript:
  wrote:

 condition


 condition is a MySQL reserved keyword, you can't use this as the name of 
 table or field

 http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

 To solve this kinf od problems.

 db = DAL(mysql, check_reserved=[all])


-- 





Re: [web2py] Re: enum datatype in table definition

2012-12-27 Thread ajith c t
so using the argument db=DAL(' mysql://..  ' , check_reserved=['all']), 
it restricts the use of the mysql keywords. But the problem is the database 
which already available in mysql contains table name such block, other 
that the condition field. So it impossible for me to change the database 
structure. 
One more thing I tried running sql query in mysql prompt but it doesnt give 
errors.
mysql CREATE TABLE IF NOT EXISTS `rms_rule` (
-   `rule_id` smallint(8) unsigned NOT NULL,
-   `created_on` datetime NOT NULL,
-   `modified_on` datetime NOT NULL,
-   `created_by` int(11) NOT NULL,
-   `category_id` int(11) NOT NULL,
-   `is_active` tinyint(4) unsigned NOT NULL,
-   `action` enum('None','Review','Approve','Reject') NOT NULL,
-   `score` smallint(6) NOT NULL DEFAULT '0',
-   `field_id` smallint(5) unsigned NOT NULL,
-   `params_type` tinyint(3) unsigned NOT NULL,
-   `condition` 
enum('IsEqual','IsNotEqual','IsGreater','IsLesser','IsNull','IsNotNull','Likeliness','IsMatch','IsNotMatch','In','NotIn','Found','NotFound')
 
NOT NULL,
-   `description` varchar(255) NOT NULL,
-   `params` varchar(255) NOT NULL,
-   PRIMARY KEY (`rule_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.11 sec)

So what to do now,

Actually I got the db. define_table() script by running the 
extract_mysql_models.py script.  

On Friday, 28 December 2012 12:19:22 UTC+5:30, rochacbruno wrote:



 On Fri, Dec 28, 2012 at 4:46 AM, ajith c t ajith...@gmail.comjavascript:
  wrote:

 condition


 condition is a MySQL reserved keyword, you can't use this as the name of 
 table or field

 http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

 To solve this kinf od problems.

 db = DAL(mysql, check_reserved=[all])


-- 





[web2py] web2py with riak

2012-10-15 Thread ajith c t
Hi I would like to know if there is any possible way to use riak database 
with the web2py framework. Should I write the riak commands in the files in 
the view folder or can I create a DAL query similar to the db= DAL(  )

-- 





[web2py] Re: web2py with riak

2012-10-15 Thread ajith c t
Thank you for your fast response. I am developing an application having its 
frontend written in web2py and the database using the riak since my project 
will be handling huge volumes of data. Hope my work will be made easier if 
at all an adapter and commands similar to the mysql or mongodb adapters are 
made.

On Monday, 15 October 2012 19:42:20 UTC+5:30, Massimo Di Pierro wrote:

 We do not have a dal adapter but you can use the python-riak APIs: 
 https://github.com/basho/riak-python-client

 If there is demand to it we could write an adapter.

 On Monday, 15 October 2012 04:15:00 UTC-5, ajith c t wrote:

 Hi I would like to know if there is any possible way to use riak database 
 with the web2py framework. Should I write the riak commands in the files in 
 the view folder or can I create a DAL query similar to the db= DAL(  )



-- 





[web2py] Re: web2py with riak

2012-10-15 Thread ajith c t
One more thing, since web2py uses the db variable in most of the 
authentication or even in the menu builder code, and many more cases, what 
should I do in these situations. I think there wont be any connection 
string for the riak-python client when creating a new application. If 
possible can you please explain where to add the riak connection queries 
(creating a client and all) or suggest any tutorials using web2py and riak. 

On Tuesday, 16 October 2012 02:17:14 UTC+5:30, ajith c t wrote:

 Thank you for your fast response. I am developing an application having 
 its frontend written in web2py and the database using the riak since my 
 project will be handling huge volumes of data. Hope my work will be made 
 easier if at all an adapter and commands similar to the mysql or mongodb 
 adapters are made.

 On Monday, 15 October 2012 19:42:20 UTC+5:30, Massimo Di Pierro wrote:

 We do not have a dal adapter but you can use the python-riak APIs: 
 https://github.com/basho/riak-python-client

 If there is demand to it we could write an adapter.

 On Monday, 15 October 2012 04:15:00 UTC-5, ajith c t wrote:

 Hi I would like to know if there is any possible way to use riak 
 database with the web2py framework. Should I write the riak commands in the 
 files in the view folder or can I create a DAL query similar to the db= 
 DAL(  )



--