[web2py] Image searching - Redirecting Ajax Results to pass to template ??
OK - hope I can make this clear - it's more of a 'how to' design question and not really web2py specific. Imagine a view/template with a container/div that displays a (multipage) image gallery - this is the landing page (prepopulated with random images. The page has a Search sidebar to allow filtering/subselection by tags; names etc. The search performs an Ajax search to find a subset of images and currently retrieves an XML list of matches. What I want to do is refresh the template images display with matches found by the Ajax request. (I don't think XHR can retrieve binary data). The XHR request currently retrieves a list, but what I really need to do here is pass the list on and have the image files updated. Is there a way to do that and/or some examples of this? Any suggestions wold be appreciated!
[web2py] A SQLFORM.grid question
I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,details=True,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman
Re: [web2py] A SQLFORM.grid question
are you able to see the form? or are you getting the not authorized message? you can set user_signature=False or ensure that user is logged in. On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltman mike.velt...@gmail.com wrote: I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,details=True,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] A SQLFORM.grid question
are you able to see the form? or are you getting the not authorized message? you can set user_signature=False or ensure that user is logged in. Thanks for the reaction. But no the form is generated perfectly. And the user is logged in. On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltman mike.velt...@gmail.com wrote: I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,details=T rue,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman With regards, Mike Veltman
[web2py] Re: BlockUI with web2py
here is controller (sleep is for emulating long lasting action): def akcje(): [...] if request.vars.a == 'restart': form=FORM(TR('Wybierz VPS',SELECT(ipvps,_name='ip', requires=IS_IN_SET(ipvps))), TR('',INPUT(_type='submit'), formstyle='ul'),_id='staty') if form.accepts(request,session): import time time.sleep(5) response.flash = 'restart form accepted' rest=str(iphostserv[request.vars.ip]) + veid + str(vids[request.vars.ip]) elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' and akcje.load: {{left_sidebar_enabled=right_sidebar_enabled=False}} {{#extend 'layout.html'}} {{#if 'message' in globals():}} {{if request.vars.a == 'restart':}} {{=form}} {{=rest}} and akcje.html: {{left_sidebar_enabled=right_sidebar_enabled=False}} {{extend 'layout.html'}} {{#if 'message' in globals():}} h1Akcje/h1 hr / {{if request.vars.a == 'restart':}} h3Restart action/h3 {{=LOAD('default','akcje.load',vars={'a':'restart'},content='Poczekaj...',ajax=True)}} On 2 Lis, 02:41, Anthony abasta...@gmail.com wrote: Can you show some code? On Tuesday, November 1, 2011 6:47:13 PM UTC-4, brushek wrote: Ok, thanks for answer. I would like to use this plugin with LOAD helper. How can I connect LOAD with blockUI ? When I use load, then I can't make blockUI working (I want to ask user before send the validated form wheter do the action (by javascript confirm()) and make him waiting with blocked browser with 'Operation in progress...' text for a while (by blockUI). On 1 Lis, 13:39, Anthony abas...@gmail.com wrote: blockUI is just a client-side jQuery plugin, so just follow the usual instructions:http://jquery.malsup.com/block/. I don't think there's anything special about using it with web2py. On Tuesday, November 1, 2011 8:34:42 AM UTC-4, brushek wrote: Hello, I would like to use jquery blockUI with web2py for long time action. Can You give me some example/advice, how to do this with web2py using web2py's ajax or jQuery in the best-fashion manner ? regards brushek
[web2py] Re: Confused about hidden fields
Instead of form.accepts() you can use form.validate() and then do your own update. Then you do not need to pass unnecessary variables to the view and back again. form = SQLFORM(table, id) if form.validate(): form.vars.mysecretvariable=whatever I want if not form.errors: if not id: id=table.insert(**dict(form.vars)) session.flash = record inserted elif form.vars.get('delete_this_record',False): db(table.id==id).delete() session.flash = record deleted else: table[id].update_record(**dict(form.vars)) session.flash = record updated On Nov 2, 3:11 am, Omi Chiba ochib...@gmail.com wrote: Thank you for understanding me :) I tried but this code will set the default value if the field exist on the view. I made a simple example. I don't want to show field2 so it's excluded in view using custom form but want to store the value like 'BBB' or 'CCC' before it's inserted into table. This code just leave field2 blank... model db.define_table('mytable', Field('field1'), Field('field2')) controller def index(): form = SQLFORM(db.mytable) form.vars.field2 = 'BBB' if form.process().accepted: form.vars.field2 = 'CCC' session.flash = 'form accepted' redirect(URL('index')) elif form.errors: response.flash = 'form has errors' return dict(form=form) view {{extend 'layout.html'}} {{=form.custom.begin}} Field1: {{=form.custom.widget.field1}} {{=form.custom.submit}} {{=form.custom.end}} On Nov 1, 6:58 pm, pbreit pbreitenb...@gmail.com wrote: I believe in your controller, before form.process() (or form.accepts), include: form.vars.FFTSCD = 'aaa'
[web2py] Re: A SQLFORM.grid question
SQLFORM.grid does not actually add the records automatically. It just calls the grid controller with args action/table. You have to do something like: if request.args(0) in (edit, new): redirect(URL(edit.html, args=[request.args(1), request.args(2)]) On Nov 2, 9:15 am, Mike Veltman mike.velt...@gmail.com wrote: are you able to see the form? or are you getting the not authorized message? you can set user_signature=False or ensure that user is logged in. Thanks for the reaction. But no the form is generated perfectly. And the user is logged in. On Wed, Nov 2, 2011 at 6:50 AM, Mike Veltman mike.velt...@gmail.com wrote: I have grid = SQLFORM.grid(query=db.lvstorage.setup_id==usedsetupid,csv=False,details=T rue,searchable=True) That creates a form with the records with a add button. But when I use add I get the next screen but the record is not added. What do I miss ? Btw is the same setup with a query possible with SQLFORM.smartgrid ? With regards, Mike Veltman With regards, Mike Veltman
[web2py] Re: How about auth.define_tables(..., format='...')? [SOLVED]
On Nov 1, 7:54 pm, Anthony abasta...@gmail.com wrote: On Tuesday, November 1, 2011 6:20:57 AM UTC-4, Massimo Di Pierro wrote: I am not sure I understand the proposal. You can override the format: db.mytable._format = '%(name)s' db.mytable._format = lambda record: SPAN(record.first_name) FYI, the above now works in trunk, but not in stable (previously, existing keys of Table objects could not be changed -- now they can if they start with an underscore). In stable, the above would have to be preceded by db.mytable.pop('_format'). Anthony That pop() does the trick right now. Thanks gentlemen! Ray
[web2py] Re: lexical scanner
oh yeah, that is working awesome. sometimes coding is better then eating. thanx so much limedrop. have a great day. lucas
[web2py] Controller result: assign to Javascript variable
I am trying a custom AJAX like functionality. I know, AJAX function in web2py is there. But i need to populate values of html elements by their IDs. Not just show the result in a 'target' DIV. simplified code follows [Controller] def lod(): do some processing on request.vars.i1 and calculate emp_id return emp_id [/Controller] [View] {{extend 'layout.html'}} input type='text' value='type a value' id='i1' name='i1' / a href='#' onclick='populate()'Load result via AJAX /a br /br / input type='text' id='i2' name='i2' value='result here' / script function populate(){ var empid = {{URL(('lod'))}}; window.alert(empid); $('#i2').val(empid); } /script [/View] Any suggestion on the same? Thanks, Vineet
[web2py] AJAX custom code
I am trying a custom AJAX like functionality. I know, AJAX function in web2py is there. But i need to populate the values of html elements by their IDs. Not just show the result in a 'target' DIV. 1) Upon clicking the link, controller action is performed (via a 'onclick' js handler) using value from input id='i1'. 2) Returned result is assigned to a javascript variable. 3) Set the value of input id='i2' equal to that js-variable simplified code follows [Controller] def lod(): do some processing on request.vars.i1 and calculate emp_id return emp_id [/Controller] [View] {{extend 'layout.html'}} input type='text' value='type a value' id='i1' name='i1' / a href='#' onclick='populate()'Load result via AJAX /a br /br / input type='text' id='i2' name='i2' value='result here' / script function populate(){ var empid = {{URL(('lod'))}}; window.alert(empid); $('#i2').val(empid); } /script [/View] input with id='i2' is not getting populated. Messagebox is also blank (no value of 'empid') I am 100 % sure that 'empid' is returned from the controller. Any suggestion on the same highly appreciated. Thanks, Vineet
[web2py] Re: upload
ok, thank you for completely clarifying for me. it makes sense and it is a matter or relative perspective. now i am straight. one additional question, the response.download function confuses me still. i get it that it is download to the client computer. what i don't get is its parameters. response.download(request, db) i get that it pulls the last argument from the request args to get the filename. but this db parameter makes no sense to me because the db may have multiple tables and how does it know which table to pulll the file from? also, what if you have two fields in your files table, one for the name of the file and the other for the extension, like pdf, how will response.download know which record to access to download the correct file? so, how does response.download know which table and which row to pull the file from the database (db) to download it to the client? thank you in advance, lucas
[web2py] Re: Passing values to CRUD create from controller
Hi, I've a seemingly workable solution for this, but it's hardly elegant. In my model, for the property_id field I have: - ,default=session.last_parent_id ,writable=False ,readable=True ...and in my controller: - @auth.requires_login() def property_detail_insert(): form=crud.create(db.property_detail) session.last_parent_id=request.args(1) return dict(form=form) ...which works, but displays the parent ID in the form. Is there a more elegant solution using CRUD? -- Regards, PhilK 'a bell is a cup...until it is struck'
[web2py] [Web2py] Stop the processing of the models midway
Hi, I am a developer for Sahana Eden . I am facing the following problem :- A variable is defined in the second file of the models of the web2py-application ( there are more than 40 files in the models folder). Depending on the value of that variable I wanted to stop the further execution of the files in model and run the controllers i.e run the controllers without completely processing all the 40 files instead just after processing 2 files. Please suggest us a way to implement this. Thank You Anubhav Aggarwal
Re: [web2py] Re: SSL Error
Context: Windows Did not tried yet using the source code but using 1.98 i get the same errors but the server never crashes... 2011/10/27 Ross Peoples ross.peop...@gmail.com I don't think so. I access my dev machine using the IP all the time. Can you try using the source code version instead of the binary and see if that makes a difference?
[web2py] Problem while Importing a csv file into the database
Hi , Step1: Created table headers(cloumns) in the excel file EXACTLY SIMILAR TO THOSE which are present in the database
[web2py] web2py.com down?
Hi, is there some problem with web2py site? I just started new project, returned to web2py and need a book for a while in the re-beginning..:D Michal
[web2py] Problem while Importing a csv file into the database
Hi, I am facing the problem while importing csv file. Please find the steps below that i am following. Step1: Created table headers(cloumns) in the excel file EXACTLY SIMILAR to those which are present in the database table Step2: Inserted some dummy data as rows in the columns. All the validations are taken care of while creating/filling out the dummy rows. For example: Inserted values in rows where the validation on field was not null =True Step3: Saved the file with .csv extension Step4: Tried to import this .csv file into the database using / appadmin It is been observed that no data has been inserted into the database table. Also there was no error message displayed. Questions: 1. What is the correct way to create the CSV file so that the file can be imported using appadmin feature. 2. How to debug the error in case data is not reflected after importing the .csv file? 3. Is there any particular steps that needs to be followed while importing the file. Please share the documentation/reference in case it is available.
[web2py] Windows7 python2.7 SQLite web2py
Hello, I'm facing a pb with windows 7/SQLite (current)/python2.7 I'm working on local and just lunch web2py.py with python2.7 nearly 50% of my request have the folloowing issue : Traceback (most recent call last): File C:\Users\user11\Desktop\web2py\gluon\restricted.py, line 194, in restricted exec ccode in environment File C:/Users/user11/Desktop/web2py/applications/xxx/models/db.py http://192.168.1.102/admin/default/edit/SAMAT/models/db.py, line 102, in module Field(GA_NUMG,integer) File C:\Users\user11\Desktop\web2py\gluon\dal.py, line 4491, in define_table polymodel=polymodel) File C:\Users\user11\Desktop\web2py\gluon\dal.py, line 700, in create_table fake_migrate=fake_migrate) File C:\Users\user11\Desktop\web2py\gluon\dal.py, line 801, in migrate_table tfile = self.file_open(table._dbt, 'w') File C:\Users\user11\Desktop\web2py\gluon\dal.py, line 496, in file_open fileobj = open(filename,mode) IOError: [Errno 13] Permission denied: 'C:\\Users\\user11\\Desktop\\web2py\\applications\\xxx\\databases\\7220618fff53ed2e8edbb0fe66a230f8_ATGAMME.table' I restarted an appp from scratch from the above config. If I refresh the browser (Last FF)often I can acces once again the result. I checcked with IE8 = same pb Everything is all right I looked in my PC to give all rights in the web2py folder, but i doesn't work either. Does anybody faced the pb ? Any idea to solve this ? Best regards
[web2py] Re: Windows7 python2.7 SQLite web2py
Looks like you've got your own Python installation and are running from source. In that case, do you have http://sourceforge.net/projects/pywin32/ installed? Anthony On Wednesday, November 2, 2011 7:38:11 AM UTC-4, JmiXIII wrote: Hello, I'm facing a pb with windows 7/SQLite (current)/python2.7 I'm working on local and just lunch web2py.py with python2.7 nearly 50% of my request have the folloowing issue : Traceback (most recent call last): File C:\Users\user11\Desktop\web2py\gluon\restricted.py, line 194, in restricted exec ccode in environment File C:/Users/user11/Desktop/web2py/applications/xxx/models/db.py http://192.168.1.102/admin/default/edit/SAMAT/models/db.py, line 102, in module Field(GA_NUMG,integer) File C:\Users\user11\Desktop\web2py\gluon\dal.py, line 4491, in define_table polymodel=polymodel) File C:\Users\user11\Desktop\web2py\gluon\dal.py, line 700, in create_table fake_migrate=fake_migrate) File C:\Users\user11\Desktop\web2py\gluon\dal.py, line 801, in migrate_table tfile = self.file_open(table._dbt, 'w') File C:\Users\user11\Desktop\web2py\gluon\dal.py, line 496, in file_open fileobj = open(filename,mode) IOError: [Errno 13] Permission denied: 'C:\\Users\\user11\\Desktop\\web2py\\applications\\xxx\\databases\\7220618fff53ed2e8edbb0fe66a230f8_ATGAMME.table' I restarted an appp from scratch from the above config. If I refresh the browser (Last FF)often I can acces once again the result. I checcked with IE8 = same pb Everything is all right I looked in my PC to give all rights in the web2py folder, but i doesn't work either. Does anybody faced the pb ? Any idea to solve this ? Best regards
[web2py] Re: web2py.com down?
Yes, looks like it's down: http://www.downforeveryoneorjustme.com/web2py.com
[web2py] Re: Passing values to CRUD create from controller
On Wednesday, November 2, 2011 6:55:41 AM UTC-4, glimmung wrote: Hi, I've a seemingly workable solution for this, but it's hardly elegant. In my model, for the property_id field I have: - ,default=session.last_parent_id ,writable=False ,readable=True ...and in my controller: - @auth.requires_login() def property_detail_insert(): form=crud.create(db.property_detail) session.last_parent_id=request.args(1) return dict(form=form) ...which works, but displays the parent ID in the form. Is there a more elegant solution using CRUD? Does the parent_id have to persist across multiple requests? If so, then storing in session is probably the way to go. If you don't want to have the value appear in the form, you could either use an onvalidation function to populate the value after the form is validated, or you could make it a computed field if you know it will always be populated via a session and/or request variable. Anthony
Re: [web2py] Re: web2py.com down?
Website is back and running... YIPIIIEE Michal On 11/02/2011 01:01 PM, Anthony wrote: Yes, looks like it's down: http://www.downforeveryoneorjustme.com/web2py.com
[web2py] Re: list of usernames
Dear Anthony, I know, you explained me they were supposed to be identical. In both cases, I can fill in the form the same way, but when you submit the form and that a row in the database is added, the title column is filled in, but not the tosomeone column. Archibald On 2 nov, 03:39, Anthony abasta...@gmail.com wrote: On Tuesday, November 1, 2011 7:15:32 PM UTC-4, Archibald Linx wrote: @auth.requires_login() def write_message(): form = SQLFORM(db.message) if form.process().accepted: response.flash = 'Got it' return dict(form=form) then although the title field is filled, the tosomeone field is not. The tosomeone field remains empty. So the problem came from form.process().accepted, without me noticing it at first. By keeping if form.accepts(request.vars, session):, I solved my problem. if form.process().accepted and if form.accepts(request.vars, session) are supposed to be identical. Can you better explain how the behavior differs. You say the tosomeone field remains empty -- what does that mean? It's a create form, so it should start out empty, no? Are you saying you can't fill it in? Or it doesn't show the multi-select widget? Anthony
Re: [web2py] Re: Passing values to CRUD create from controller
Hi Anthony, On 02/11/2011 12:06, Anthony wrote: Does the parent_id have to persist across multiple requests? If so, then storing in session is probably the way to go. If you don't want to have the value appear in the form, you could either use an onvalidation function to populate the value after the form is validated, or you could make it a computed field if you know it will always be populated via a session and/or request variable. No, it doesn't need to persist - that's part of my reason for feeling that this is inelegant. In fact, I have to set the session value in each request, to ensure that the fresh value is used and not one from a previous request. This app uses nested components, so there may be more than one of these structures in a single page load. I'll experiment with onvalidation, which seems cleaner. Failing that compute (which I hadn't even considered) seems more natural than default here. -- Regards, PhilK 'a bell is a cup...until it is struck'
[web2py] Re: upload
On Wednesday, November 2, 2011 6:20:55 AM UTC-4, lucas wrote: one additional question, the response.download function confuses me still. i get it that it is download to the client computer. what i don't get is its parameters. response.download(request, db) i get that it pulls the last argument from the request args to get the filename. but this db parameter makes no sense to me because the db may have multiple tables and how does it know which table to pulll the file from? Yeah, I'm working on explaining that better in the book. Note, when the file is initially uploaded, the new name it is given starts with tablename.fieldname of the upload field, so it extracts the table and field name from the filename itself. It then uses that to find the relevant upload field in the DB, and the only thing it needs from that field is the upload folder where it can find the file. also, what if you have two fields in your files table, one for the name of the file and the other for the extension, like pdf, how will response.download know which record to access to download the correct file? so, how does response.download know which table and which row to pull the file from the database (db) to download it to the client? Note, when you upload a file, you don't have to store the filename or extension separately in the table (though you can if you need to for some reason). During the upload process, web2py encodes the original filename into the new filename (which it then decodes upon download), and it preserves the extension as well. So, when you upload a file called 'myfile.pdf' into upload field 'myfield' in 'mytable', the new filename will be: mytable.myfield.[16-char-uuid].[base16-encoded 'myfile'].pdf response.download extracts the table and field name, decodes the original filename, and identifies the upload folder associated with mytable.myupload (which is an attribute of the field itself -- it defaults to /app/uploads, but can be set differently via the field's 'uploadfolder' argument). Anthony
[web2py] Re: Windows7 python2.7 SQLite web2py
Yep I have my own python installation and are running from source Not I do not have pywin32 installed But I do not remember to have it installed on my previous computer. Anyway I'll try it thanks
[web2py] Re: AJAX custom code
On Wednesday, November 2, 2011 6:14:04 AM UTC-4, Vineet wrote: script function populate(){ var empid = {{URL(('lod'))}}; That's not how Ajax works -- you don't just assign a URL to a variable. Instead, you have to explicitly make an Ajax call. If the web2py ajax() function isn't suitable, you can use the jQuery .ajax() function (http://api.jquery.com/jQuery.ajax/). However, I think you can use the web2py ajax() function in this case, specifying the target as :eval. That tells the function that the action will be returning some Javascript to be executed. So, do: onclick=ajax({{=URL('lod')}}, ['i1'], ':eval'); and have the lod action return: $('#i2').val('whatever'); Anthony
[web2py] Re: Windows7 python2.7 SQLite web2py
Hello, I have installed pywin32 ofr python27 Seems to work a little better but if I stress my computer on a web page (form for example), I still have the pb. JmiXIII
[web2py] Re: [Web2py] Stop the processing of the models midway
You may also wish to consider using sub-folders for models. all files in models/a/ are executed only for actions in controllers/a.py all files in models/a/b/ are executed only for actions b() in controllers/a.py this is for every a and b.
[web2py] Re: Confused about hidden fields
On Nov 1, 11:11 pm, Omi Chiba ochib...@gmail.com wrote: Thank you for understanding me :) I tried but this code will set the default value if the field exist on the view. I made a simple example. I don't want to show field2 so it's excluded in view using custom form but want to store the value like 'BBB' or 'CCC' before it's inserted into table. This code just leave field2 blank... model db.define_table('mytable', Field('field1'), Field('field2')) controller def index(): form = SQLFORM(db.mytable) form.vars.field2 = 'BBB' This should work to pre-populate the value of field2 with 'BBB' but it seems to be broken in 1.99.2 if form.process().accepted: form.vars.field2 = 'CCC' this has no effect, field2 will not be set to 'CCC' in the DB, the insert has already been done at this point so field2 will be 'BBB' (if it wasn't broken). To change it you have to use onvalidation, see the example in the book. session.flash = 'form accepted' redirect(URL('index')) elif form.errors: response.flash = 'form has errors' return dict(form=form) view {{extend 'layout.html'}} {{=form.custom.begin}} Field1: {{=form.custom.widget.field1}} {{=form.custom.submit}} {{=form.custom.end}} On Nov 1, 6:58 pm, pbreit pbreitenb...@gmail.com wrote: I believe in your controller, before form.process() (or form.accepts), include: form.vars.FFTSCD = 'aaa'
[web2py] SQLFORM.grid columnas a mostrar
Hello list. My question is this, I have a join in my query to the database, you need to show the columns belonging to tables and routes accountcode, here is my code: left = (db.accountcode.on(db.llamados.id_accountcode==db.accountcode.id),db.rutaproveedor.on(db.llamados.id_rutaproveedor==db.rutaproveedor.id),db.rutas.on(db.rutaproveedor.id_rutas==db.rutas.id)) query = (db.llamados.dialstatus=='ANSWER') (db.llamados.inicio=dt1) (db.llamados.inicio=dt2) ## rows=db(query).select(b.ani,a.destino,r.nombre,a.answeredtime,a.inicio,a.valor, left=left) rws=SQLFORM.grid( query, left = left, deletable=False, editable=False, create=False, csv=False, details=False, showbuttontext=False, columns=['accountcode.ani','llamados.destino','llamados.answeredtime','llamados.inicio','llamados.valor'] )
[web2py] Suggested improvements to populate()
I needed to customize the behavior of gluon.contrib.populate.populate(), so I created by version by adding ``values=None`` argument, and this code after the ``elif field.type == 'id': continue``: elif values is not None and values.has_key(fieldname): if callable(values[fieldname]): record[fieldname] = values[fieldname](table, fieldname) else: record[fieldname] = values[fieldname] Brief explanation: for each field a values[fieldname] is checked. If it is callable, the return value of values[fieldname](table, fieldname) is used for the field. Else, directly values[fieldname] is used as field value. BTW: Wouldn't be better to move IUP outside that module, maybe in a pickled shelf file or so? Or, at least, split the dict on multiple lines to avoid having a single line of that length. I don't know which editor are you using, but eclipse takes some minutes to open the file and once opened it becomes unusable; with gedit it's a bit better but still very hard to navigate, due to the too long single line.. [on a Core i7 M620 @2.67 GHz 8Gb RAM machine..] -- Samuele ~redShadow~ Santi redshadow[at]hackzine.org - redshadowhack[at]gmail.com Blog: http://hackzine.org GPG Key signature: 050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933 /me recommends: Squadra Informatica - http://www.squadrainformatica.com - Proud ThinkPad T-Series owner - Registered Linux-User: #440008 * GENTOO User since 1199142000 (2008-01-01) * former DEBIAN SID user Software is like sex: it's better when it's free! -- Linus Torvalds signature.asc Description: This is a digitally signed message part
[web2py] Choose nothing in a drop-down menu
Hello, I would like my users to be able to choose nothing, if they want to, in a drop-down menu. The drop-down menu is generated using SQLFORM. By default the validator does not accept that my users choose nothing. How to change that ? Thank you very much, Bianca
Re: [web2py] Re: Confused about hidden fields
Hi, On 02/11/2011 13:59, DenesL wrote: form.vars.field2 = 'BBB' This should work to pre-populate the value of field2 with 'BBB' but it seems to be broken in 1.99.2 I'm so glad you said that - this was one of the things I tried in troubleshooting my Passing values to CRUD create from controller issue, and I was completely baffled as to why it was not working! -- Regards, PhilK 'a bell is a cup...until it is struck'
[web2py] Re: Choose nothing in a drop-down menu
You can try IS_EMPTY_OR(IS_IN_DB(...)) (also works with IS_IN_SET). You might also want to specify a 'zero' option. See http://web2py.com/book/default/chapter/07#Validators. On Wednesday, November 2, 2011 10:35:26 AM UTC-4, Bianca Cadaveri wrote: Hello, I would like my users to be able to choose nothing, if they want to, in a drop-down menu. The drop-down menu is generated using SQLFORM. By default the validator does not accept that my users choose nothing. How to change that ? Thank you very much, Bianca
[web2py] Re: AJAX custom code
thanks for replying. I tried this-- [Controller] def lod(): x = 'This is a val' return $('#i2').val(x); [/Controller] [View] {{extend 'layout.html'}} input type='text' value='type a value' id='i1' name='i1' / a href='#' onclick=ajax({{=URL('lod')}}, ['i1'], ':eval'); Load result via AJAX /a br /br / input type='text' id='i2' name='i2' value='result here' / [/View] But the input with id='i2' is not populated. Is something wrong or missing in the code? ---Vineet On Nov 2, 6:12 pm, Anthony abasta...@gmail.com wrote: On Wednesday, November 2, 2011 6:14:04 AM UTC-4, Vineet wrote: script function populate(){ var empid = {{URL(('lod'))}}; That's not how Ajax works -- you don't just assign a URL to a variable. Instead, you have to explicitly make an Ajax call. If the web2py ajax() function isn't suitable, you can use the jQuery .ajax() function (http://api.jquery.com/jQuery.ajax/). However, I think you can use the web2py ajax() function in this case, specifying the target as :eval. That tells the function that the action will be returning some Javascript to be executed. So, do: onclick=ajax({{=URL('lod')}}, ['i1'], ':eval'); and have the lod action return: $('#i2').val('whatever'); Anthony
[web2py] problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
Hi, I'm using web2py latest trunk on win7. As soon as I applied the following changeset: ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch I got errors both in shell and web requests ... auth.settings.hmac_key = 'sha512:5fd2a4d2-d703-476c-8184-800b84e453b8' File C:\web2py\gluon\storage.py, line 199, in __setattr__ raise SyntaxError, 'setting key \'%s\' does not exist' % key SyntaxError: setting key 'hmac_key' does not exist If I reload the immediate prior changeset, everything works ok again. Based on what I see in this change, you are now removing the Storage key also via __setitem__ (in addition to __setattr__). But I need a way to assign None to a Storage key, for which I was using: mystorage['key'] = None (which did assign None and did not remove the key). Now I would have no way to assign a None value to a Storage key?. Plus the above error I get in Settings. Can this change be reverted?, or what do you recommend instead?. Thanks, Carlos
[web2py] Re: AJAX custom code
On Wednesday, November 2, 2011 10:49:04 AM UTC-4, Vineet wrote: thanks for replying. I tried this-- [Controller] def lod(): x = 'This is a val' return $('#i2').val(x); Note, the returned value is simply a string from the perspective of the lod() function, so 'x' in that string is literally just the letter 'x' -- it is not replaced with the value of your x variable. Also, you need to put the value in .val() in quotes. You want: return $('#i2').val('%s'); % x That will put the actual value of x inside quotes inside .val(). Anthony
[web2py] Re: AJAX custom code
You are right. To clear any ambiguity, I did this -- return $('#i2').val('Vineet'); But still, no success. Any other hint? ---Vineet On Nov 2, 8:15 pm, Anthony abasta...@gmail.com wrote: On Wednesday, November 2, 2011 10:49:04 AM UTC-4, Vineet wrote: thanks for replying. I tried this-- [Controller] def lod(): x = 'This is a val' return $('#i2').val(x); Note, the returned value is simply a string from the perspective of the lod() function, so 'x' in that string is literally just the letter 'x' -- it is not replaced with the value of your x variable. Also, you need to put the value in .val() in quotes. You want: return $('#i2').val('%s'); % x That will put the actual value of x inside quotes inside .val(). Anthony
[web2py] interget or string to date
This is more like python question but jj.J2NSD is integer and has value = 2030 (MMDD) I want to set the value as default value of FFNSD which is 'date' type. Field('FFNSD', 'date'), I think I need to import datetime and convert from integer or stiring. Is anyone know easy way to do it ? This doesn't work because it set string to date... db.FEDEXFORM.FFNSD.default = str(jj.J2NSD)[0:4]+-+str(jj.J2NSD) [4:6]+-+str(jj.J2NSD)[6:8]
[web2py] Re: problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
How are you making use of None values in Storage keys? On Wednesday, November 2, 2011 10:59:01 AM UTC-4, Carlos wrote: Hi, I'm using web2py latest trunk on win7. As soon as I applied the following changeset: ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch I got errors both in shell and web requests ... auth.settings.hmac_key = 'sha512:5fd2a4d2-d703-476c-8184-800b84e453b8' File C:\web2py\gluon\storage.py, line 199, in __setattr__ raise SyntaxError, 'setting key \'%s\' does not exist' % key SyntaxError: setting key 'hmac_key' does not exist If I reload the immediate prior changeset, everything works ok again. Based on what I see in this change, you are now removing the Storage key also via __setitem__ (in addition to __setattr__). But I need a way to assign None to a Storage key, for which I was using: mystorage['key'] = None (which did assign None and did not remove the key). Now I would have no way to assign a None value to a Storage key?. Plus the above error I get in Settings. Can this change be reverted?, or what do you recommend instead?. Thanks, Carlos
[web2py] Re: interget or string to date
Recently, I wrote this function for my purpose. See if this helps you. Assuming that argument 'dte' input format is -- 03-11-2011 [CODE] import datetime, string def str_to_dt(dte): dte = str(dte) dte = string.strip(dte) if len(dte) == 10: y = int(dte[6:]) m = int(dte[3:5]) d = int(dte[:2]) return datetime.date(y, m, d) [/CODE] This returns output in python datetime.date format. --Vineet On Nov 2, 8:19 pm, Omi Chiba ochib...@gmail.com wrote: This is more like python question but jj.J2NSD is integer and has value = 2030 (MMDD) I want to set the value as default value of FFNSD which is 'date' type. Field('FFNSD', 'date'), I think I need to import datetime and convert from integer or stiring. Is anyone know easy way to do it ? This doesn't work because it set string to date... db.FEDEXFORM.FFNSD.default = str(jj.J2NSD)[0:4]+-+str(jj.J2NSD) [4:6]+-+str(jj.J2NSD)[6:8]
Re: [web2py] problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
On Nov 2, 2011, at 7:59 AM, Carlos wrote: I'm using web2py latest trunk on win7. As soon as I applied the following changeset: ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch I got errors both in shell and web requests ... auth.settings.hmac_key = 'sha512:5fd2a4d2-d703-476c-8184-800b84e453b8' File C:\web2py\gluon\storage.py, line 199, in __setattr__ raise SyntaxError, 'setting key \'%s\' does not exist' % key SyntaxError: setting key 'hmac_key' does not exist If I reload the immediate prior changeset, everything works ok again. Based on what I see in this change, you are now removing the Storage key also via __setitem__ (in addition to __setattr__). But I need a way to assign None to a Storage key, for which I was using: mystorage['key'] = None (which did assign None and did not remove the key). Now I would have no way to assign a None value to a Storage key?. Plus the above error I get in Settings. Can this change be reverted?, or what do you recommend instead?. I'll take a look. The patch was intended to make Storage behave consistently with respect to access through attributes and through keys, mainly so that s.key and s['key'] would behave the same way--that is, both yield None when the key isn't present in the underlying dict. The behavior on storing None is along those lines: s.key = None deletes the key+value from the dict, and the patch makes s['key'] = None do the same thing. I'm frankly not sure that deletion is a great idea in any case; deletion should IMO be explicit. Finally, the settings error appears to be a bug. I'll send Massimo a patch ASAP to revert the new deletion and fix the error; I need to add a case to the unit test.
Re: [web2py] Re: [Web2py] Stop the processing of the models midway
Thanks for the reply You may also wish to consider using sub-folders for models. all files in models/a/ are executed only for actions in controllers/a.py Actually we wanted to execute most of the models for all the controllers except this particular controller which needs only 2 files of the models . Therefore we put the files in the common folder ( models/ ) . Could you please suggest any other way to control the execution of the files in the models. Thank You Anubhav Aggarwal
[web2py] Hardware Requirements for Deployment
I've been asked by my colleagues to enumerate all hardware requirements for deploying a server running web2py. My question is, how do I even begin to calculate the requirements for the architecture, storage space, memory, etc.? For architecture, am I basically stuck with x86? For storage, is the only consideration going to be the database? For memory, do I basically run the server with users and profile the memory usage?
Re: [web2py] Re: problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
On Nov 2, 2011, at 8:20 AM, Anthony wrote: How are you making use of None values in Storage keys? I meant to ask the same thing, actually. I *do* think it's a useful behavior of Python dicts that one can store None as a dictionary value. I struggle sometimes with Objective-C, in which you can't store nil in an NSArray or an NSDictionary. On Wednesday, November 2, 2011 10:59:01 AM UTC-4, Carlos wrote: Hi, I'm using web2py latest trunk on win7. As soon as I applied the following changeset: ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch I got errors both in shell and web requests ... auth.settings.hmac_key = 'sha512:5fd2a4d2-d703-476c-8184-800b84e453b8' File C:\web2py\gluon\storage.py, line 199, in __setattr__ raise SyntaxError, 'setting key \'%s\' does not exist' % key SyntaxError: setting key 'hmac_key' does not exist If I reload the immediate prior changeset, everything works ok again. Based on what I see in this change, you are now removing the Storage key also via __setitem__ (in addition to __setattr__). But I need a way to assign None to a Storage key, for which I was using: mystorage['key'] = None (which did assign None and did not remove the key). Now I would have no way to assign a None value to a Storage key?. Plus the above error I get in Settings. Can this change be reverted?, or what do you recommend instead?. Thanks, Carlos
[web2py] Re: Windows7 python2.7 SQLite web2py
Hello, I confirm that pywin32 doesn't help in this issue. I've searched on the web but did not find any peaple facing this pb with sqlite and windows7. Yet I nearly bet that if i use win xp evferything is all right and i cannot figure nobody has already faced this pb ... sic JmiXIII
Re: [web2py] Re: problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
On Nov 2, 2011, at 8:20 AM, Anthony wrote: How are you making use of None values in Storage keys? It turns out that Settings depends on that behavior (note its last line). Auth.__init__ sets auth.settings.hmac_key to None by default, and then sets lock_keys. The presence of the None value (or at least *some* value) is what allows the user to later set a new value for hmac_key. So I'll revert the __setitem__ change, I guess, but keep the __getitem__ change. On Wednesday, November 2, 2011 10:59:01 AM UTC-4, Carlos wrote: Hi, I'm using web2py latest trunk on win7. As soon as I applied the following changeset: ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch I got errors both in shell and web requests ... auth.settings.hmac_key = 'sha512:5fd2a4d2-d703-476c-8184-800b84e453b8' File C:\web2py\gluon\storage.py, line 199, in __setattr__ raise SyntaxError, 'setting key \'%s\' does not exist' % key SyntaxError: setting key 'hmac_key' does not exist If I reload the immediate prior changeset, everything works ok again. Based on what I see in this change, you are now removing the Storage key also via __setitem__ (in addition to __setattr__). But I need a way to assign None to a Storage key, for which I was using: mystorage['key'] = None (which did assign None and did not remove the key). Now I would have no way to assign a None value to a Storage key?. Plus the above error I get in Settings. Can this change be reverted?, or what do you recommend instead?. Thanks, Carlos
Re: [web2py] problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
Hi, I'm using Storage objects throughout my code, and compare vs None values to perform certain specific actions. Thanks!, Carlos
[web2py] Re: Windows7 python2.7 SQLite web2py
I'm on Windows 7 with Python 2.7 32-bit and have never had this problem. On Wednesday, November 2, 2011 11:35:43 AM UTC-4, JmiXIII wrote: Hello, I confirm that pywin32 doesn't help in this issue. I've searched on the web but did not find any peaple facing this pb with sqlite and windows7. Yet I nearly bet that if i use win xp evferything is all right and i cannot figure nobody has already faced this pb ... sic JmiXIII
[web2py] Re: Serving dynamic HTML files
These files can appear ANYWHERE on the file system. I do not know in advance, as the user can add directories for the input (and output) data at runtime via configuration. So, I need a fully dynamic solution that I can tweak programmatically at runtime. Your solution (creating links under a path served by Apache) is similar to something I already tried (a path under static/). What I'd really love is to be able to have a routes module I could talk to from the controllers, or one that called a function in my controller to get the file name to read given a URL. On Nov 1, 8:07 pm, ~redShadow~ redsha...@hackzine.org wrote: On Tue, 2011-11-01 at 19:54 -0700, Anthony wrote: If these are purely static files, why do you need web2py to serve them? Can't you set up your web server to serve them from where they are, or do you only have web2py's built-in server available (if so, maybe you can run a separate instance of Rocket using the fs method:http://packages.python.org/rocket/methods.html#fs)? +1 Plus, if you are running web2py via apache, my suggestion is something like this: - Configure an alias (``Alias /reports /path/to/reports``) in the virtualhost configuration - Configure in your app that ``reports_url = /reports/`` and ``reports_path = /path/to/reports`` - Browse files into reports_path and then link them using ``posixpath.join(reports_url, 'path/to/file')`` [posixpath uses UNIX file names, so it joins using '/'; only on Unix platforms (a part from macosx..?) os.path == posixpath] -- Samuele ~redShadow~ Santi redshadow[at]hackzine.org - redshadowhack[at]gmail.com Blog:http://hackzine.org GPG Key signature: 050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933 /me recommends: Squadra Informatica -http://www.squadrainformatica.com - Proud ThinkPad T-Series owner - Registered Linux-User: #440008 * GENTOO User since 1199142000 (2008-01-01) * former DEBIAN SID user Software is like sex: it's better when it's free! -- Linus Torvalds signature.asc 1KViewDownload
Re: [web2py] problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
On Wednesday, November 2, 2011 11:46:49 AM UTC-4, Carlos wrote: Hi, I'm using Storage objects throughout my code, and compare vs None values to perform certain specific actions. In your code, can you use the attribute access method, which will return None when the attribute doesn't exist: myobj.mykey is None will be true if mykey doesn't exist. Or do you need to use the myobj['mykey'] method because the key is stored in a variable or something like that? In the latter case, I suppose there are other possibilities, such as mykey in myobj Thanks!, Carlos
[web2py] Re: Choose nothing in a drop-down menu
Thank you very much ! Could I also ask if it is possible to forbid one specific value for a field ? BC On 2 nov, 15:45, Anthony abasta...@gmail.com wrote: You can try IS_EMPTY_OR(IS_IN_DB(...)) (also works with IS_IN_SET). You might also want to specify a 'zero' option. Seehttp://web2py.com/book/default/chapter/07#Validators. On Wednesday, November 2, 2011 10:35:26 AM UTC-4, Bianca Cadaveri wrote: Hello, I would like my users to be able to choose nothing, if they want to, in a drop-down menu. The drop-down menu is generated using SQLFORM. By default the validator does not accept that my users choose nothing. How to change that ? Thank you very much, Bianca
[web2py] Re: Windows7 python2.7 SQLite web2py
I also have no problem. Windows 7 64bit Python 2.7 32 bit (64-bit version gave me problems) Pywin 32-bit Paolo
[web2py] ID Encoding oddity
Hi, Where I have a next in CRUD create/update, rather than the [id] substring being replaced by the ID of the created/updated record, I'm seeing %5Bid%5D. My first question is why?, and that leads me to ask how I can refer to the ID if I use the URL helper here rather than a simple string? -- Regards, PhilK 'a bell is a cup...until it is struck'
Re: [web2py] problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
Hi Anthony, One example is to pass an Storage object to form.accepts, containing None values. Carlos
Re: [web2py] problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
On Nov 2, 2011, at 9:09 AM, Carlos wrote: One example is to pass an Storage object to form.accepts, containing None values. It's a closed issue anyway, since Settings (and who knows what else) depends on it. I'm sure it's too late now, for compatibility reasons, but I think that deletes should be explicit in all cases.
Re: [web2py] Re: Choose nothing in a drop-down menu
In that case you have to pass a set instead of db to IS_IN_DB look in the book it clear... Richard On Wed, Nov 2, 2011 at 11:55 AM, Bianca Cadaveri biancacadav...@gmail.comwrote: Thank you very much ! Could I also ask if it is possible to forbid one specific value for a field ? BC On 2 nov, 15:45, Anthony abasta...@gmail.com wrote: You can try IS_EMPTY_OR(IS_IN_DB(...)) (also works with IS_IN_SET). You might also want to specify a 'zero' option. Seehttp://web2py.com/book/default/chapter/07#Validators. On Wednesday, November 2, 2011 10:35:26 AM UTC-4, Bianca Cadaveri wrote: Hello, I would like my users to be able to choose nothing, if they want to, in a drop-down menu. The drop-down menu is generated using SQLFORM. By default the validator does not accept that my users choose nothing. How to change that ? Thank you very much, Bianca
[web2py] Re: Windows7 python2.7 SQLite web2py
May I send someone my app to check on a windows7 + python2.7 + sqlite to check if this is an os/computer pb or linked to my app/database ? What i cannot understand is why after 2 or more attemps it suddenly works it really seems a randomly pb
Re: [web2py] Hardware Requirements for Deployment
I think it all depend of your needs (number of user, $$)... A single virtual machine under ubuntu can easily run postgres or mysql, apache and web2py with reasonable performance from 1 up to 50 users that need to acces your app once in a wild... If your audience is bigger then that you will maybe need a database dedicated server and apache + web2py server to speed thing up a bit. And eventually if you plan to dominate the world you will have to go through redondance and add as many server you need to answer the demand you have... It all depend also about the kind and amount of data you have to serve. Richard On Wed, Nov 2, 2011 at 11:28 AM, Harshad hash0...@gmail.com wrote: I've been asked by my colleagues to enumerate all hardware requirements for deploying a server running web2py. My question is, how do I even begin to calculate the requirements for the architecture, storage space, memory, etc.? For architecture, am I basically stuck with x86? For storage, is the only consideration going to be the database? For memory, do I basically run the server with users and profile the memory usage?
[web2py] Re: Serving dynamic HTML files
Certainly there is s simpler way to talk to an already running instance of rocket (mine) and tell it to serve more static files? I could also do it via apache, if I could talk to apache and tell it to serve from locations not listed in its config. I need to do this at runtime, though. On Nov 1, 7:54 pm, Anthony abasta...@gmail.com wrote: On Tuesday, November 1, 2011 5:48:12 PM UTC-4, John Duddy wrote: Unfortunately, no. I might be able to create soft links under static to those directories, making up a guid each time for the name. I was hoping for a more elegant solution. If these are purely static files, why do you need web2py to serve them? Can't you set up your web server to serve them from where they are, or do you only have web2py's built-in server available (if so, maybe you can run a separate instance of Rocket using the fs method:http://packages.python.org/rocket/methods.html#fs)?
[web2py] Re: Windows7 python2.7 SQLite web2py
Can you provide a packed .w2p web2py application? Paolo
[web2py] Re: Windows7 python2.7 SQLite web2py
I'll give it a try. On Wednesday, November 2, 2011 12:18:54 PM UTC-4, JmiXIII wrote: May I send someone my app to check on a windows7 + python2.7 + sqlite to check if this is an os/computer pb or linked to my app/database ? What i cannot understand is why after 2 or more attemps it suddenly works it really seems a randomly pb
[web2py] Re: Serving dynamic HTML files
Well, there's always this option: https://groups.google.com/d/msg/web2py/_GohKTJhn5c/KkeQzH1xRf0J On Wednesday, November 2, 2011 11:53:05 AM UTC-4, John Duddy wrote: These files can appear ANYWHERE on the file system. I do not know in advance, as the user can add directories for the input (and output) data at runtime via configuration. So, I need a fully dynamic solution that I can tweak programmatically at runtime. Your solution (creating links under a path served by Apache) is similar to something I already tried (a path under static/). What I'd really love is to be able to have a routes module I could talk to from the controllers, or one that called a function in my controller to get the file name to read given a URL. On Nov 1, 8:07 pm, ~redShadow~ reds...@hackzine.org wrote: On Tue, 2011-11-01 at 19:54 -0700, Anthony wrote: If these are purely static files, why do you need web2py to serve them? Can't you set up your web server to serve them from where they are, or do you only have web2py's built-in server available (if so, maybe you can run a separate instance of Rocket using the fs method:http://packages.python.org/rocket/methods.html#fs)? +1 Plus, if you are running web2py via apache, my suggestion is something like this: - Configure an alias (``Alias /reports /path/to/reports``) in the virtualhost configuration - Configure in your app that ``reports_url = /reports/`` and ``reports_path = /path/to/reports`` - Browse files into reports_path and then link them using ``posixpath.join(reports_url, 'path/to/file')`` [posixpath uses UNIX file names, so it joins using '/'; only on Unix platforms (a part from macosx..?) os.path == posixpath] -- Samuele ~redShadow~ Santi redshadow[at]hackzine.org - redshadowhack[at]gmail.com Blog:http://hackzine.org GPG Key signature: 050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933 /me recommends: Squadra Informatica -http://www.squadrainformatica.com - Proud ThinkPad T-Series owner - Registered Linux-User: #440008 * GENTOO User since 1199142000 (2008-01-01) * former DEBIAN SID user Software is like sex: it's better when it's free! -- Linus Torvalds signature.asc 1KViewDownload
Re: [web2py] problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
On Wednesday, November 2, 2011 12:09:12 PM UTC-4, Carlos wrote: Hi Anthony, One example is to pass an Storage object to form.accepts, containing None values. I see -- so the keys have to actually exist.
[web2py] Re: AJAX custom code
Can you use the browser developer tools to confirm that the ajax request is going out properly, and that the proper value is returned? On Wednesday, November 2, 2011 11:19:09 AM UTC-4, Vineet wrote: You are right. To clear any ambiguity, I did this -- return $('#i2').val('Vineet'); But still, no success. Any other hint? ---Vineet On Nov 2, 8:15 pm, Anthony abas...@gmail.com wrote: On Wednesday, November 2, 2011 10:49:04 AM UTC-4, Vineet wrote: thanks for replying. I tried this-- [Controller] def lod(): x = 'This is a val' return $('#i2').val(x); Note, the returned value is simply a string from the perspective of the lod() function, so 'x' in that string is literally just the letter 'x' -- it is not replaced with the value of your x variable. Also, you need to put the value in .val() in quotes. You want: return $('#i2').val('%s'); % x That will put the actual value of x inside quotes inside .val(). Anthony
Re: [web2py] Re: Serving dynamic HTML files
On Wed, 2011-11-02 at 09:25 -0700, John Duddy wrote: Certainly there is s simpler way to talk to an already running instance of rocket (mine) and tell it to serve more static files? I could also do it via apache, if I could talk to apache and tell it to serve from locations not listed in its config. I need to do this at runtime, though. To serve anything anywhere in the filesystem, you can do something like: Alias /reports / And then append the file path. Of course be aware of the risks of letting users browse the whole filesystem.. If that's in a small intranet to which only trusted people can have access, plus you tweak permissions on filesystem in order to limit where the www-data user can have access, plus limit cgi/php/.. file execution to only some locations, and maybe even add http authentication, this could be a valid solution.. Better if you can restrict more the accessible path, eg. if your users will create reports only in their home dirs, you can use something like: Alias /reports /home And maybe even limit which user can access which directory (there are several ways to do this, depending on where you get the users, etc.) -- Samuele ~redShadow~ Santi redshadow[at]hackzine.org - redshadowhack[at]gmail.com Blog: http://hackzine.org GPG Key signature: 050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933 /me recommends: Squadra Informatica - http://www.squadrainformatica.com - Proud ThinkPad T-Series owner - Registered Linux-User: #440008 * GENTOO User since 1199142000 (2008-01-01) * former DEBIAN SID user Software is like sex: it's better when it's free! -- Linus Torvalds signature.asc Description: This is a digitally signed message part
Re: [web2py] problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
Hi Jonathan, I completely agree about deletes to be explicit in all cases. In fact, Storage.__setattr__ should be changed to not auto-delete on None value, but I guess it's not possible for compatibility reasons?. Thanks again, Carlos
Re: [web2py] problems after changeset # ce20196cd7b895029ed667ecff505987ee83d727 - (ce20196cd7b8) storage patch
On Nov 2, 2011, at 10:06 AM, Carlos wrote: I completely agree about deletes to be explicit in all cases. In fact, Storage.__setattr__ should be changed to not auto-delete on None value, but I guess it's not possible for compatibility reasons?. That's my assumption, yes.
[web2py] Re: AJAX custom code
Yes. I used Opera Dragonfly IE Developer Tools. It doesn't show any js error. After clicking the link also, no error. How Where do I check the sent returned values? (in the developer tools or in Dragonfly) Thanks, Vineet On Nov 2, 9:45 pm, Anthony abasta...@gmail.com wrote: Can you use the browser developer tools to confirm that the ajax request is going out properly, and that the proper value is returned? On Wednesday, November 2, 2011 11:19:09 AM UTC-4, Vineet wrote: You are right. To clear any ambiguity, I did this -- return $('#i2').val('Vineet'); But still, no success. Any other hint? ---Vineet On Nov 2, 8:15 pm, Anthony abas...@gmail.com wrote: On Wednesday, November 2, 2011 10:49:04 AM UTC-4, Vineet wrote: thanks for replying. I tried this-- [Controller] def lod(): x = 'This is a val' return $('#i2').val(x); Note, the returned value is simply a string from the perspective of the lod() function, so 'x' in that string is literally just the letter 'x' -- it is not replaced with the value of your x variable. Also, you need to put the value in .val() in quotes. You want: return $('#i2').val('%s'); % x That will put the actual value of x inside quotes inside .val(). Anthony- Hide quoted text - - Show quoted text -
Re: [web2py] Re: [Web2py] Stop the processing of the models midway
The only other thing I can think of is putting that code in a module. http://web2py.com/book/default/chapter/04?search=module#Accessing-the-API-from-Python-modules But is there a specific reason you want to suppress model execution? Are you running into any sort of problem?
[web2py] Re: AJAX custom code
On Wednesday, November 2, 2011 1:13:46 PM UTC-4, Vineet wrote: Yes. I used Opera Dragonfly IE Developer Tools. It doesn't show any js error. After clicking the link also, no error. How Where do I check the sent returned values? (in the developer tools or in Dragonfly) In IE, Network Start Capturing. Click the link and watch for the Ajax request. If there's no request, then the onclick and/or ajax() function isn't working. If there is a request, select it and go to the detailed view and look at the request headers and body and the response headers and body to make sure the right data went out and was returned. Anthony
[web2py] Fixing request.cid goes AWOL in LOAD with file upload fix from Slice # 113
Hi, Just fixed an irksome problem and wanted to share! I have a component, called with load. In the component is a view of a record with an edit button, linkified using web2py's Ajax trap: - {{=A(XML('button type=buttonEdit Landlord Registration/button'), _href=URL(r=request, c='landlord', f='update', args=['landlord', request.args(1)]), cid=request.cid)}} This pulls the edit form into the component as expected, and the edit form is trapped by web2py and brings the view back up with the edit form. However, at this point cid is no longer in the request (verified with {{=request.cid}}, which throws None), so the Ajax trap fails and I see my bare component. The cause seems to be the fix for file upload in components from slice #113, which warns about the loss of headers. The solution is dead simple - if I specify target='landlord_panel' in the load statement, I can name the target in my linkified button, and all is well: - {{=A(XML('button type=buttonEdit Landlord Registration/button'), _href=URL(r=request, c='landlord', f='update', args=['landlord', request.args(1)]), cid='landlord_panel')}} Hope this helps someone else, as it had me scratching my head for a few minutes... -- Regards, PhilK 'a bell is a cup...until it is struck'
Re: [web2py] Re: Confused about hidden fields
Hello, For hidden field I usually used p style=display : None{{=form.custom.widget}}/p But you can still access the value from code so it depends your needs. JmiXIII
[web2py] Re: AJAX custom code
I did check the network tab in Opera Dragonfly. Upon clicking the ajax link, there is no network activity. Nothing is sent or fetched. In Network tab = url, if I put manually '/appname/ controllername/' and click on Send Request, In response, 'Failed to load URL'. The URL helper, ajax function syntax are correct. I double-checked that. I am wondering what might be wrong ! :-( Vineet On Nov 2, 10:19 pm, Anthony abasta...@gmail.com wrote: On Wednesday, November 2, 2011 1:13:46 PM UTC-4, Vineet wrote: Yes. I used Opera Dragonfly IE Developer Tools. It doesn't show any js error. After clicking the link also, no error. How Where do I check the sent returned values? (in the developer tools or in Dragonfly) In IE, Network Start Capturing. Click the link and watch for the Ajax request. If there's no request, then the onclick and/or ajax() function isn't working. If there is a request, select it and go to the detailed view and look at the request headers and body and the response headers and body to make sure the right data went out and was returned. Anthony
[web2py] Re: Serving dynamic HTML files
That's cool - I'll definitely consider it. Thanks! On Nov 2, 10:03 am, ~redShadow~ redsha...@hackzine.org wrote: On Wed, 2011-11-02 at 09:25 -0700, John Duddy wrote: Certainly there is s simpler way to talk to an already running instance of rocket (mine) and tell it to serve more static files? I could also do it via apache, if I could talk to apache and tell it to serve from locations not listed in its config. I need to do this at runtime, though. To serve anything anywhere in the filesystem, you can do something like: Alias /reports / And then append the file path. Of course be aware of the risks of letting users browse the whole filesystem.. If that's in a small intranet to which only trusted people can have access, plus you tweak permissions on filesystem in order to limit where the www-data user can have access, plus limit cgi/php/.. file execution to only some locations, and maybe even add http authentication, this could be a valid solution.. Better if you can restrict more the accessible path, eg. if your users will create reports only in their home dirs, you can use something like: Alias /reports /home And maybe even limit which user can access which directory (there are several ways to do this, depending on where you get the users, etc.) -- Samuele ~redShadow~ Santi redshadow[at]hackzine.org - redshadowhack[at]gmail.com Blog:http://hackzine.org GPG Key signature: 050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933 /me recommends: Squadra Informatica -http://www.squadrainformatica.com - Proud ThinkPad T-Series owner - Registered Linux-User: #440008 * GENTOO User since 1199142000 (2008-01-01) * former DEBIAN SID user Software is like sex: it's better when it's free! -- Linus Torvalds signature.asc 1KViewDownload
[web2py] How to use this specific widget with a simple FORM ?
Hello, I 'd like to use this great widget (slice 85 http://www.web2pyslices.com/slices/take_slice/85) with a simple form FORM helper. It works great with a SQLFORM but I need to use it (slightly modified) in a FORM. I saw that for this slice (http://www.web2pyslices.com/main/slices/ take_slice/22) , it was necessary to add _class=date to the input field definition (see http://groups.google.com/group/web2py/browse_thread/thread/6bc48492ecde4ee2/842449026c28b152?lnk=gstq=Adding+a+Widget+to+a+simple+FORM%28%29+input%28%29+#842449026c28b152). I just don't know what to do. Can anyone give me a hint ? Thanks in advance for your help Dominique
[web2py] ajax redirect after @auth.requires_login() failed
Hello, is it possible to return json to the calling jQuery.ajax() function after access was denied by decorator @auth.requires_login()? I know there is a possibility to specify a function when authorization/ authentication failed with auth.settings.on_failed_authentication = myFunc and auth.settings.on_failed_authorization = myFunc I put this two lines in model db.py. However, I don't know how to just return json containing a url to which the user should be redirected. Any suggestions are welcome! Thanks, haggis
[web2py] Create different edit link for grid
I was reading the previous post https://groups.google.com/group/web2py/browse_thread/thread/51eed6556ba1b61f/a1f4395b7530192a?lnk=gstq=grid+edit#a1f4395b7530192a but I cannot figure out how to do it with my grid. In args, I want to pass the value of the field called db.PDTFF.FFDNO. How can I do that ? def history(): orders = SQLFORM.grid(db.PDTFF,deletable=False, create=False,csv=False,orderby=~db.PDTFF.id, links = [lambda row: A('Edit',_href=URL(default,next, args=[db.PDTFF.FFDNO]))], fields=[db.PDTFF.id,db.PDTFF.FFTRD,db.PDTFF.FFDNO,db.PDTFF.FFJCSC,db.PDTFF.FFJDNO,db.PDTFF.FFJGNO, db.PDTFF.FFJJDN,db.PDTFF.FFJJGN]) return dict(orders=orders)
[web2py] Re: Confused about hidden fields
Thanks everyone. I'm easy person so I use the CSS to hide it just like JmixIII mentioned. something like this. View script jQuery(function(){ jQuery('.hidden').hide(); }; /script {{extend 'layout.html'}} table {{=form.custom.begin}} trtdField1: {{=form.custom.widget.field1}}/td/tr trtd class=hiddenField2: {{=form.custom.widget.field1}}/td/ tr {{=form.custom.submit}} {{=form.custom.end}} /table On Nov 2, 12:32 pm, JmiXIII sylvn.p...@gmail.com wrote: Hello, For hidden field I usually used p style=display : None{{=form.custom.widget}}/p But you can still access the value from code so it depends your needs. JmiXIII
[web2py] Autocomplete in GAE
Has anybody a solution for this? Autocomplete web2py widget doesn't work in gae. I've been searching in this group archive and I haven't found any solution. Googling gives me some possible solutions, but they are really complex unless you'd be a GAE expert. One of the most attractive things of web2py is that the developer can abstract (mostly) the database, but it seems to me that when using gae, this is not possible. Has anybody else had this kind of problem? Does anybody have a good solution for a good autocomplete widget in gae? I mean, a widget that really search in the database, not a simple combo with a very short list of possible items to show/search. Thanks in advance José L.
[web2py] Re: interget or string to date
Vineet, Thanks for sharing. It works like a charm ! On Nov 2, 10:27 am, Vineet vineet.deod...@gmail.com wrote: Recently, I wrote this function for my purpose. See if this helps you. Assuming that argument 'dte' input format is -- 03-11-2011 [CODE] import datetime, string def str_to_dt(dte): dte = str(dte) dte = string.strip(dte) if len(dte) == 10: y = int(dte[6:]) m = int(dte[3:5]) d = int(dte[:2]) return datetime.date(y, m, d) [/CODE] This returns output in python datetime.date format. --Vineet On Nov 2, 8:19 pm, Omi Chiba ochib...@gmail.com wrote: This is more like python question but jj.J2NSD is integer and has value = 2030 (MMDD) I want to set the value as default value of FFNSD which is 'date' type. Field('FFNSD', 'date'), I think I need to import datetime and convert from integer or stiring. Is anyone know easy way to do it ? This doesn't work because it set string to date... db.FEDEXFORM.FFNSD.default = str(jj.J2NSD)[0:4]+-+str(jj.J2NSD) [4:6]+-+str(jj.J2NSD)[6:8]
[web2py] GAE Python 2.7
1. Does anyone have a Python 2.7 web2py app running on GAE? 2. Ditto, with WSGI rather than CGI? I'm thinking that we need a new handler that's a blend of gaehandler.py and wsgihandler.py.
Re: [web2py] GAE Python 2.7
On Nov 2, 2011, at 12:11 PM, Jonathan Lundell wrote: 1. Does anyone have a Python 2.7 web2py app running on GAE? 2. Ditto, with WSGI rather than CGI? I'm thinking that we need a new handler that's a blend of gaehandler.py and wsgihandler.py. On second thought, would it work to app.yaml to specify a script of gaehandler.wsgiapp?
[web2py] Re: Choose nothing in a drop-down menu
Thank you very much ! BC On 2 nov, 17:30, Anthony abasta...@gmail.com wrote: Try IS_MATCH and specify a regex pattern that will exclude the item you want to forbid. Anthony On Wednesday, November 2, 2011 11:55:28 AM UTC-4, Bianca Cadaveri wrote: Thank you very much ! Could I also ask if it is possible to forbid one specific value for a field ? BC On 2 nov, 15:45, Anthony abas...@gmail.com wrote: You can try IS_EMPTY_OR(IS_IN_DB(...)) (also works with IS_IN_SET). You might also want to specify a 'zero' option. Seehttp://web2py.com/book/default/chapter/07#Validators. On Wednesday, November 2, 2011 10:35:26 AM UTC-4, Bianca Cadaveri wrote: Hello, I would like my users to be able to choose nothing, if they want to, in a drop-down menu. The drop-down menu is generated using SQLFORM. By default the validator does not accept that my users choose nothing. How to change that ? Thank you very much, Bianca
Re: [web2py] Re: [Web2py] Stop the processing of the models midway
Not really a good solution, but you can do in the beggining of every model file. if request.function in ['index', 'another', 'other']: #model code goes here this way you can set which function will execute that model file. On Wed, Nov 2, 2011 at 1:27 PM, anubhav aggarwal anubhav...@gmail.comwrote: Thanks for the reply You may also wish to consider using sub-folders for models. all files in models/a/ are executed only for actions in controllers/a.py Actually we wanted to execute most of the models for all the controllers except this particular controller which needs only 2 files of the models . Therefore we put the files in the common folder ( models/ ) . Could you please suggest any other way to control the execution of the files in the models. Thank You Anubhav Aggarwal -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] POST in services jsonrpc
It's not clear from the book. but will a piece of code like : from gluon.tools import Service service = Service() def call(): session.forget() return service() @service.json def submit(body, age, gender): unique_id = insert_into_my_db(body, age, gender) return dict(unique_id=unique_id) work with a POST request. I know and have tested it with a get request and it works swimmingly, but I'm wondering if it will work with POST.
Re: [web2py] POST in services jsonrpc
On Nov 2, 2011, at 12:35 PM, Raymond Elward wrote: It's not clear from the book. but will a piece of code like : from gluon.tools import Service service = Service() def call(): session.forget() return service() @service.json def submit(body, age, gender): unique_id = insert_into_my_db(body, age, gender) return dict(unique_id=unique_id) work with a POST request. I know and have tested it with a get request and it works swimmingly, but I'm wondering if it will work with POST. I think so, yes. I'm using service.jsonrpc with POST, and it works fine.
[web2py] Re: ajax redirect after @auth.requires_login() failed
On Wednesday, November 2, 2011 2:36:53 PM UTC-4, haggis wrote: Hello, is it possible to return json to the calling jQuery.ajax() function after access was denied by decorator @auth.requires_login()? I know there is a possibility to specify a function when authorization/ authentication failed with auth.settings.on_failed_authentication = myFunc and auth.settings.on_failed_authorization = myFunc I put this two lines in model db.py. However, I don't know how to just return json containing a url to which the user should be redirected. Maybe your on_failed_authorization function could do: raise HTTP(200, 'your_url') Anthony
Re: [web2py] Re: [Web2py] Stop the processing of the models midway
How about something like wrapping all your normal models inside a condition block... if not request.controller in []:
[web2py] Re: Windows7 python2.7 SQLite web2py
Another Thought: Based on the path listed in your Traceback, it looks like you're running it from the desktop. Trying instead installing and running from a root folder. Windows7 may restrict what will execute from the Desktop folder.
[web2py] Re: Image searching - Redirecting Ajax Results to pass to template ??
I think you would pass the list of links to the images and then build the tabletrtdimg src=%s/ On Nov 2, 3:29 am, BrendanC bren...@gmail.com wrote: OK - hope I can make this clear - it's more of a 'how to' design question and not really web2py specific. Imagine a view/template with a container/div that displays a (multipage) image gallery - this is the landing page (prepopulated with random images. The page has a Search sidebar to allow filtering/subselection by tags; names etc. The search performs an Ajax search to find a subset of images and currently retrieves an XML list of matches. What I want to do is refresh the template images display with matches found by the Ajax request. (I don't think XHR can retrieve binary data). The XHR request currently retrieves a list, but what I really need to do here is pass the list on and have the image files updated. Is there a way to do that and/or some examples of this? Any suggestions wold be appreciated!
[web2py] Re: AJAX custom code
The URL has to be in quotes. Also, looks like the second arg to ajax() should be the 'name' attribute of the input field, not the id (though, in this case they are the same). Anthony On Wednesday, November 2, 2011 1:59:48 PM UTC-4, Vineet wrote: I did check the network tab in Opera Dragonfly. Upon clicking the ajax link, there is no network activity. Nothing is sent or fetched. In Network tab = url, if I put manually '/appname/ controllername/' and click on Send Request, In response, 'Failed to load URL'. The URL helper, ajax function syntax are correct. I double-checked that. I am wondering what might be wrong ! :-( Vineet On Nov 2, 10:19 pm, Anthony abas...@gmail.com wrote: On Wednesday, November 2, 2011 1:13:46 PM UTC-4, Vineet wrote: Yes. I used Opera Dragonfly IE Developer Tools. It doesn't show any js error. After clicking the link also, no error. How Where do I check the sent returned values? (in the developer tools or in Dragonfly) In IE, Network Start Capturing. Click the link and watch for the Ajax request. If there's no request, then the onclick and/or ajax() function isn't working. If there is a request, select it and go to the detailed view and look at the request headers and body and the response headers and body to make sure the right data went out and was returned. Anthony
[web2py] Re: [Web2py] Stop the processing of the models midway
You may also wish to consider using sub-folders for models We have our own Conditional Model Loading system to handle not having to load all models all the time. We can't simply use the Web2Py system as we have too many inter-linkages across models/controllers. is there a specific reason you want to suppress model execution? One of the key ones is that the DB definition is defined dynamically from deployment_settings: http://bazaar.launchpad.net/~flavour/sahana-eden/trunk/view/head:/models/00_db.py#L38 These deployment_settings are currently defined in a previous model: http://bazaar.launchpad.net/~flavour/sahana-eden/trunk/view/head:/deployment-templates/models/000_config.py What Anubhav's project is about is creating a web-based utility for creating this file instead of having to edit the text file manually. This cannot proceed with 00_db.py beyond as the DB hasn't been configured yet... Not really a good solution, but you can do in the beginning of every model file. if request.function in ['index', 'another', 'other']: #model code goes here We /could/ actually do this for the websetup, slightly differently: In the 1st model file when we know we're the 1st run hence are to redirect to WebSetup, we do this as a redirect() there (so no further model processing) In every other model file, we could add at the beginning an exclusion when we need to access the WebSetup controller: if request.controller not in [setup]: It would be nice not to have to lose a level of indent in all these files as we're already struggling to keep within the 80 char limit, especially as we lose a bunch from conditional model loads (both option to disable modules also simply loading models only when required) There's no way to simply 'return' from that file continue with the next is there? It would be really sweet to simply have a 'now stop model processing continue to controller' option... Thanks for the ideas :) Fran.
[web2py] Re: web2py.com down?
VPS.net has been doing some maintenance On Nov 2, 7:21 am, Michal Jursa mic...@jursa.cz wrote: Website is back and running... YIPIIIEE Michal On 11/02/2011 01:01 PM, Anthony wrote: Yes, looks like it's down:http://www.downforeveryoneorjustme.com/web2py.com
[web2py] Re: SQLFORM.grid columnas a mostrar
what is the question? On Nov 2, 9:09 am, mmartinez alexra...@gmail.com wrote: Hello list. My question is this, I have a join in my query to the database, you need to show the columns belonging to tables and routes accountcode, here is my code: left = (db.accountcode.on(db.llamados.id_accountcode==db.accountcode.id),db.rutapr oveedor.on(db.llamados.id_rutaproveedor==db.rutaproveedor.id),db.rutas.on(d b.rutaproveedor.id_rutas==db.rutas.id)) query = (db.llamados.dialstatus=='ANSWER') (db.llamados.inicio=dt1) (db.llamados.inicio=dt2) ## rows=db(query).select(b.ani,a.destino,r.nombre,a.answeredtime,a.inicio,a.va lor, left=left) rws=SQLFORM.grid( query, left = left, deletable=False, editable=False, create=False, csv=False, details=False, showbuttontext=False, columns=['accountcode.ani','llamados.destino','llamados.answeredtime','llam ados.inicio','llamados.valor'] )
[web2py] Re: Image searching - Redirecting Ajax Results to pass to template ??
Why not have the Ajax request retrieve new HTML to replace the HTML displaying the images? Your Ajax shouldn't be retrieving actually images, it should just be retrieving HTML img tags with the appropriate references to the image URLs. On Wednesday, November 2, 2011 4:29:55 AM UTC-4, BrendanC wrote: OK - hope I can make this clear - it's more of a 'how to' design question and not really web2py specific. Imagine a view/template with a container/div that displays a (multipage) image gallery - this is the landing page (prepopulated with random images. The page has a Search sidebar to allow filtering/subselection by tags; names etc. The search performs an Ajax search to find a subset of images and currently retrieves an XML list of matches. What I want to do is refresh the template images display with matches found by the Ajax request. (I don't think XHR can retrieve binary data). The XHR request currently retrieves a list, but what I really need to do here is pass the list on and have the image files updated. Is there a way to do that and/or some examples of this? Any suggestions wold be appreciated!
[web2py] Re: ID Encoding oddity
Can you show us your code? which web2py version? On Nov 2, 11:07 am, Philip Kilner phil.kil...@gmail.com wrote: Hi, Where I have a next in CRUD create/update, rather than the [id] substring being replaced by the ID of the created/updated record, I'm seeing %5Bid%5D. My first question is why?, and that leads me to ask how I can refer to the ID if I use the URL helper here rather than a simple string? -- Regards, PhilK 'a bell is a cup...until it is struck'
[web2py] Re: ajax redirect after @auth.requires_login() failed
As I wrote Massimo directly by accident, he answered me via mail: it's not possible. That's a pity. May this be possible in a future release? Otherwise it's difficult to develope an application that works with ajax only. In this case the only way I see to redirect a user after his session timed out is to resign the decorators and check access in each callback function. Are there other ways I don't know? On 2 Nov., 19:36, haggis patr...@mindf.org wrote: Hello, is it possible to return json to the calling jQuery.ajax() function after access was denied by decorator @auth.requires_login()? I know there is a possibility to specify a function when authorization/ authentication failed with auth.settings.on_failed_authentication = myFunc and auth.settings.on_failed_authorization = myFunc I put this two lines in model db.py. However, I don't know how to just return json containing a url to which the user should be redirected. Any suggestions are welcome! Thanks, haggis