[web2py] register recepatcha not working

2011-09-17 Thread Avik Basu
I am using recaptcha using the following code (public and private keys not 
shown):

auth.settings.register_captcha = Recaptcha(request, '', 
'yy', use_ssl=False, error_message='please complete the reCaptcha')

I've registered with recaptcha.net and I not running this from a localhost. 
 Also, the above line is called after auth is instantiated.  The rest of the 
registration page looks right, but the recaptcha box does not show up.  Any 
ideas?

Thanks,
Avik


[web2py] logging cannot create a log file when run from web2py

2010-10-27 Thread Avik Basu
Hi,

I would like a web2py script to create a log file, but when run via
the python web2py.py ... command line, the log file (in this case
logging.log) is not being created.  Is this a permissions issue with
file creation?

Here is what I what I am doing:

#in cron/log.py
import logging
logging.basicConfig(filename='logging.log',level=logging.INFO)
logging.info('test')

#command used to run the above file
python web2py.py -M -N -S test -R applications/test/cron/log.py 

Thanks.

Avik Basu


[web2py] Re: expose URL to internal web2py functions

2010-09-21 Thread Avik Basu
I was wondering if it might be possible to limit the URL to functions
that are called internally from web2py component calls.  In the
manual, there is a reference to using a decorator like:

@auth.requires(request.cid)

Would this be an effective safeguard?  Also, is there some way to set
this since it only seems to work when LOAD is called and I would like
to set it when some code in the model is executed.

Avik

On Sep 21, 12:10 am, mdipierro mdipie...@cs.depaul.edu wrote:
 If the URL is exposed and it is accessible via ajax, than it is called
 by the remote browser.
 You can only limit access with @auth.requires_login() or other auth
 recorator.

 On Sep 20, 6:48 pm, Avik Basu avikb...@gmail.com wrote:



  I have a generic function called edit_db which allows for editing of
  database records and is useful for ajax-related form functions such as
  edit-in-place.  The URL that is exposed is something like

  edit_db/tablename/row_id/fieldname?value=newvalue

  I would like to make sure that this function can only be accessed by
  functions within my web2py applications--in particular, widgets which
  are defined in the model.  What is the best way to do this?

  Avik


[web2py] expose URL to internal web2py functions

2010-09-20 Thread Avik Basu
I have a generic function called edit_db which allows for editing of
database records and is useful for ajax-related form functions such as
edit-in-place.  The URL that is exposed is something like

edit_db/tablename/row_id/fieldname?value=newvalue

I would like to make sure that this function can only be accessed by
functions within my web2py applications--in particular, widgets which
are defined in the model.  What is the best way to do this?

Avik


[web2py] Re: URL error in appadmin

2010-09-18 Thread Avik Basu
There is nowhere I can see that I am altering request in the models.
What is the specific reason that request would break the URL
function?  Any other ideas what the problem could be?

Avik

