[web2py] web2py exe
Hi I recently started coding a python app and decided to explore web2py. however, when I download the windows exe and run it, I see neither the admin console nor the webpage when I connect to 127.0.0.1:8000 I even tried web2py.exe -S welcome, and still nothing. Regards Raji -- 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] Performance issues while opening webpage with more than 1 lakh records.....
Hi , i am a newbie in Web2pyI have more than 1 lakh records in database table1 and i am displaying that table through an SQLFORM.grid.The problem is the corresponding WebPage for this table1 is taking more than 15 seconds to open.Is there a way we can solve this performance issue??.Kindly help.. Default.py def WebPage(): grid=SQLFORM.grid(db.table1) return locals() WebPage.html {{=grid}} and table1 has more than 1 lakh records. -- --- 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: Converting Field of a SQLFORM.grid to local timezone of a user.....
On Tuesday, 12 February 2013 11:06:00 UTC+5:30, newbie wrote: > > Hi, > I have a table x, with fields name,place,timezone_offset.And another > table y ,having field 'servertime',which stores the current time of the > server its fetching the values from. > > db.define_table('x',Field('name'),Field('place'),Field('timezone_offset' > )) > db.define_table('y',Field('name'),Field('servertime')) > User will set the timezone offset in table x, for a particular name. There is one thread continuously running in background in the server which will save the servertime as local time using datetime.datetime.now() in table y for the name. And finally this data displayed by using SQLFORM.grid on the UI. Problem facing: We have to convert the local time saved for the name field as per saved timezone_offset in x table and display on the grid without modifying anything on database level. It means suppose for name ='Alex' timezone_offset was being saved as -5 in x table and suppose server running on different timezone lets say on +5.30 so for name Alex server will save the servertime in +5.30 format as it is the local time for the server but when it will be displayed on the grid servertime should first get converted to Alex timezone_offset which is set as -5 and then display on the grid. Can anyone please suggest me how can I achieved in web2py? Is there any way to achieve it using SQLFORM.grid()? Thanks. > > -- --- 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] Converting Field of a SQLFORM.grid to local timezone of a user.....
Hi, I have a table x, with fields name,place,timezone offset.And another table y which references to table x and has an additional field 'timezone',which displays the timezone of the server its fetching the values from.I want to convert the timezone of the server,to the timezone of the local user,by using the offset of from table x,Kindly suggest a way to show the converted time in a grid,such that we don't have to convert for all the records in the table y.Only the shown page records should be converted .Converting all the records might slow the process.So,one page will have 20 records,all the records its displaying should be converted to user's local timezone.When the user, paginates to another page,those 20 set of records shuld be converted that moment and shown.Is it possible.Kindly tell a way if this can be achieved. -- --- 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: Create SQLFORM with one of its field's as ajax enabled
Hi Richardthanks for the link...the widget is working perfectly for all scenarios..:) On Thursday, 31 January 2013 10:29:29 UTC+5:30, newbie wrote: > Hi > I m a newbie working on web2py,and i want to create an SQLForm > with database Employee.The fields of db.Employee are name,campus,timzezone > .I want the user to input in the SQLform ,but the last filed of timezone > shud be such that when the user inputs in the field ,it shud present a > dropdown of fields from another database called 'timezone_countries'.The > user shud be able to select from the dropdown and submit the form .The code > i have written in DB,Default,and view are here respectively:- > DB.py > > db.define_table('Employee',Field('name'),Field('campus'),Field('timezone')) > > > db.define_table('timezone_countries',Field('countries')) > def timezone_countries_data(): > result = {} > result['countries'] = 'Brazil/Rio' > db.timezone_countries.insert(**result) > db.commit() > > DEFAULT.py > def timezone_countries_dataF(): > timezone_countries_data() > > def emp_input(): > form=SQLFORM(db.Employee) > return locals() > > def emp_selector(): > if not request.vars.emp_timezone: > --->where > > emp_timezone is the id of timezone in SQLFORM > return ' ' > pattern = request.vars.emp_timezone.capitalize() + '%' > selected = [row.countries for row in > db(db.timezone_countries.countries.like(pattern)).select()] > return ''.join([DIV(k, > _onclick="jQuery('#emp_timezone').val('%s')" % k, > _onmouseover="this.style.backgroundColor='yellow'", > _onmouseout="this.style.backgroundColor='white'" > ).xml() for k in selected]) > > View: > {{extend 'layout.html'}} > {{=form}} > > #suggestions { position: relative; } > .suggestions { background: white; border: solid 1px #55A6C8; } > .suggestions DIV { padding: 2px 4px 2px 4px; } > > >class="suggestions"> > > > > jQuery("#emp_timezone").keyup(function(){ > ajax('emp_selector', ['emp_timezone'], 'suggestions')}); > > > > Kindly help... > -- --- 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] Create SQLFORM with one of its field's as ajax enabled
Hi Richard, Thanks for the answer. Actually i am able to achieve Ajax enabled text box in an SQLFORM...But the problem is the sqlform is auto generated by the SQLFORM.grid for that database. The code for SQLFORM which is working for normal tables is: DB.py db.define_table('tag',Field('name'),Field('campus'),Field('timezone')) def tag_data(): result = {} result['name'] = 'Neha' result['campus'] = 'Orion' result['timezone'] = 'America/newyork' db.tag.insert(**result) db.commit() db.define_table('timezone_list',Field('countries')) def timezone_list_data(): result = {} result['countries'] = 'Ireland' db.timezone_list.insert(**result) db.commit() def timezone_bulk(): db.timezone_list.bulk_insert([{'countries':'Africa/Abidjan'}, {'countries':'Africa/Accra'}, {'countries':'Africa/Addis_Ababa'}, {'countries':'Africa/Bamako'},{'countries':'America/Argentina/Buenos_Aires'}, {'countries':'America/Argentina/ComodRivadavia'}, {'countries':'America/Argentina/Rio_Gallegos'}, {'countries':'America/Cambridge_Bay'},{'countries':'America/Chicago'},{'countries':'America/Costa_Rica'},{'countries':'America/Detroit'}, {'countries':'Indian/Antananarivo'},{'countries':'Indian/Mahe'},{'countries':'Indian/Maldives'},{'countries':'Indian/Reunion'}, {'countries':'US/Hawaii'},{'countries':'US/Pacific'},{'countries':'UTC'},{'countries':'Zulu'}, {'countries':'Singapore'}]) db.commit() DEFAULT.py def month_input(): form=SQLFORM(db.tag) return locals() def month_selector(): if not request.vars.timezone: return '' pattern = request.vars.timezone.capitalize() + '%' selected = [row.countries for row in db(db.timezone_list.countries.like(pattern)).select()] return ''.join([DIV(k, _onclick="jQuery('#tag_timezone').val('%s'); jQuery('#suggestions').hide(); " % k, _onmouseover="this.style.backgroundColor='yellow'", _onmouseout="this.style.backgroundColor='white'", ).xml() for k in selected]) def timezone_list_dataF(): timezone_list_data() def timezone_bulkF(): timezone_bulk() month_input.html {{extend 'layout.html'}} {{=form}} #suggestions { position: relative; } .suggestions { background: white; border: solid 1px #55A6C8; } .suggestions DIV { padding: 2px 4px 2px 4px; } jQuery("#tag_timezone").keyup(function(){ jQuery('#suggestions').show(); ajax('month_selector', ['timezone'], 'suggestions')}); But i have to generate the same result for an auto generated SQLFORM.Actually we are using an sqlform.grid which has an inbuilt option for ADD.And on clicking on that an autogenerated SQLFORM for adding inputs opens.Now the goal is to add another field in that page which is ajax enabled.Can we do it?.Kindly helpThanks in advance.. On Thursday, 31 January 2013 20:32:13 UTC+5:30, Richard wrote: > Have you look at this plugin : > http://dev.s-cubism.com/plugin_lazy_options_widget > > It require a dependecy to suggest plugin as explained on the site, but you > can avoid using it. I already post answer to Jim on this list about that. > If you need more help with the integration of lazy option widget plugin let > me know... > > Richard > > > On Wed, Jan 30, 2013 at 11:59 PM, newbie >wrote: > >> Hi >> I m a newbie working on web2py,and i want to create an SQLForm >> with database Employee.The fields of db.Employee are name,campus,timzezone >> .I want the user to input in the SQLform ,but the last filed of timezone >> shud be such that when the user inputs in the field ,it shud present a >> dropdown of fields from another database called 'timezone_countries'.The >> user shud be able to select from the dropdown and submit the form .The code >> i have written in DB,Default,and view are here respectively:- >> DB.py >> >> db.define_table('Employee
[web2py] Create SQLFORM with one of its field's as ajax enabled
Hi I m a newbie working on web2py,and i want to create an SQLForm with database Employee.The fields of db.Employee are name,campus,timzezone .I want the user to input in the SQLform ,but the last filed of timezone shud be such that when the user inputs in the field ,it shud present a dropdown of fields from another database called 'timezone_countries'.The user shud be able to select from the dropdown and submit the form .The code i have written in DB,Default,and view are here respectively:- DB.py db.define_table('Employee',Field('name'),Field('campus'),Field('timezone')) db.define_table('timezone_countries',Field('countries')) def timezone_countries_data(): result = {} result['countries'] = 'Brazil/Rio' db.timezone_countries.insert(**result) db.commit() DEFAULT.py def timezone_countries_dataF(): timezone_countries_data() def emp_input(): form=SQLFORM(db.Employee) return locals() def emp_selector(): if not request.vars.emp_timezone: --->where emp_timezone is the id of timezone in SQLFORM return ' ' pattern = request.vars.emp_timezone.capitalize() + '%' selected = [row.countries for row in db(db.timezone_countries.countries.like(pattern)).select()] return ''.join([DIV(k, _onclick="jQuery('#emp_timezone').val('%s')" % k, _onmouseover="this.style.backgroundColor='yellow'", _onmouseout="this.style.backgroundColor='white'" ).xml() for k in selected]) View: {{extend 'layout.html'}} {{=form}} #suggestions { position: relative; } .suggestions { background: white; border: solid 1px #55A6C8; } .suggestions DIV { padding: 2px 4px 2px 4px; } jQuery("#emp_timezone").keyup(function(){ ajax('emp_selector', ['emp_timezone'], 'suggestions')}); Kindly help... -- --- 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: Python for Android (any takers to run web2py)
I think they're running web2py on an android device in this video (apparently one of Massimo's colleagues): http://pyvideo.org/video/1246/some-experiences-with-python-for-android-py4a --
[web2py] Remember to delete examples application or become a spam farm
Just a short note to say traffic on one of my websites had gone through the roof recently. It turns out that I hadn't removed the examples directory from web2py and spammers were using the example applications to upload comment spam. Cheers Brendan --
[web2py] Re: Trouble with pickling session
On Monday, August 13, 2012 12:35:05 AM UTC+10, Anthony wrote: > > Are you able to pickle the object outside of web2py (i.e., is the object > generally pickleable, but fails only in web2py)? > > Didn't occur to me, but have now tested it - Yes, I can pickle it with the re.finditer line. --
[web2py] Re: Trouble with pickling session
Replaced method by: def initNewLines(self): self.newlines = [] for i in range(len(self.raw)): if self.raw[i:i+1]=='\n': self.newlines.append(i) And no more complaints from web2py. Would like to know what the problem is though. --
[web2py] Re: Trouble with pickling session
It seems to be caused by the presence of: nlIter = re.finditer('\n',self.raw) in one of the methods of one of the class methods. So, I moved the work to a separate function (not method): def initNewLines(self): self.newLines = findNewLines(self.raw) def findNewLines( searchIn): ''' given a string return a list with the indices of each \n character ''' result = [] for nl in re.finditer('\n', searchIn): result.append(nl.start) return result But it still doesn't seem to work. If I change it to self.newlines = [], web2py pickles the session fine. confused... --
[web2py] Trouble with pickling session
My app doesn't want to pickle my session for some reason. I get: Traceback (most recent call last): File "/data-current/programming/python/web2py/gluon/main.py", line 523, in wsgibase session._try_store_on_disk(request, response) File "/data-current/programming/python/web2py/gluon/globals.py", line 591, in _try_store_on_disk cPickle.dump(dict(self), response.session_file) TypeError: expected string or Unicode object, NoneType found This occurs on return from a function call. Immediately before the call I check that session_file and session exist. session_file seems to exist and is open: session file: Any ideas what would cause this? There is a class in session with 4 levels of inheritance would that be a problem? Thanks Brendan --
[web2py] Re: Storing class instances in sessions... or somewhere
I meant "a simplified version which acts the same way"
[web2py] Re: Storing class instances in sessions... or somewhere
Here's a simplified version: class debugDM(object): def __init__(self): self.allDefs=[] def add_def(self, rawText): if rawText not in self.allDefs: self.allDefs.append(rawText) Here are some controllers: def debug2(): print "counter: %s, counter2: %s len: %s"%(session.counter,session.counter2, len(session.defManager.allDefs)) #session.defManager.add_def("Test%s"%session.counter) session.counter +=1 return locals() #session.defManager.dump() def debug3(): print "counter: %s, counter2: %s len: %s"%(session.counter,session.counter2, len(session.defManager.allDefs)) session.defManager.add_def("Test%s"%session.counter) print '\nDebug3: '.join(session.defManager.allDefs) #session.counter +=1 return "".join(session.defManager.allDefs) def test(): print "\n** in test()" right_sidebar_enabled = True if session.defManager is None: # web2py returns None for undefined attributes print "initialising definition manager" session.defManager = toc.debugDM() print "In test(): ",session.defManager session.defManager.add_def("AddFromTest") session.counter = 0 session.counter2 = 0 On Friday, 30 March 2012 23:55:59 UTC+11, Massimo Di Pierro wrote: > > Can I see the object that you are storing in session? > > On Friday, 30 March 2012 01:09:09 UTC-5, Web2py Newbie wrote: >> >> session doesn't seem to have a "force an update to me" method, so I am >> just incrementing a counter. >> >
[web2py] Re: Storing class instances in sessions... or somewhere
session doesn't seem to have a "force an update to me" method, so I am just incrementing a counter.
[web2py] Re: Storing class instances in sessions... or somewhere
On Friday, 30 March 2012 14:38:39 UTC+11, Limedrop wrote: > > M. Picking might not be the issue. I would try to take javascript > out of the equation first. What if you simulated the javascript in a > second server-side controller? See if it can retrieve, update and save the > session? > > I now have a second controller which adds a unique entry each page refresh. When I visit the controller pages, the entries are properly added and retained. When I call via AJAX, the entries are not, despite being added locally (eg printing the elements to console after adding). I thought it might be that I am trying to add request.vars in the ajax call, but it doesn't remember even string literals being added. Confused... ahhh... But when I add another (primitive) variable to the session and change that within the (server side of the) ajax call everything starts working properly. So, presumably web2py doesn't notice changes to the instance so chooses not to update session, changing the primitive causes it to update all the session variables including the instance.
[web2py] Re: Storing class instances in sessions... or somewhere
On Friday, 30 March 2012 12:04:05 UTC+11, Limedrop wrote: > > If instances are pickable then you should be okay. Have you tried saving > them to the session and seeing what happens? Note that sometimes you can > pickle things okay but the unpickle throws the error. > > > Have you tried saving them to the session and seeing what happens? I have - weird stuff happens. The class I have been testing is supposed to accumulate elements like a set. The first one I add (in the controller for the view for debugging) gets stored in the instance fine, and it seems to persist when I save the instance to session. However, when I add other elements (in a separate function called by the javascript) to that instance they get added while in the function, but don't seem to persist in the object saved in the session. It is like the instance is a local variable initialised from what is first stored by the controller. I can modify the original instance like it is a local variable, but changes don't stay there to the next call. > Failing that have a look at the recipe near the bottom of this thread... > > http://bytes.com/topic/python/answers/552476-why-cant-you-pickle-instancemethods > > BTW, that's no good for web2py classes, which don't pickle because they > are db connections thanks for the link I will try to decipher it.
[web2py] Storing class instances in sessions... or somewhere
I have an existing application that I am trying to get running as AJAX with web2py (locally, but eventually to run on GAE). The application makes use of class instances to store much of the data which would be used for user sessions. I understand that session can't be used to store class instances but for the time being I want to keep the instances for each session (about 200K of data). Sooner or later I guess I will need to save this data in the data store, but at the moment I'm trying to get a prototype up and running and reworking the code to get the data into/out of a database is more pain than I can face atm. The instances are pickleable (well, cPickle doesn't complain) My options seem to be: * cache in ram using the session id as a key and * dumping the instance to a string, saving the string to session (on GAE will this be the same as cache.ram?) Are there other approaches? What's the best way to go about this? Also, in the next update of the documentation, this would be a useful detail to include on the session related sections. Thanks in advance Brendan
[web2py] Re: I would like to learn Web2py but where do I start?
Thank you all so much for your responses and recommendations. I will give those a try. Massimo, keep up the great work and thank you for taking the time to help. I look forward to the video tutorial. On Feb 23, 10:20 pm, pbreit wrote: > W3schools is perfectly fine. That fools thing is a little overblown.
[web2py] I would like to learn Web2py but where do I start?
Hello, I would like to learn Web2py but know nothing about programming. I'm convinced it's the best language out there so I don't want to waste time learning something that would not be applicable if I ended up using Web2py (PHP, etc). Do I need to learn Javascript first? Do I need to know HTML? I would eventually like to learn how to build database driven websites. Thanks
[web2py] Re: More Details on RESTful web2py?
At the moment it is: @request.restful() def as_rest(): def GET(*args,**vars): patterns = ['/{bookmarks.id}', ''] parsed = db.parse_as_rest(patterns,args,vars) if parsed.status==200: return parsed.response.json() else: posts = db().select(db.bookmarks.ALL) return response.render('posts/index.html', locals()) On Jun 16, 12:58 pm, Massimo Di Pierro wrote: > please show us your code. > > On Jun 15, 2:25 am, Web2py Newbie > > wrote: > > As a follow up: > > > I want to use something like: > > /myapp/api/show_comment/id > > to show comment at id > > and > > /myapp/api/show_comment/ > > To show all comments > > > However, when I try this it complains ("invalid arguments"). I try to > > test id against None, but id is apparently a server object. > > Any ideas or do I just have to define all_comments? > >
[web2py] Re: More Details on RESTful web2py?
Apparently: wait for a pattern failure and work with that? if parsed.status==200: return parsed.response.json() else: maybe some test for kind of parse error
[web2py] Spello in @request.restful() parsed.error
Version 1.96.4 (2011-06-07 21:08:15) If there's no matching pattern: "no mathcing pattern" -> "no matching pattern" ^^ Is there a bug tracker somewhere I'm supposed to use?
[web2py] Re: More Details on RESTful web2py?
H it seems to have just dropped my supplementary question. Apologies if this arrives twice. I want to do something like: /myapp/api/get_comment/id to return the comment at id and /myapp/api/get_comment/ to return a list of all comments However, it complains when I try this (invalid argument). I try to test id against None, but it's a server object so isn't None. Is this doable or do I give up and define get_all_comments?
[web2py] Re: More Details on RESTful web2py?
As a follow up: I want to use something like: /myapp/api/show_comment/id to show comment at id and /myapp/api/show_comment/ To show all comments However, when I try this it complains ("invalid arguments"). I try to test id against None, but id is apparently a server object. Any ideas or do I just have to define all_comments?
[web2py] More Details on RESTful web2py?
I am trying to find more details on @request.restful() in Web2py. I have found a vimeo video: http://vimeo.com/21133657 And a post on reddit: http://www.reddit.com/r/programming/comments/g5hxq/web2py_trunk_has_a_new_restful_api_that_writes_db/c1l2ykg Is there any other documentation? In particular, the reddit post says: # we can limit access using auth.requires_login # but it must be preceeded by request.restful But the code snippet doesn't actually use auth.requires_login - it is just a repeat of the earlier code example. Are there any examples of use of auth.requires_login with a Restful service? Thanks in advance Brendan
[web2py] Re: Uploading file
On Jun 9, 3:42 am, Massimo Di Pierro wrote: > I responded 2hr ago but comment did not show up. It happens all the > time. :-( > Here is it a again and hope it shows up. > > def upload(): > return > dict(form=crud.create(db.uploadedFiles,message='Successful > upload',next=URL())) Wow. I would never have guessed that. I will try it later today. Thanks Brendan
[web2py] Uploading file
I want to expose a method which will accept a file POSTed to it and save the file to the database. I have found php examples all over the place (one below). How do i do this in web2py? I don't want to use a form as I don't want to upload interactively. My model is this: db.define_table('uploadedFiles', Field('displayName'), Field('store_file','upload',autodelete=True)) Thanks in advance Brendan Example php:
[web2py] Re: Problems with Google App Engine
On Mar 24, 7:16 pm, Arbie Samong wrote: > I'm not sure if my reply was posted so I'm posting again. It happened to me > because I tried to set handlers.script in app.yaml to web2py.py. I used > gaehandler.py instead and it worked. Wow! It worked! Thanks Brendan
[web2py] Problems with Google App Engine
Hi I have done a short app (actually just a couple of web pages strung together) that I wanted to load to the google app engine. When I try to hook up web2py: python2.5 dev_appserver.py web2py the app starts, but fails when I load the page in a browser: ERROR2011-03-23 23:00:16,549 dev_appserver.py:3285] Exception encountered handling request Traceback (most recent call last): File "/data-current/programming/python/gae/google_appengine/google/ appengine/tools/dev_appserver.py", line 3245, in _HandleRequest self._Dispatch(dispatcher, self.rfile, outfile, env_dict) File "/data-current/programming/python/gae/google_appengine/google/ appengine/tools/dev_appserver.py", line 3186, in _Dispatch base_env_dict=env_dict) File "/data-current/programming/python/gae/google_appengine/google/ appengine/tools/dev_appserver.py", line 531, in Dispatch base_env_dict=base_env_dict) File "/data-current/programming/python/gae/google_appengine/google/ appengine/tools/dev_appserver.py", line 2410, in Dispatch self._module_dict) File "/data-current/programming/python/gae/google_appengine/google/ appengine/tools/dev_appserver.py", line 2320, in ExecuteCGI reset_modules = exec_script(handler_path, cgi_path, hook) File "/data-current/programming/python/gae/google_appengine/google/ appengine/tools/dev_appserver.py", line 2216, in ExecuteOrImportScript exec module_code in script_module.__dict__ File "/data-current/programming/python/gae/web2py/web2py.py", line 9, in os.chdir(path) AttributeError: 'module' object has no attribute 'chdir' Any ideas on what's going on/how to fix? web2py version is most recent stable from the website this morning (1.94.5) Python version is Python 2.5.5 (r255:77872, Mar 24 2011, 09:36:33), but I get the same failure using python2.6 Brendan
[web2py] Help with setting up Web2py environment
Hi I have migrated an existing application onto web2py as a proof of concept and I'm looking at how I take it/web2py further. The main things I'm wondering about are: * what's the right way to do logging in web2py? My test server is running apache2/wsgi. * what's the right way to use svn (do I just import the whole web2py directory structure)? * what's the right way to debug applications? python web2py.py -S ? * is Eric useable as an ide? * any traps for young players? Thanks in advance Brendan
[web2py:21121] Re: redirection to next page on submit
Thank you. wud try copying into session variables. :) On May 4, 1:19 am, Yarko Tymciurak wrote: > The thing to be aware of: > > www is connectionless; each request is it's own "program" running (sort of > - it's its own thread). > > That is, when you ask for a page, a new instance of web2py is created > (cache), the application and controller that is being requested is > determined, the models are read into the thread so that the data structures > for your datastore are defined (actually, all the files in your app/models > directory are run, so you may find some opportunistic placement of utilities > into the models directory by some - this is ok)... and once that > environment is setup for the thread, the function from the controller is > called. > > You have a few ways to communicate information between these threads: > > - store in persistent data, and let each thread read it out; > - pass in parameters to your controller/function call > See the URL function: you'll see all paths to web2py apps have the form > of: > - application/controller/function/arg/arg2/.../vars > the last piece looking like a dict: > arg/arg2?key=value,key2=another_value > - store in session variables (short term, and works for the same client > session) > > On Sun, May 3, 2009 at 12:53 PM, newbie wrote: > > > hi mdipierro, > > > Actually I'm trying to access some of the request variables of > > the form. But If i redirect using > > > redirect(URL(r=request,f='confirm')) > > > I'm not able to access the request variables of the form. > > > On May 3, 7:03 pm, newbie wrote: > > > thanks for the immediate reply :) > > > > On May 3, 7:01 pm, mdipierro wrote: > > > > > def page1(): > > > > form=SQLFORM(db.a_table) > > > > if FORM.accepts(form,request.vars): > > > > session.vars=form.vars > > > > redirect(URL(r=request,f='confirm')) > > > > return dict(form=form) > > > > > def confirm(): > > > > form=FORM('sure?',INPUT(_name='yes',_type='checkbox'),INPUT > > > > (_type='submit')) > > > > if request.vars.yes and session.vars: > > > > db.a_table.insert(**session.vars) > > > > ... do something > > > > return dict(form=form) > > > > > On May 3, 8:50 am, Nazgi wrote: > > > > > > Hi, > > > > > > I'm new to python and web2py. I have a simple doubt. I've > > > > > written a form and after the submit button is pressed in the form, I > > > > > want to print the variables of the form into next page and ask for > > > > > confirmation. I have written the form in a controller and also the > > > > > function for the next page where the variables of the form are > > > > > printed. But i dont know how to direct to that page after pressing of > > > > > the submit button. Can someone help me regarding this. > > > > > > regards, > > > > > Nazgi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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 -~--~~~~--~~--~--~---
[web2py:21062] Re: redirection to next page on submit
hi mdipierro, Actually I'm trying to access some of the request variables of the form. But If i redirect using redirect(URL(r=request,f='confirm')) I'm not able to access the request variables of the form. On May 3, 7:03 pm, newbie wrote: > thanks for the immediate reply :) > > On May 3, 7:01 pm, mdipierro wrote: > > > def page1(): > > form=SQLFORM(db.a_table) > > if FORM.accepts(form,request.vars): > > session.vars=form.vars > > redirect(URL(r=request,f='confirm')) > > return dict(form=form) > > > def confirm(): > > form=FORM('sure?',INPUT(_name='yes',_type='checkbox'),INPUT > > (_type='submit')) > > if request.vars.yes and session.vars: > > db.a_table.insert(**session.vars) > > ... do something > > return dict(form=form) > > > On May 3, 8:50 am, Nazgi wrote: > > > > Hi, > > > > I'm new to python and web2py. I have a simple doubt. I've > > > written a form and after the submit button is pressed in the form, I > > > want to print the variables of the form into next page and ask for > > > confirmation. I have written the form in a controller and also the > > > function for the next page where the variables of the form are > > > printed. But i dont know how to direct to that page after pressing of > > > the submit button. Can someone help me regarding this. > > > > regards, > > > Nazgi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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 -~--~~~~--~~--~--~---
[web2py:21044] Re: redirection to next page on submit
thanks for the immediate reply :) On May 3, 7:01 pm, mdipierro wrote: > def page1(): > form=SQLFORM(db.a_table) > if FORM.accepts(form,request.vars): > session.vars=form.vars > redirect(URL(r=request,f='confirm')) > return dict(form=form) > > def confirm(): > form=FORM('sure?',INPUT(_name='yes',_type='checkbox'),INPUT > (_type='submit')) > if request.vars.yes and session.vars: > db.a_table.insert(**session.vars) > ... do something > return dict(form=form) > > On May 3, 8:50 am, Nazgi wrote: > > > Hi, > > > I'm new to python and web2py. I have a simple doubt. I've > > written a form and after the submit button is pressed in the form, I > > want to print the variables of the form into next page and ask for > > confirmation. I have written the form in a controller and also the > > function for the next page where the variables of the form are > > printed. But i dont know how to direct to that page after pressing of > > the submit button. Can someone help me regarding this. > > > regards, > > Nazgi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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 -~--~~~~--~~--~--~---
[web2py:20706] Re: forms in web2py
I think I've messed it up. I would like to explain my problem once again clearly. in controllers/identity.py: def getcities(): citystr = request.vars.values()[0] if citystr == "Delhi": output = "city1, city2" # list elif citystr == "Tamil Nadu": output = "city2, city3" # list elif citystr == "Andhra Pradesh": output = "city4, city5. city6" # list else: output = "Bombay" return output def index(): form=FORM(TABLE( TR("State:", SELECT("Andhra Pradesh","Delhi","Tamil Nadu",_name="States", _id="States",default="Andhra Pradesh",_onchange="ajax('/Test/default/ getcities',['States'],'handle')",requires=[IS_NOT_EMPTY()])), TR(DIV(_id="handle")), TR("District", SELECT({{=handle}}, _name="Choose", _id="district", default="", requires=[IS_NOT_EMPTY()] return dict(form=form) What i'm trying to do here is: I've built a form to enter the states and based on the option selected by the user, I'm generating another option list. So in the first options menu, the user input will be sent to geticities() function using ajax which will return a json object list of cities beloging to that input entry. Now when I use that list (handle) in DIV tag, I'm able to display list. But I'm not able to use that list to populate the options in second SELECT tag as shown above. Its giving me an error on writing so. Had i written that code for the form in a View using html, i wud not have faced these problems. Since I'm using the SELECT tag here, I'm facing these problems. On Apr 26, 3:58 am, mdipierro wrote: > Not sure I understand but you can try: > > def getcities(): > citystr = request.vars.values()[0] > if citystr == "Delhi": > output = "Hyderabad" > elif citystr == "Tamil Nadu": > output = "Chennai" > elif citystr == "Andhra Pradesh": > output = "Pune" > else: > output = "mumbai" > return TAG[''](OPTION(""),OPTION("asfas"),OPTION > ("safee"),OPTION(output)) > > def index1(): > form=FORM(TABLE( > TR("State:", SELECT("Andhra > Pradesh","Delhi","Tamil Nadu",_name="States", > _id="States",default="Delhi",_onchange="ajax('/Test/default/ > getcities', > ['States'],'district')",requires=[IS_NOT_EMPTY()])), > TR("District", SELECT("","asfas","safee", > _name="Choose", _id="district", default="", requires=[IS_NOT_EMPTY > ()] > return dict(form=form) > > On Apr 25, 3:51 pm, newbie wrote: > > > in Controller/index.py: > > def getcities(): > > citystr = request.vars.values()[0] > > if citystr == "Delhi": > > output = "Hyderabad" > > elif citystr == "Tamil Nadu": > > output = "Chennai" > > elif citystr == "Andhra Pradesh": > > output = "Pune" > > else: > > output = "mumbai" > > return output > > > def index1(): > > form=FORM(TABLE( > > TR("State:", SELECT("Andhra > > Pradesh","Delhi","Tamil Nadu",_name="States", > > _id="States",default="Delhi",_onchange="ajax('/Test/default/getcities', > > ['States'],'handle')",requires=[IS_NOT_EMPTY()])), > > TR(DIV(_id="handle")), > > TR("District", SELECT("","asfas","safee", > > _name="Choose", _id="district", default="", requires=[IS_NOT_EMPTY > > ()] > > return dict(form=form) > > > This is how i've written a form withajaxto auto-populate SELECT > > boxes. But in the above code, if i want to use the "handle" variable > > and display it as an option in SELECT box, I'm not able to do that. If > > i return a list into the "handle" variable then how do i populate the > > list in SELECT box. Please reply me asap. > > > Thanks, > > Nazgi. > > > On Apr 25, 2:21 pm, Nazgi wrote: > > > > Hi, > > > > I hav written a form in controller of my application. The form > > > has a select option which based on its input usesajaxand calls a > > > function. This function sends a json list object. How do I access that > > > variable in order to incorporate the contents of that list as another > > > select option menu.? > > > > Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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 -~--~~~~--~~--~--~---
[web2py:20506] Re: forms in web2py
in Controller/index.py: def getcities(): citystr = request.vars.values()[0] if citystr == "Delhi": output = "Hyderabad" elif citystr == "Tamil Nadu": output = "Chennai" elif citystr == "Andhra Pradesh": output = "Pune" else: output = "mumbai" return output def index1(): form=FORM(TABLE( TR("State:", SELECT("Andhra Pradesh","Delhi","Tamil Nadu",_name="States", _id="States",default="Delhi",_onchange="ajax('/Test/default/getcities', ['States'],'handle')",requires=[IS_NOT_EMPTY()])), TR(DIV(_id="handle")), TR("District", SELECT("","asfas","safee", _name="Choose", _id="district", default="", requires=[IS_NOT_EMPTY ()] return dict(form=form) This is how i've written a form with ajax to auto-populate SELECT boxes. But in the above code, if i want to use the "handle" variable and display it as an option in SELECT box, I'm not able to do that. If i return a list into the "handle" variable then how do i populate the list in SELECT box. Please reply me asap. Thanks, Nazgi. On Apr 25, 2:21 pm, Nazgi wrote: > Hi, > > I hav written a form in controller of my application. The form > has a select option which based on its input uses ajax and calls a > function. This function sends a json list object. How do I access that > variable in order to incorporate the contents of that list as another > select option menu.? > > Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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 -~--~~~~--~~--~--~---
[web2py:20415] Re: debuggers for ajax in web2py
thanks for the reply... On Apr 24, 12:27 pm, Fran wrote: > On Apr 24, 7:11 am, Nazgi wrote: > > > I'm new to web2py. Can some1 tell me how to debug javascript > > code in web2py? > > Same as you debug JavaScript in other environments:http://getfirebug.com > > F --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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 -~--~~~~--~~--~--~---