On Sep 17, 7:57 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 17, 2010, at 4:44 PM, Avik Basu wrote:



  Yes, I'm sure I'm running 1.85.2.  i copied over appadmin.py and the
  associated views to my applications.  What is strange though is that I
  can run the welcome app without any problem (http://127.0.0.1:8000/
  welcome/appadmin/index), but not the version I copied into my
  application (http://127.0.0.1:8000/FWv9_1_Avik/appadmin/index).  Is
  there some other file I need to copy?

 I'm not seeing anything.

 Is it possible that you're altering request in your model(s)?





  Avik

  On Sep 17, 7:24 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 17, 2010, at 4:06 PM, Avik Basu wrote:

  Hi,

  I get the following error in appadmin.py which I copied over from the
  welcome app in version 1.85.2:

  Are you running 1.85.2? It sounds like you might be running something 
  earlier.

  Traceback (most recent call last):
   File /Volumes/Data/avikbasu/web2py/gluon/restricted.py, line 188,
  in restricted
     exec ccode in environment
   File /Volumes/Data/avikbasu/web2py/applications/FWv9_1_Avik/
  controllers/appadmin.py, line 40, in module
     URL('index')], [T('state'), False,
   File /Volumes/Data/avikbasu/web2py/gluon/html.py, line 188, in URL
     raise SyntaxError, 'not enough information to build the url'
  SyntaxError: not enough information to build the url

  Any ideas?

  Thanks,
  Avik


[web2py] Re: URL error in appadmin

2010-09-18 Thread Avik Basu
Sure, I'm happy to help debug.  Send me the print statements when you
get a chance.
Avik

On Sep 18, 12:39 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 17, 2010, at 11:50 PM, Avik Basu wrote:



  There is nowhere I can see that I am altering request in the models.
  What is the specific reason that request would break the URL
  function?  Any other ideas what the problem could be?

 The URL function requires, at a minimum, app, controller and function names. 
 In a call like the one that's blowing out, that supplies only a function 
 name, the app  controller names come from request, which URL knows about 
 magically.

 I'm at a loss here; I was hoping Massimo might have an idea.

 If you're willing, I can give you a debug print or two to stick in there, and 
 at least we can see what's missing, exactly.





  Avik

  On Sep 17, 7:57 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 17, 2010, at 4:44 PM, Avik Basu wrote:

  Yes, I'm sure I'm running 1.85.2.  i copied over appadmin.py and the
  associated views to my applications.  What is strange though is that I
  can run the welcome app without any problem (http://127.0.0.1:8000/
  welcome/appadmin/index), but not the version I copied into my
  application (http://127.0.0.1:8000/FWv9_1_Avik/appadmin/index).  Is
  there some other file I need to copy?

  I'm not seeing anything.

  Is it possible that you're altering request in your model(s)?

  Avik

  On Sep 17, 7:24 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 17, 2010, at 4:06 PM, Avik Basu wrote:

  Hi,

  I get the following error in appadmin.py which I copied over from the
  welcome app in version 1.85.2:

  Are you running 1.85.2? It sounds like you might be running something 
  earlier.

  Traceback (most recent call last):
   File /Volumes/Data/avikbasu/web2py/gluon/restricted.py, line 188,
  in restricted
     exec ccode in environment
   File /Volumes/Data/avikbasu/web2py/applications/FWv9_1_Avik/
  controllers/appadmin.py, line 40, in module
     URL('index')], [T('state'), False,
   File /Volumes/Data/avikbasu/web2py/gluon/html.py, line 188, in URL
     raise SyntaxError, 'not enough information to build the url'
  SyntaxError: not enough information to build the url

  Any ideas?

  Thanks,
  Avik


[web2py] Re: URL error in appadmin

2010-09-18 Thread Avik Basu
When I replace the code in gluon/html.py, I still keep getting the
same SyntaxError ('not enough information to build the url') which
seems strange since that is not even in the code anymore.

I am sort of new to debugging the gluon code so I maybe making some
simple mistake.   I did delete the html.pyc file. Do I need to restart
the server?

On Sep 18, 2:31 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 18, 2010, at 9:46 AM, Avik Basu wrote:



  Sure, I'm happy to help debug.  Send me the print statements when you
  get a chance.

 FWIW, I just did the same thing (move the current appadmin into my own app) 
 and it seems to work OK; at least I can access appadmin/index OK.


[web2py] Re: URL error in appadmin

2010-09-18 Thread Avik Basu
After restarting the server, I get the following error:

SyntaxError: URL: a=index c=None f=None r=None

On Sep 18, 2:46 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 18, 2010, at 11:40 AM, Avik Basu wrote:



  When I replace the code in gluon/html.py, I still keep getting the
  same SyntaxError ('not enough information to build the url') which
  seems strange since that is not even in the code anymore.

  I am sort of new to debugging the gluon code so I maybe making some
  simple mistake.   I did delete the html.pyc file. Do I need to restart
  the server?

 I would assume so, given the message, and especially if you're not seeing 
 html.pyc getting recreated.





  On Sep 18, 2:31 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 9:46 AM, Avik Basu wrote:

  Sure, I'm happy to help debug.  Send me the print statements when you
  get a chance.

  FWIW, I just did the same thing (move the current appadmin into my own 
  app) and it seems to work OK; at least I can access appadmin/index OK.


[web2py] Re: URL error in appadmin

2010-09-18 Thread Avik Basu
Line 219 of gluon/compileapp.py is as you described it. I also deleted
the whole gluon directory and downloaded the latest source of web2py
before restarting the server.  Also, as far as I can tell, I am not
doing anything tricky with Globals or the URL symbol in my models.

I now get the following syntax error:

SyntaxError: URL: a=index c=None f=None r=None u=URL




On Sep 18, 3:33 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 18, 2010, at 11:52 AM, Avik Basu wrote:



  After restarting the server, I get the following error:

  SyntaxError: URL: a=index c=None f=None r=None

 I was afraid of that, and I can't explain it.

 Please check that line 219 of gluon/compileapp.py is:

     environment['URL'] = html._gURL(request)

 And you might want to quit your server, delete all the .pyc files in gluon, 
 and restart.

 Do you do anything tricky with globals() or the URL symbol in your models?

 And let's try one more printing attempt:

    if not (application and controller and function):
        if r:
            msg = 'URL: a=%s c=%s f=%s r.a=%s r.c=%s r.f=%s' % 
 (application,controller,function,r.application,r.controller,r.function)
        else:
            msg = 'URL: a=%s c=%s f=%s r=%s u=%s' % 
 (application,controller,function,r,URL.__name__)
        raise SyntaxError, msg





  On Sep 18, 2:46 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 11:40 AM, Avik Basu wrote:

  When I replace the code in gluon/html.py, I still keep getting the
  same SyntaxError ('not enough information to build the url') which
  seems strange since that is not even in the code anymore.

  I am sort of new to debugging the gluon code so I maybe making some
  simple mistake.   I did delete the html.pyc file. Do I need to restart
  the server?

  I would assume so, given the message, and especially if you're not seeing 
  html.pyc getting recreated.

  On Sep 18, 2:31 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 9:46 AM, Avik Basu wrote:

  Sure, I'm happy to help debug.  Send me the print statements when you
  get a chance.

  FWIW, I just did the same thing (move the current appadmin into my own 
  app) and it seems to work OK; at least I can access appadmin/index OK.


[web2py] Re: URL error in appadmin

2010-09-18 Thread Avik Basu
do i need to import logging?

On Sep 18, 4:10 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 18, 2010, at 12:52 PM, Avik Basu wrote:



  Line 219 of gluon/compileapp.py is as you described it. I also deleted
  the whole gluon directory and downloaded the latest source of web2py
  before restarting the server.  Also, as far as I can tell, I am not
  doing anything tricky with Globals or the URL symbol in my models.

  I now get the following syntax error:

  SyntaxError: URL: a=index c=None f=None r=None u=URL

 Thanks.

 I realized after I sent that last request that the __name__ of URL might not 
 be significant at this point, because we're inside the URL() function.

 This might be worth a try. In appadmin.py, near the beginning (after the 
 imports, but before response.menu is set):

 logger = logging.getLogger('web2py')
 logger.warning('appadmin url.name=%s' % URL.__name__)

 What you *should* see is _URL. That's what I see if I stick it in my own 
 appadmin.





  On Sep 18, 3:33 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 11:52 AM, Avik Basu wrote:

  After restarting the server, I get the following error:

  SyntaxError: URL: a=index c=None f=None r=None

  I was afraid of that, and I can't explain it.

  Please check that line 219 of gluon/compileapp.py is:

      environment['URL'] = html._gURL(request)

  And you might want to quit your server, delete all the .pyc files in 
  gluon, and restart.

  Do you do anything tricky with globals() or the URL symbol in your models?

  And let's try one more printing attempt:

     if not (application and controller and function):
         if r:
             msg = 'URL: a=%s c=%s f=%s r.a=%s r.c=%s r.f=%s' % 
  (application,controller,function,r.application,r.controller,r.function)
         else:
             msg = 'URL: a=%s c=%s f=%s r=%s u=%s' % 
  (application,controller,function,r,URL.__name__)
         raise SyntaxError, msg

  On Sep 18, 2:46 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 11:40 AM, Avik Basu wrote:

  When I replace the code in gluon/html.py, I still keep getting the
  same SyntaxError ('not enough information to build the url') which
  seems strange since that is not even in the code anymore.

  I am sort of new to debugging the gluon code so I maybe making some
  simple mistake.   I did delete the html.pyc file. Do I need to restart
  the server?

  I would assume so, given the message, and especially if you're not 
  seeing html.pyc getting recreated.

  On Sep 18, 2:31 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 9:46 AM, Avik Basu wrote:

  Sure, I'm happy to help debug.  Send me the print statements when you
  get a chance.

  FWIW, I just did the same thing (move the current appadmin into my own 
  app) and it seems to work OK; at least I can access appadmin/index OK.


[web2py] Re: URL error in appadmin

2010-09-18 Thread Avik Basu
I put this:
{{=URL.__name__}}

in the view of my index page and it showed
URL

(not _URL as you said)


Also, I don't know if its helpful to mention that the latest format
for the URL function is not working anywhere in my app, not just in
appadmin.  So, if I put:

{{=URL('index')}}

in my index page, I get the same syntax error that I had in appadmin.

On Sep 18, 4:10 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 18, 2010, at 12:52 PM, Avik Basu wrote:



  Line 219 of gluon/compileapp.py is as you described it. I also deleted
  the whole gluon directory and downloaded the latest source of web2py
  before restarting the server.  Also, as far as I can tell, I am not
  doing anything tricky with Globals or the URL symbol in my models.

  I now get the following syntax error:

  SyntaxError: URL: a=index c=None f=None r=None u=URL

 Thanks.

 I realized after I sent that last request that the __name__ of URL might not 
 be significant at this point, because we're inside the URL() function.

 This might be worth a try. In appadmin.py, near the beginning (after the 
 imports, but before response.menu is set):

 logger = logging.getLogger('web2py')
 logger.warning('appadmin url.name=%s' % URL.__name__)

 What you *should* see is _URL. That's what I see if I stick it in my own 
 appadmin.





  On Sep 18, 3:33 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 11:52 AM, Avik Basu wrote:

  After restarting the server, I get the following error:

  SyntaxError: URL: a=index c=None f=None r=None

  I was afraid of that, and I can't explain it.

  Please check that line 219 of gluon/compileapp.py is:

      environment['URL'] = html._gURL(request)

  And you might want to quit your server, delete all the .pyc files in 
  gluon, and restart.

  Do you do anything tricky with globals() or the URL symbol in your models?

  And let's try one more printing attempt:

     if not (application and controller and function):
         if r:
             msg = 'URL: a=%s c=%s f=%s r.a=%s r.c=%s r.f=%s' % 
  (application,controller,function,r.application,r.controller,r.function)
         else:
             msg = 'URL: a=%s c=%s f=%s r=%s u=%s' % 
  (application,controller,function,r,URL.__name__)
         raise SyntaxError, msg

  On Sep 18, 2:46 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 11:40 AM, Avik Basu wrote:

  When I replace the code in gluon/html.py, I still keep getting the
  same SyntaxError ('not enough information to build the url') which
  seems strange since that is not even in the code anymore.

  I am sort of new to debugging the gluon code so I maybe making some
  simple mistake.   I did delete the html.pyc file. Do I need to restart
  the server?

  I would assume so, given the message, and especially if you're not 
  seeing html.pyc getting recreated.

  On Sep 18, 2:31 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 9:46 AM, Avik Basu wrote:

  Sure, I'm happy to help debug.  Send me the print statements when you
  get a chance.

  FWIW, I just did the same thing (move the current appadmin into my own 
  app) and it seems to work OK; at least I can access appadmin/index OK.


[web2py] Re: URL error in appadmin

2010-09-18 Thread Avik Basu
I tried the following command in both my app (where URL) and the
welcome app (where URL does not fail):

{{=gluon.html._gURL(request).__name__}}

and the result for both apps was:

_URL

Does that provide any clues?

On Sep 18, 5:03 pm, Jonathan Lundell jlund...@pobox.com wrote:
 Massimo, any ideas?

 On Sep 18, 2010, at 1:24 PM, Avik Basu wrote:







  I put this:
  {{=URL.__name__}}

  in the view of my index page and it showed
  URL

  (not _URL as you said)

  Also, I don't know if its helpful to mention that the latest format
  for the URL function is not working anywhere in my app, not just in
  appadmin.  So, if I put:

  {{=URL('index')}}

  in my index page, I get the same syntax error that I had in appadmin.

 That's good to know.

 You could try this (you'll need to import gluon.html):

 {{=gluon.html._gURL(request).__name__}}

 That's what the global URL should be.

 I think you were saying that this works OK in the other apps, right? You 
 could stick similar logic into welcome, for comparison purposes, good vs bad. 
 You might have to delete the welcome/compiled directory.

 By way of background, the URL logic was updated not all that long ago. Have a 
 look at html._gURL, and then compileapp.build_environment() to see how it's 
 being used. URL is being replaced by the closure (I think it's a closure) 
 _gURL(request), so the value of request gets bound to the URL call, without 
 having to supply it all the time.

 Also, a single argument to the original URL is treated as the application, 
 whereas the closure treats it as the function. We see the former in the 
 syntax error print below, more evidence that we're not invoking the closure.





  On Sep 18, 4:10 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 12:52 PM, Avik Basu wrote:

  Line 219 of gluon/compileapp.py is as you described it. I also deleted
  the whole gluon directory and downloaded the latest source of web2py
  before restarting the server.  Also, as far as I can tell, I am not
  doing anything tricky with Globals or the URL symbol in my models.

  I now get the following syntax error:

  SyntaxError: URL: a=index c=None f=None r=None u=URL

  Thanks.

  I realized after I sent that last request that the __name__ of URL might 
  not be significant at this point, because we're inside the URL() function.

  This might be worth a try. In appadmin.py, near the beginning (after the 
  imports, but before response.menu is set):

  logger = logging.getLogger('web2py')
  logger.warning('appadmin url.name=%s' % URL.__name__)

  What you *should* see is _URL. That's what I see if I stick it in my own 
  appadmin.

  On Sep 18, 3:33 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 11:52 AM, Avik Basu wrote:

  After restarting the server, I get the following error:

  SyntaxError: URL: a=index c=None f=None r=None

  I was afraid of that, and I can't explain it.

  Please check that line 219 of gluon/compileapp.py is:

      environment['URL'] = html._gURL(request)

  And you might want to quit your server, delete all the .pyc files in 
  gluon, and restart.

  Do you do anything tricky with globals() or the URL symbol in your 
  models?

  And let's try one more printing attempt:

     if not (application and controller and function):
         if r:
             msg = 'URL: a=%s c=%s f=%s r.a=%s r.c=%s r.f=%s' % 
  (application,controller,function,r.application,r.controller,r.function)
         else:
             msg = 'URL: a=%s c=%s f=%s r=%s u=%s' % 
  (application,controller,function,r,URL.__name__)
         raise SyntaxError, msg

  On Sep 18, 2:46 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 11:40 AM, Avik Basu wrote:

  When I replace the code in gluon/html.py, I still keep getting the
  same SyntaxError ('not enough information to build the url') which
  seems strange since that is not even in the code anymore.

  I am sort of new to debugging the gluon code so I maybe making some
  simple mistake.   I did delete the html.pyc file. Do I need to restart
  the server?

  I would assume so, given the message, and especially if you're not 
  seeing html.pyc getting recreated.

  On Sep 18, 2:31 pm, Jonathan Lundell jlund...@pobox.com wrote:
  On Sep 18, 2010, at 9:46 AM, Avik Basu wrote:

  Sure, I'm happy to help debug.  Send me the print statements when 
  you
  get a chance.

  FWIW, I just did the same thing (move the current appadmin into my 
  own app) and it seems to work OK; at least I can access 
  appadmin/index OK.


[web2py] Re: URL error in appadmin

2010-09-18 Thread Avik Basu
I tried your suggestion and tracked the error to the following line
which was in my db.py:

from gluon.sqlhtml import *

I guess this import overrided the URL function.  When I took it out,
everything works.  Thanks so much for your patience and helping me get
through this issue so methodically!  The web2py community is quite
exceptional.

Avik



On Sep 18, 7:07 pm, Jonathan Lundell jlund...@pobox.com wrote:
 I should also mention that if I were able to reproduce the problem here, I'd 
 look at it with a debugger, watching URL in the global namespace of a 
 request. So if that's a possibility


[web2py] URL error in appadmin

2010-09-17 Thread Avik Basu
Hi,

I get the following error in appadmin.py which I copied over from the
welcome app in version 1.85.2:

Traceback (most recent call last):
  File /Volumes/Data/avikbasu/web2py/gluon/restricted.py, line 188,
in restricted
exec ccode in environment
  File /Volumes/Data/avikbasu/web2py/applications/FWv9_1_Avik/
controllers/appadmin.py, line 40, in module
URL('index')], [T('state'), False,
  File /Volumes/Data/avikbasu/web2py/gluon/html.py, line 188, in URL
raise SyntaxError, 'not enough information to build the url'
SyntaxError: not enough information to build the url

Any ideas?

Thanks,
Avik


[web2py] Re: URL error in appadmin

2010-09-17 Thread Avik Basu
Yes, I'm sure I'm running 1.85.2.  i copied over appadmin.py and the
associated views to my applications.  What is strange though is that I
can run the welcome app without any problem (http://127.0.0.1:8000/
welcome/appadmin/index), but not the version I copied into my
application (http://127.0.0.1:8000/FWv9_1_Avik/appadmin/index).  Is
there some other file I need to copy?

Avik

On Sep 17, 7:24 pm, Jonathan Lundell jlund...@pobox.com wrote:
 On Sep 17, 2010, at 4:06 PM, Avik Basu wrote:



  Hi,

  I get the following error in appadmin.py which I copied over from the
  welcome app in version 1.85.2:

 Are you running 1.85.2? It sounds like you might be running something earlier.





  Traceback (most recent call last):
   File /Volumes/Data/avikbasu/web2py/gluon/restricted.py, line 188,
  in restricted
     exec ccode in environment
   File /Volumes/Data/avikbasu/web2py/applications/FWv9_1_Avik/
  controllers/appadmin.py, line 40, in module
     URL('index')], [T('state'), False,
   File /Volumes/Data/avikbasu/web2py/gluon/html.py, line 188, in URL
     raise SyntaxError, 'not enough information to build the url'
  SyntaxError: not enough information to build the url

  Any ideas?

  Thanks,
  Avik


[web2py] prevent redirect when using crud.delete

2010-09-14 Thread Avik Basu
Hello,

Is there a way to prevent crud.delete from redirecting to a new page.
The reason I want to do this is that I am calling crud.delete via
web2py's LOAD function?  I am trying this:

form = crud.delete(db.ate,ate_id, next='')

I notice in the code that crud.update explicitly checks for an empty
next variable while crud.delete does not.

Avik


[web2py] StorageList error on Dreamhost installation

2010-09-14 Thread Avik Basu
Hi,

I get the following error when loading web2py version 1.84.4 on
Dreamhost:

Traceback (most recent call last):\n  File gluon/restricted.py, line
178, in restricted
in code it raises a RestrictedError containing the traceback. layer is
\n  File /home/pwoolf/foodwiki.com/applications/init/models/db.py,
line 20, in module
from gluon.tools import *
File gluon/tools.py, line 11, in module
from storage import Storage, StorageList, Settings, Messages
\nImportError: cannot import name StorageList

Is there a missing library I need to install?

Avik


[web2py] Re: StorageList error on Dreamhost installation [SOLVED]

2010-09-14 Thread Avik Basu
I restarted the server and the issue was resolved.  Sorry for the
bother.
Avik

On Sep 14, 6:24 pm, Avik Basu avikb...@gmail.com wrote:
 Hi,

 I get the following error when loading web2py version 1.84.4 on
 Dreamhost:

 Traceback (most recent call last):\n  File gluon/restricted.py, line
 178, in restricted
 in code it raises a RestrictedError containing the traceback. layer is
 \n  File /home/pwoolf/foodwiki.com/applications/init/models/db.py,
 line 20, in module
 from gluon.tools import *
 File gluon/tools.py, line 11, in module
 from storage import Storage, StorageList, Settings, Messages
 \nImportError: cannot import name StorageList

 Is there a missing library I need to install?

 Avik


[web2py] MySQL query with empty belongs

2010-07-12 Thread Avik Basu
Hi,

I am trying to run a query with the web2py belongs statement where
sometimes the value passed to the belongs may be empty.  For example,

a=[]
rows = db(db.food.id.belongs(a)).select()

The database I'm using is MySQL and I get the following error:

Traceback (most recent call last):
  File input, line 1, in module
  File gluon/sql.py, line 3111, in select
rows = response(query)
  File gluon/sql.py, line 3106, in response
db._execute(query)
  File gluon/sql.py, line 932, in lambda
self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
  File build/bdist.linux-x86_64/egg/MySQLdb/cursors.py, line 173, in
execute
self.errorhandler(self, exc, value)
  File build/bdist.linux-x86_64/egg/MySQLdb/connections.py, line 36,
in defaulterrorhandler
raise errorclass, errorvalue
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 ')' at line 1)

Any ideas?

Avik


[web2py] synchronize tables in two databases

2010-06-28 Thread Avik Basu
Hi,

I'm trying to synchronize two databases that are similar but not
exactly the same.  I would like to create two connections (db1 and
db2) and go through table by table to do the synchronization.

db1 = DAL('sqlite://storage.db')
db2 = DAL('mysql://username:passw...@mysql.test.com/test_db',
pool_size=10, check_reserved=['mysql'], migrate=False,
fake_migrate=False)

db1 is defined in db.py while db2 is a mysql database (created via
web2py) that already exists and has data in it.  i'm trying to update
the data in db2 with the data in db1.  What is a good way to deal with
this problem?

Avik


[web2py] An error occurred importing your passenger_wsgi.py

2010-05-31 Thread Avik Basu
I am running on web2py 1.78.3 on a shared server on Dreamhost and I am
getting the following error:

An error occurred importing your passenger_wsgi.py

It seems like a PATH issue but I'm not sure.  Any ideas what might be
causing this?

Avik


[web2py] Re: MySQL failure to connect [SOLVED]

2010-05-19 Thread Avik Basu
Turns out I was not running from source.  Thanks for your help!
Avik

On May 19, 7:53 am, Alexandre Andrade alexandrema...@gmail.com
wrote:
 the correct driver is not python-mysql, but mysqldb.

 2010/5/18 Avik Basu avikb...@gmail.com





  Hello,

  I am having some trouble connecting to a MySQL server running on my
  local machine (Macbook Pro running Snow Leopard with My SQL 5.1.46).
  I use the following connection string:

  db = DAL('mysql://root:passw...@localhost/test', pool_size=10)

  and I get the following error:

  Traceback (most recent call last):
   File gluon/restricted.py, line 178, in restricted
   File /Applications/web2py.app/Contents/Resources/applications/
  FWv7_12/models/db.py, line 9, in module
   File gluon/sql.py, line 3840, in DAL
  RuntimeError: Failure to connect to DB. Tried 5 times

  I do have the python-mysql driver properly installed. Also, I am able
  to connect to the database named 'test' both from the shell and using
  a third party MySQL app (Sequel Pro).  There are no existing tables in
  the 'test' database to begin with. Any ideas why the connection may be
  failing?

  Avik

 --
 Atenciosamente

 --
 =
 Alexandre Andrade
 Hipercenter.com


[web2py] MySQL failure to connect

2010-05-18 Thread Avik Basu
Hello,

I am having some trouble connecting to a MySQL server running on my
local machine (Macbook Pro running Snow Leopard with My SQL 5.1.46).
I use the following connection string:

db = DAL('mysql://root:passw...@localhost/test', pool_size=10)

and I get the following error:

Traceback (most recent call last):
  File gluon/restricted.py, line 178, in restricted
  File /Applications/web2py.app/Contents/Resources/applications/
FWv7_12/models/db.py, line 9, in module
  File gluon/sql.py, line 3840, in DAL
RuntimeError: Failure to connect to DB. Tried 5 times

I do have the python-mysql driver properly installed. Also, I am able
to connect to the database named 'test' both from the shell and using
a third party MySQL app (Sequel Pro).  There are no existing tables in
the 'test' database to begin with. Any ideas why the connection may be
failing?

Avik


[web2py] Re: cache.disk.clear

2010-05-04 Thread Avik Basu
It seems to work fine from the interactive shell.  And after I ran
that command from the interactive shell, I think that I no longer have
the invalid function when calling the action.  So, perhaps it was a
problem with items that were accumulating in the cache.  I'll report
back if it breaks again.
Avik

On May 3, 10:30 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Can you try it from the shell?

 python web2py.py -S welcome

  cache.disk.clear()

 On May 3, 9:29 pm, mdipierro mdipie...@cs.depaul.edu wrote:



  can you show the complete traceback? Do you have the latest web2py?
  This seems to work for me.

  On May 3, 6:25 pm, Avik Basu avikb...@gmail.com wrote:

   Hi,

   I have installed a site on dreamhost and whenever I issue the command
   cache.disk.clear in an action, I get an invalid function error.

   I thought this could be a permissions problem for the cache directory
   or cache.shelve, so I added read/write permissions for everyone, but
   it didn't seem to work.

   Aache.ram.clear seems to work just fine.  Any ideas?

   Avik


[web2py] cache.disk.clear

2010-05-03 Thread Avik Basu
Hi,

I have installed a site on dreamhost and whenever I issue the command
cache.disk.clear in an action, I get an invalid function error.

I thought this could be a permissions problem for the cache directory
or cache.shelve, so I added read/write permissions for everyone, but
it didn't seem to work.

Aache.ram.clear seems to work just fine.  Any ideas?

Avik


[web2py] restart web2py command line

2010-04-29 Thread Avik Basu
Hi,
Is there a way to restart web2py from the command line in a linux
environment?
Avik


[web2py] Re: LOAD and reload

2010-04-09 Thread Avik Basu
Say I have a form in component A and a records display in component
B.  Both are loaded on a single page. How can I update the records
display when the form (SQLFORM) accepts?


On Apr 9, 6:19 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 Instead of
 {{=LOAD('default','show_foods',ajax=True)}}

 do
 div id=mystuffimg src=...the loading indicator...//div
 scriptweb2py_component('{{=URL(r=request,c='default',f='show_foods')}}',' 
 mystuff')/
 script

 You can also have

 button
 onclick=web2py_component('{{=URL(r=request,c='default',f='show_foods')}}', 
 'mystuff')click
 me to reload/script

 On Apr 9, 5:07 pm, Avik Basu avikb...@gmail.com wrote:



  Hi,

  Is there a way to reload a component that has been loaded with the
  LOAD function without sending a request back to the server?

  For example, I would like to reload a list of foods whenever the data
  has been altered by the user, but I would like only the component to
  reload instead of the whole page.

  #in view
  {{=LOAD('default','show_foods',ajax=True)}}

  Also, is there a way to use a loading indicator icon instead of the
  default 'loading...' message?

  Thanks,
  Avik


-- 
To unsubscribe, reply using remove me as the subject.


[web2py] Re: crud update with represent

2010-04-03 Thread Avik Basu
Thanks, that works great.  I have an additional question:  Is there a
represent argument for in define_table which would allow for a
formatting of an entire row, based on the fields which were selected
in the query of crud.select(...)?

Avik

On Apr 2, 8:36 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 You just need to specify the format. It will make for you both
 validator and represent attribute.

 #model
 db.define_table(food,
     Field(desc, string),
     format='%(desc)s'
 )

 db.define_table(ate,
     Field(food_id, db.food)
 )

 #controller
 form=crud.update(db.ate,ate_id)

 On Apr 1, 2:22 pm, Avik Basu avikb...@gmail.com wrote:



  Hi,
  As I understand, when crud.update(...) creates a form it pulls the
  values of a given record into the form as a string.  If the field is a
  reference to another table, then this shows up as a number.  I would
  like to instead show the name of the record instead of the id. I have
  a represent function set in the data model, but that is only used on
  crud.select().

  So, my question is how can I get the crud.update(...) form to render
  the record values with according to the represent function specified
  by the represent function of the field.  Code below:

  #model
  db.define_table(food,
      Field(desc, string,)
  )

  db.define_table(ate,
      Field(food_id, db.food,
          represent=lambda x: db(db.food.id==x).select().first().desc
      )
  )

  #controller
  form=crud.update(db.ate,ate_id)

  Thanks,
  Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] crud update with represent

2010-04-01 Thread Avik Basu
Hi,
As I understand, when crud.update(...) creates a form it pulls the
values of a given record into the form as a string.  If the field is a
reference to another table, then this shows up as a number.  I would
like to instead show the name of the record instead of the id. I have
a represent function set in the data model, but that is only used on
crud.select().

So, my question is how can I get the crud.update(...) form to render
the record values with according to the represent function specified
by the represent function of the field.  Code below:

#model
db.define_table(food,
Field(desc, string,)
)

db.define_table(ate,
Field(food_id, db.food,
represent=lambda x: db(db.food.id==x).select().first().desc
)
)

#controller
form=crud.update(db.ate,ate_id)

Thanks,
Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] datetime and represent

2010-03-28 Thread Avik Basu
I would like to use the represent function on a datetime object, like
so:

from datetime import *

db.define_table(adate,
  Field(date,datetime,
 represent = lambda x: x.strftime(%a %m-%d-%y) if x else 'No
time'  #convert datetime object to string
  )
)

This works when I create a form, however when i use appadmin it gives
the following error:

Traceback (most recent call last):
  File gluon/restricted.py, line 173, in restricted
  File /Applications/web2py.app/Contents/Resources/applications/
FWv7_7/views/appadmin.html, line 196, in module
  File gluon/sqlhtml.py, line 1103, in __init__
  File gluon/sql.py, line 2676, in formatter
  File gluon/validators.py, line 2006, in formatter
AttributeError: 'str' object has no attribute 'strftime'

Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: datetime and represent

2010-03-28 Thread Avik Basu
I dropped all the records in the table and still get the same result.
I replaced the previous represent with:

represent = lambda x: type(x)

which shows that the records are in fact of type datetime as opposed
to string.  could the issue be in the rendering of tables in appadmin?

Avik

On Mar 28, 6:02 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 It is possible you chaged the type of this field from 'string' to
 'datetime' and because sqlite does not support migrations, you may
 have still string data in the datetime field. I suggest you delete
 those records that contain corrupted data.

 Massimo

 On Mar 28, 4:54 pm, Avik Basu avikb...@gmail.com wrote:



  I would like to use the represent function on a datetime object, like
  so:

  from datetime import *

  db.define_table(adate,
    Field(date,datetime,
       represent = lambda x: x.strftime(%a %m-%d-%y) if x else 'No
  time'  #convert datetime object to string
    )
  )

  This works when I create a form, however when i use appadmin it gives
  the following error:

  Traceback (most recent call last):
    File gluon/restricted.py, line 173, in restricted
    File /Applications/web2py.app/Contents/Resources/applications/
  FWv7_7/views/appadmin.html, line 196, in module
    File gluon/sqlhtml.py, line 1103, in __init__
    File gluon/sql.py, line 2676, in formatter
    File gluon/validators.py, line 2006, in formatter
  AttributeError: 'str' object has no attribute 'strftime'

  Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: datetime and represent

2010-03-28 Thread Avik Basu
I'm still way back on 1.75.4, but can't upgrade because my IP seems to
be blocked from accessing web2py.com.
Avik

On Mar 28, 7:32 pm, mdipierro mdipie...@cs.depaul.edu wrote:
 I see. I think what you are seeing is due to a bug. I have fixed this
 bug but I do not recall if it is fixed in only in trunk or also in
 1.76.5. Which web2py version do you use?

 Massimo

 On Mar 28, 6:18 pm, Avik Basu avikb...@gmail.com wrote:



  I dropped all the records in the table and still get the same result.
  I replaced the previous represent with:

  represent = lambda x: type(x)

  which shows that the records are in fact of type datetime as opposed
  to string.  could the issue be in the rendering of tables in appadmin?

  Avik

  On Mar 28, 6:02 pm, mdipierro mdipie...@cs.depaul.edu wrote:

   It is possible you chaged the type of this field from 'string' to
   'datetime' and because sqlite does not support migrations, you may
   have still string data in the datetime field. I suggest you delete
   those records that contain corrupted data.

   Massimo

   On Mar 28, 4:54 pm, Avik Basu avikb...@gmail.com wrote:

I would like to use the represent function on a datetime object, like
so:

from datetime import *

db.define_table(adate,
  Field(date,datetime,
     represent = lambda x: x.strftime(%a %m-%d-%y) if x else 'No
time'  #convert datetime object to string
  )
)

This works when I create a form, however when i use appadmin it gives
the following error:

Traceback (most recent call last):
  File gluon/restricted.py, line 173, in restricted
  File /Applications/web2py.app/Contents/Resources/applications/
FWv7_7/views/appadmin.html, line 196, in module
  File gluon/sqlhtml.py, line 1103, in __init__
  File gluon/sql.py, line 2676, in formatter
  File gluon/validators.py, line 2006, in formatter
AttributeError: 'str' object has no attribute 'strftime'

Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Passing values to widgets

2010-03-27 Thread Avik Basu
So, for my example, I tried your suggestion.  I defined a widget in
models/widgets.py:

def units_widget(field,value,food_id):
   ...

and then in the controller, I set the widget with:

db.ate.units.widget = units_widget(food_id)

But here I am not passing field and value so I get an error.  What
would be the proper way to call the widget constructor?

Avik


On Mar 27, 12:02 am, mdipierro mdipie...@cs.depaul.edu wrote:
 in the controller you can do

 db.table.field.widget = SomeWidgetConstructor(args)

 Not sure if this is what you are asking.

 On 26 Mar, 18:26, Avik Basu avikb...@gmail.com wrote:



  Is there a way to pass arguments to a field's widget from the
  controller?  For example:

  db.define_table(food, Field(name, string'))

  db.define_table(units,
     Field(food_id, db.food),
     Field(name, string)
  )

  db.define_table(ate,
     Field(food_id, db.food),
     Field(quantity, double),
     Field(units, string, widget=units_widget),
  )

  In an update form for ate, I would like to create a dropdown box of
  units that are associated with a given food_id.  I realize could not
  be set in the db.py since the food id would be unknown in that scope,
  however the action in the controller would have access to the food id,
  but I would like to be able to pass that somehow to the widget.

  Thanks,
  Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Passing values to widgets

2010-03-27 Thread Avik Basu
I get the following error:

TypeError: __init__() should return None, not 'function'

I think the problem has to do with the following return statement in
the constructor:

return widget


Avik


On Mar 27, 11:57 am, mr.freeze nat...@freezable.com wrote:
 Sorry, the constructor should be:

 def __init__(*args,**kargs):

 On Mar 27, 10:53 am, mr.freeze nat...@freezable.com wrote:



  You need to make your widget a class so you can pass args to it in the
  constructor:

  class Units_Widget(object):
      def __init__(**args):
          def widget(f,v):
             #build your widget
             #using args
          return widget

  db.ate.units.widget = Units_Widget(food_id)

  On Mar 27, 10:42 am, Avik Basu avikb...@gmail.com wrote:

   So, for my example, I tried your suggestion.  I defined a widget in
   models/widgets.py:

   def units_widget(field,value,food_id):
      ...

   and then in the controller, I set the widget with:

   db.ate.units.widget = units_widget(food_id)

   But here I am not passing field and value so I get an error.  What
   would be the proper way to call the widget constructor?

   Avik

   On Mar 27, 12:02 am, mdipierro mdipie...@cs.depaul.edu wrote:

in the controller you can do

db.table.field.widget = SomeWidgetConstructor(args)

Not sure if this is what you are asking.

On 26 Mar, 18:26, Avik Basu avikb...@gmail.com wrote:

 Is there a way to pass arguments to a field's widget from the
 controller?  For example:

 db.define_table(food, Field(name, string'))

 db.define_table(units,
    Field(food_id, db.food),
    Field(name, string)
 )

 db.define_table(ate,
    Field(food_id, db.food),
    Field(quantity, double),
    Field(units, string, widget=units_widget),
 )

 In an update form for ate, I would like to create a dropdown box of
 units that are associated with a given food_id.  I realize could not
 be set in the db.py since the food id would be unknown in that scope,
 however the action in the controller would have access to the food id,
 but I would like to be able to pass that somehow to the widget.

 Thanks,
 Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Passing values to widgets

2010-03-27 Thread Avik Basu
Also, if i wanted to extend SQLFORM.widgets.options.widget, how would
i go about doing that? Is it as simple as replacing:

class Units_Widget(object):

with:

class Units_Widget(SQLFORM.widgets.options.widget):

Thanks,
Avik


On Mar 27, 5:03 pm, Avik Basu avikb...@gmail.com wrote:
 I get the following error:

 TypeError: __init__() should return None, not 'function'

 I think the problem has to do with the following return statement in
 the constructor:

 return widget

 Avik

 On Mar 27, 11:57 am, mr.freeze nat...@freezable.com wrote:



  Sorry, the constructor should be:

  def __init__(*args,**kargs):

  On Mar 27, 10:53 am, mr.freeze nat...@freezable.com wrote:

   You need to make your widget a class so you can pass args to it in the
   constructor:

   class Units_Widget(object):
       def __init__(**args):
           def widget(f,v):
              #build your widget
              #using args
           return widget

   db.ate.units.widget = Units_Widget(food_id)

   On Mar 27, 10:42 am, Avik Basu avikb...@gmail.com wrote:

So, for my example, I tried your suggestion.  I defined a widget in
models/widgets.py:

def units_widget(field,value,food_id):
   ...

and then in the controller, I set the widget with:

db.ate.units.widget = units_widget(food_id)

But here I am not passing field and value so I get an error.  What
would be the proper way to call the widget constructor?

Avik

On Mar 27, 12:02 am, mdipierro mdipie...@cs.depaul.edu wrote:

 in the controller you can do

 db.table.field.widget = SomeWidgetConstructor(args)

 Not sure if this is what you are asking.

 On 26 Mar, 18:26, Avik Basu avikb...@gmail.com wrote:

  Is there a way to pass arguments to a field's widget from the
  controller?  For example:

  db.define_table(food, Field(name, string'))

  db.define_table(units,
     Field(food_id, db.food),
     Field(name, string)
  )

  db.define_table(ate,
     Field(food_id, db.food),
     Field(quantity, double),
     Field(units, string, widget=units_widget),
  )

  In an update form for ate, I would like to create a dropdown box 
  of
  units that are associated with a given food_id.  I realize could not
  be set in the db.py since the food id would be unknown in that 
  scope,
  however the action in the controller would have access to the food 
  id,
  but I would like to be able to pass that somehow to the widget.

  Thanks,
  Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Passing values to widgets

2010-03-27 Thread Avik Basu
That works perfectly.  Thanks.
Avik

On Mar 27, 5:21 pm, mr.freeze nat...@freezable.com wrote:
 Sorry, low blood sugar.

 def units_widget(food_id):
     def widget(f,v):
        #build your widget
        #using food_id
     return widget

 db.ate.units.widget = units_widget(food_id)

 On Mar 27, 4:05 pm, Avik Basu avikb...@gmail.com wrote:



  Also, if i wanted to extend SQLFORM.widgets.options.widget, how would
  i go about doing that? Is it as simple as replacing:

  class Units_Widget(object):

  with:

  class Units_Widget(SQLFORM.widgets.options.widget):

  Thanks,
  Avik

  On Mar 27, 5:03 pm, Avik Basu avikb...@gmail.com wrote:

   I get the following error:

   TypeError: __init__() should return None, not 'function'

   I think the problem has to do with the following return statement in
   the constructor:

   return widget

   Avik

   On Mar 27, 11:57 am, mr.freeze nat...@freezable.com wrote:

Sorry, the constructor should be:

def __init__(*args,**kargs):

On Mar 27, 10:53 am, mr.freeze nat...@freezable.com wrote:

 You need to make your widget a class so you can pass args to it in the
 constructor:

 class Units_Widget(object):
     def __init__(**args):
         def widget(f,v):
            #build your widget
            #using args
         return widget

 db.ate.units.widget = Units_Widget(food_id)

 On Mar 27, 10:42 am, Avik Basu avikb...@gmail.com wrote:

  So, for my example, I tried your suggestion.  I defined a widget in
  models/widgets.py:

  def units_widget(field,value,food_id):
     ...

  and then in the controller, I set the widget with:

  db.ate.units.widget = units_widget(food_id)

  But here I am not passing field and value so I get an error.  What
  would be the proper way to call the widget constructor?

  Avik

  On Mar 27, 12:02 am, mdipierro mdipie...@cs.depaul.edu wrote:

   in the controller you can do

   db.table.field.widget = SomeWidgetConstructor(args)

   Not sure if this is what you are asking.

   On 26 Mar, 18:26, Avik Basu avikb...@gmail.com wrote:

Is there a way to pass arguments to a field's widget from the
controller?  For example:

db.define_table(food, Field(name, string'))

db.define_table(units,
   Field(food_id, db.food),
   Field(name, string)
)

db.define_table(ate,
   Field(food_id, db.food),
   Field(quantity, double),
   Field(units, string, widget=units_widget),
)

In an update form for ate, I would like to create a dropdown 
box of
units that are associated with a given food_id.  I realize 
could not
be set in the db.py since the food id would be unknown in that 
scope,
however the action in the controller would have access to the 
food id,
but I would like to be able to pass that somehow to the widget.

Thanks,
Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Passing values to widgets

2010-03-26 Thread Avik Basu
Is there a way to pass arguments to a field's widget from the
controller?  For example:

db.define_table(food, Field(name, string'))

db.define_table(units,
   Field(food_id, db.food),
   Field(name, string)
)

db.define_table(ate,
   Field(food_id, db.food),
   Field(quantity, double),
   Field(units, string, widget=units_widget),
)

In an update form for ate, I would like to create a dropdown box of
units that are associated with a given food_id.  I realize could not
be set in the db.py since the food id would be unknown in that scope,
however the action in the controller would have access to the food id,
but I would like to be able to pass that somehow to the widget.

Thanks,
Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] widgets in db.py

2010-03-20 Thread Avik Basu
Hi,

I have a several widgets in a file called widgets.py and would like to
use those widgets in db.py.  Both db.py and widgets.py exist in the
models directory.  However, when I use the widgets in defining table
fields in db.py, it does not recognize the widgets.  How can I include
the widgets.py in db.py?

Note that some of the the widgets reference the db object and so I
decided not to put widgets.py in the modules folder since I could not
reference db and the other globals from web2py.

Thanks for your help.

Avik

-- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py:33386] Re: OPTION selected problem

2009-10-21 Thread Avik Basu

Sorry, my example was too simplistic for what I am trying to achieve.
Let me try again.

num = 1
SELECT(OPTION('candy',_value=1, value=num),OPTION
('chocolate',_value=2, value=num))

the result i want is

select
option value=1 selected=selectedcandy/option
option value=2chocolate/option
/select

this is based on my understanding of the value and _value
attributes of the OPTION helper.  here is the relevant text from p.
139 of the manual:

---
As in the case of INPUT, web2py make a distinction between 
value (the value of the OPTION), and value (the current value of
the enclosing select). If they are equal, the option is selected.
---

Thanks,
Avik

On Oct 21, 10:42 pm, Thadeus Burgess thade...@thadeusb.com wrote:
 No, if you want that option selected pass it a attribute for selected.
 Anything with an underscore will get passed to the html as an attribute. So
 you could also go _style=...

 OPTION('candy', _selected=selected, _value=1) should produce what you are
 looking for.

 However, when using SQLFORM the default selection can be set as well when
 you specify field.default =...

 -Thadeus

 On Wed, Oct 21, 2009 at 9:26 PM, Avik Basu avikb...@gmail.com wrote:

  Hello,

  I am a Web2Py newbie trying to use the OPTION helper to create a
  dropdown menu that will select the appropriate option.

  I expect that

  OPTION('candy', _value=1, value=1)

  should produce

  option selected=selected value=1candy/option

  but it only produces

  option value=1candy/option

  Am I doing something wrong? Thanks.

  Avik


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---