[web2py] Re: Using comet sockets
Why have you chosen Tornado for this "comet sockets" experiment? it´s Unix only, right? I'm currently working on a quite similar comet sockets with web2py Project, but I attempt to implement this with hookbox.org which could also be worth a look. On 13 Feb., 22:41, Massimo Di Pierro wrote: > Right now the only examples are in web2py/gluon/contrib/ > comet_messaging.py > > This must be mode more powerful and it is on my todo list. It uses > tornado. It talks to web2py. It is not web2py specific. > > Massimo > > On Feb 13, 3:30 pm, guruyaya wrote: > > > > > > > > > Every since the demo of EMTE, I'm fascinated by the option of using > > comet sockets to do real time processing. Yet I cannot find any > > domestication on the usage of comet sockets in web2py. > > Can you help direct me to anything that has to do with this issue? > > Thanks in advance > > Yair
[web2py] Re: Authorization for Webhooks
I can see the stored data, but I just do not know how to extract the required values, Do I have to unpickle these files somehow, or is there perhaps a more framework-conform-approach to query these two values? I would not like to import external libraries for this. I thought querying user_name/is_logged_in by session_id would be a basic built in functionality... THX Dieter Asman On 13 Feb., 15:54, Massimo Di Pierro wrote: > The session it is the name of the sessions file under app/sessions. It > is a pickle. Try open it and see what is inside. > > On Feb 13, 6:43 am, AsmanCom wrote: > > > > > > > > > Does nobody know, how to query these two values by the given > > session_id (session_id_myapp=127.0.0.1-2b77d424-4e72-4d3f-a0de- > > badbcdbe6a30)? > > > 1. is_logged_in (boolean) > > 2. username or user email (string) > > > I looked in the book, i´ve searched this group, i´ve searched the web, > > but still can´t find any Solution... > > > So could anyone, who knows about the auth-process, please take a look > > at it. > > > Thanks in advance. > > Dieter Asman
[web2py] Re: Authorization for Webhooks
Does nobody know, how to query these two values by the given session_id (session_id_myapp=127.0.0.1-2b77d424-4e72-4d3f-a0de- badbcdbe6a30)? 1. is_logged_in (boolean) 2. username or user email (string) I looked in the book, i´ve searched this group, i´ve searched the web, but still can´t find any Solution... So could anyone, who knows about the auth-process, please take a look at it. Thanks in advance. Dieter Asman
[web2py] Re: Authorization for Webhooks
First things first, Thanks a bunch for your reply. "Can you just read the cookie" Yes: request.cookies "and match it to a session?" I would like to, but I do not know how? "Do these callbacks occur quickly enough that the session has not expired?" Yes. "the callback is not technically "logged in" (it has stolen a cookie)" I dare say it's quite true, but the only thing I still need to know is: How to get these two values by the given session_id, 1. is_logged_in (boolean) 2. username or user email (string) I would be great if Someone could help with this... Thanks On 11 Feb., 18:41, pbreit wrote: > Can you just read the cookie and match it to a session? Do these callbacks > occur quickly enough that the session has not expired? I don't know exactly > how sessions work but I could imagine there's be problems using sessions > with callbacks since the callback is not technically "logged in" (it has > stolen a cookie).
[web2py] Re: Authorization for Webhooks
BTW why does the callbacks with the cookie header not work with web2py just like that? Is this some kind of Security Feature of web2py? Thanks in advance. Dieter Asman On 11 Feb., 13:02, AsmanCom wrote: > I´ve got an Application wich makes (url)callbacks to my web2py app and > All these webhooks have a "Cookie:" header with a value identical to > the browser that caused the request to be initiated. > For for example it calls the web2py Controller with this "Cookie:" > header: > > Cookie: session_id_myapp=127.0.0.1-2b77d424-4e72-4d3f-a0de- > badbcdbe6a30 > > In the called web2py controller I want to make the Authorization for > this call, tried to like that: > > def connect(): > > return response.json([auth.is_logged_in(), {"name": "Test"}]) > > When called with the Browser, it returns: > [true, {"name": "test"}] > > When called by the (url)callback, it returns: > [false, {"name": "test"}] > > In this Controller I can simply grab the session_id: > > def get_session_test(): > > if request.cookies.has_key(response.session_id_name): > value = request.cookies[response.session_id_name].value > return dict(session_id=value) > else: > return False > > How can I authorize these (url)callbacks by session_id? > > I´ve to query two values by the given session_id, > 1. is_logged_in (boolean) > 2. username or user email (string) > > But, how to obtain them? > > Or is there a better way to make the authorization for the > (url)callbacks? > > Thank you in advance. > > Dieter Asman
[web2py] Authorization for Webhooks
I´ve got an Application wich makes (url)callbacks to my web2py app and All these webhooks have a "Cookie:" header with a value identical to the browser that caused the request to be initiated. For for example it calls the web2py Controller with this "Cookie:" header: Cookie: session_id_myapp=127.0.0.1-2b77d424-4e72-4d3f-a0de- badbcdbe6a30 In the called web2py controller I want to make the Authorization for this call, tried to like that: def connect(): return response.json([auth.is_logged_in(), {"name": "Test"}]) When called with the Browser, it returns: [true, {"name": "test"}] When called by the (url)callback, it returns: [false, {"name": "test"}] In this Controller I can simply grab the session_id: def get_session_test(): if request.cookies.has_key(response.session_id_name): value = request.cookies[response.session_id_name].value return dict(session_id=value) else: return False How can I authorize these (url)callbacks by session_id? I´ve to query two values by the given session_id, 1. is_logged_in (boolean) 2. username or user email (string) But, how to obtain them? Or is there a better way to make the authorization for the (url)callbacks? Thank you in advance. Dieter Asman
[web2py] Re: Plugin_JqGrid long-polling
Hi Massimo, Thank you for your attention, the last questions have already been resolved. But now I´ve got a new question :-) I noticed the JqGrid when calling the URL already passing the Parameter "nd: 1289404767209", which is a Timestamp value, it calls JavaScript "new Date (), getTime ().", which returns the number of milliseconds since January 1, 1970. How can I represent this Dateformat in web2py (Model / Controller)? Than I could use this Timestamp to filter the results with an select. THX On 10 Nov., 16:55, mdipierro wrote: > You need to install firebug and check in the console log what is going > on. > > On Nov 10, 9:53 am, AsmanCom wrote: > > > tried it like this: > > > app/models/plugin_jqgrid.py: > > > var server_time=null; > > jQuery(document).ready(function(server_time){jQuery("#% > > (id)s").jqGrid({ > > url:'%(callback)s&server_time'+escape(server_time), > > > app/controllers/plugin_jqgrid.py: > > > def data(): > > sleep(10) > > ... > > test1 = request.vars.server_time or error() > > tablename = request.vars.tablename or error() > > ... > > items = {} > > items['userdata']=request.now > > ... > > __ > > > It seems not working, data is not returned by the controller. > > > On 10 Nov., 16:37, mdipierro wrote: > > > > replace > > > > > > > jQuery(document).ready(function(server_time){jQuery("#% > > > (id)s").jqGrid({ > > > url:'%(callback)s', > > > > > > > with > > > > > > > jQuery(document).ready(function(server_time){jQuery("#% > > > (id)s").jqGrid({ > > > url:'%(callback)s&server_time'+escape(server_time), > > > > > > > On Nov 10, 9:34 am, AsmanCom wrote: > > > > > Hi Massimo, never mind. I do not want the variable passed with > > > > jQuery.getJSON, but with the url: '% (callback) s', which is called > > > > with LoadComplete: .trigger ("reload grid"). > > > > Here's the code so far.. > > > > > _ > > > > app/models/plugin_jqgrid.py: > > > > > def > > > > plugin_live_grid(table,fieldname=None,fieldvalue=None,col_widths={}, > > > > > _id=None,columns=None,col_width=80,width=700,height=300): > > > > """ > > > > just do to embed the jqGrid with ajax search capability and > > > > pagination > > > > {{=plugin_jqgrid(db.tablename)}} > > > > - table is the db.tablename > > > > - fieldname, fieldvalue are an optional filter > > > > (fieldname==fieldvalue) > > > > - _id is the "id" of the DIV that contains the jqGrid > > > > - columns is a list of columns names to be displayed > > > > - cold_width is the width of each column > > > > - height is the height of the jqGrid > > > > """ > > > > from gluon.serializers import json > > > > _id = 'jqgrid_%s' % table > > > > columns = columns or [x for x in table.fields if > > > > table[x].readable] > > > > colnames = [x.replace('_',' ').capitalize() for x in columns] > > > > colmodel = [{'name':x,'index':x, > > > > 'width':col_widths.get(x,col_width), 'sortable':True} \ > > > > for x in columns if table[x].readable] > > > > callback = URL(r=request,c='plugin_jqgrid',f='data', > > > > vars=dict(tablename=table._tablename, > > > > columns=','.join(columns), > > > > fieldname=fieldname or '', > > > > fieldvalue=fieldvalue, > > > > )) > > > > script=""" > > > > var server_time=null; > > > > jQuery(document).ready(function(server_time){jQuery("#% > > > > (id)s").jqGrid({ > > > > url:'%(callback)s', > > > > datatype: "json", > > > > colNames: %(colnames)s, > > > > colModel:%(colmodel)s, > > > > rowNum:10, > > > > rowList:[20,50,100], > > > > pager: '#%(id)s_pager
[web2py] Re: Plugin_JqGrid long-polling
By the way, how can i set initially the "var server_time=null;" to a python readble False? THX On 10 Nov., 16:55, mdipierro wrote: > You need to install firebug and check in the console log what is going > on. > > On Nov 10, 9:53 am, AsmanCom wrote: > > > tried it like this: > > > app/models/plugin_jqgrid.py: > > > var server_time=null; > > jQuery(document).ready(function(server_time){jQuery("#% > > (id)s").jqGrid({ > > url:'%(callback)s&server_time'+escape(server_time), > > > app/controllers/plugin_jqgrid.py: > > > def data(): > > sleep(10) > > ... > > test1 = request.vars.server_time or error() > > tablename = request.vars.tablename or error() > > ... > > items = {} > > items['userdata']=request.now > > ... > > __ > > > It seems not working, data is not returned by the controller. > > > On 10 Nov., 16:37, mdipierro wrote: > > > > replace > > > > > > > jQuery(document).ready(function(server_time){jQuery("#% > > > (id)s").jqGrid({ > > > url:'%(callback)s', > > > > > > > with > > > > > > > jQuery(document).ready(function(server_time){jQuery("#% > > > (id)s").jqGrid({ > > > url:'%(callback)s&server_time'+escape(server_time), > > > > > > > On Nov 10, 9:34 am, AsmanCom wrote: > > > > > Hi Massimo, never mind. I do not want the variable passed with > > > > jQuery.getJSON, but with the url: '% (callback) s', which is called > > > > with LoadComplete: .trigger ("reload grid"). > > > > Here's the code so far.. > > > > > _ > > > > app/models/plugin_jqgrid.py: > > > > > def > > > > plugin_live_grid(table,fieldname=None,fieldvalue=None,col_widths={}, > > > > > _id=None,columns=None,col_width=80,width=700,height=300): > > > > """ > > > > just do to embed the jqGrid with ajax search capability and > > > > pagination > > > > {{=plugin_jqgrid(db.tablename)}} > > > > - table is the db.tablename > > > > - fieldname, fieldvalue are an optional filter > > > > (fieldname==fieldvalue) > > > > - _id is the "id" of the DIV that contains the jqGrid > > > > - columns is a list of columns names to be displayed > > > > - cold_width is the width of each column > > > > - height is the height of the jqGrid > > > > """ > > > > from gluon.serializers import json > > > > _id = 'jqgrid_%s' % table > > > > columns = columns or [x for x in table.fields if > > > > table[x].readable] > > > > colnames = [x.replace('_',' ').capitalize() for x in columns] > > > > colmodel = [{'name':x,'index':x, > > > > 'width':col_widths.get(x,col_width), 'sortable':True} \ > > > > for x in columns if table[x].readable] > > > > callback = URL(r=request,c='plugin_jqgrid',f='data', > > > > vars=dict(tablename=table._tablename, > > > > columns=','.join(columns), > > > > fieldname=fieldname or '', > > > > fieldvalue=fieldvalue, > > > > )) > > > > script=""" > > > > var server_time=null; > > > > jQuery(document).ready(function(server_time){jQuery("#% > > > > (id)s").jqGrid({ > > > > url:'%(callback)s', > > > > datatype: "json", > > > > colNames: %(colnames)s, > > > > colModel:%(colmodel)s, > > > > rowNum:10, > > > > rowList:[20,50,100], > > > > pager: '#%(id)s_pager', > > > > onSelectRow: function(postdata) {web2py_ajax_page('get','/jqgrid2/ > > > > default/tabs2/'+(postdata),null,'panel');}, > > > > loadComplete: function () { > > > > var server_time=jQuery("#%(id)s").getGridParam('userData'); > > > > > setTimeout(function(){ > > > > alert(s
[web2py] Re: Plugin_JqGrid long-polling
http://127.0.0.1:8000/core/plugin_jqgrid/data?fieldname=&tablename=device&fieldvalue=None&columns=id%2Ccolumn1%2Ccolumn2%2Ccolumn3%2Ccolumn4%2Ccolumn5%2Ccolumn6%2Ccolumn7%2Ccolumn8%2Ccolumn9%2Ccolumn10&server_timenull&_search=false&nd=1289404767209&rows=10&page=1&sidx=&sord=asc Parameter: _search false columns id,column1,column2,column3,column4,column5,column6,column7,column8,column9,column10 fieldname fieldvalue None nd 1289404767209 page1 rows10 server_timenull sidx sordasc tablename device "server_timenull" seems wrong? what to do? THX On 10 Nov., 16:55, mdipierro wrote: > You need to install firebug and check in the console log what is going > on. > > On Nov 10, 9:53 am, AsmanCom wrote: > > > tried it like this: > > > app/models/plugin_jqgrid.py: > > > var server_time=null; > > jQuery(document).ready(function(server_time){jQuery("#% > > (id)s").jqGrid({ > > url:'%(callback)s&server_time'+escape(server_time), > > > app/controllers/plugin_jqgrid.py: > > > def data(): > > sleep(10) > > ... > > test1 = request.vars.server_time or error() > > tablename = request.vars.tablename or error() > > ... > > items = {} > > items['userdata']=request.now > > ... > > __ > > > It seems not working, data is not returned by the controller. > > > On 10 Nov., 16:37, mdipierro wrote: > > > > replace > > > > > > > jQuery(document).ready(function(server_time){jQuery("#% > > > (id)s").jqGrid({ > > > url:'%(callback)s', > > > > > > > with > > > > > > > jQuery(document).ready(function(server_time){jQuery("#% > > > (id)s").jqGrid({ > > > url:'%(callback)s&server_time'+escape(server_time), > > > > > > > On Nov 10, 9:34 am, AsmanCom wrote: > > > > > Hi Massimo, never mind. I do not want the variable passed with > > > > jQuery.getJSON, but with the url: '% (callback) s', which is called > > > > with LoadComplete: .trigger ("reload grid"). > > > > Here's the code so far.. > > > > > _ > > > > app/models/plugin_jqgrid.py: > > > > > def > > > > plugin_live_grid(table,fieldname=None,fieldvalue=None,col_widths={}, > > > > > _id=None,columns=None,col_width=80,width=700,height=300): > > > > """ > > > > just do to embed the jqGrid with ajax search capability and > > > > pagination > > > > {{=plugin_jqgrid(db.tablename)}} > > > > - table is the db.tablename > > > > - fieldname, fieldvalue are an optional filter > > > > (fieldname==fieldvalue) > > > > - _id is the "id" of the DIV that contains the jqGrid > > > > - columns is a list of columns names to be displayed > > > > - cold_width is the width of each column > > > > - height is the height of the jqGrid > > > > """ > > > > from gluon.serializers import json > > > > _id = 'jqgrid_%s' % table > > > > columns = columns or [x for x in table.fields if > > > > table[x].readable] > > > > colnames = [x.replace('_',' ').capitalize() for x in columns] > > > > colmodel = [{'name':x,'index':x, > > > > 'width':col_widths.get(x,col_width), 'sortable':True} \ > > > > for x in columns if table[x].readable] > > > > callback = URL(r=request,c='plugin_jqgrid',f='data', > > > > vars=dict(tablename=table._tablename, > > > > columns=','.join(columns), > > > > fieldname=fieldname or '', > > > > fieldvalue=fieldvalue, > > > > )) > > > > script=""" > > > > var server_time=null; > > > > jQuery(document).ready(function(server_time){jQuery("#% > > > > (id)s").jqGrid({ > > > > url:'%(callback)s', > > > > datatype: "json", > > > > colNames: %(colnames)s, > > > > colModel:%(colmodel)s, >
[web2py] Re: Plugin_JqGrid long-polling
tried it like this: app/models/plugin_jqgrid.py: var server_time=null; jQuery(document).ready(function(server_time){jQuery("#% (id)s").jqGrid({ url:'%(callback)s&server_time'+escape(server_time), app/controllers/plugin_jqgrid.py: def data(): sleep(10) ... test1 = request.vars.server_time or error() tablename = request.vars.tablename or error() ... items = {} items['userdata']=request.now ... __ It seems not working, data is not returned by the controller. On 10 Nov., 16:37, mdipierro wrote: > replace > > > jQuery(document).ready(function(server_time){jQuery("#% > (id)s").jqGrid({ > url:'%(callback)s', > > > with > > > jQuery(document).ready(function(server_time){jQuery("#% > (id)s").jqGrid({ > url:'%(callback)s&server_time'+escape(server_time), > > > On Nov 10, 9:34 am, AsmanCom wrote: > > > Hi Massimo, never mind. I do not want the variable passed with > > jQuery.getJSON, but with the url: '% (callback) s', which is called > > with LoadComplete: .trigger ("reload grid"). > > Here's the code so far.. > > > _ > > app/models/plugin_jqgrid.py: > > > def > > plugin_live_grid(table,fieldname=None,fieldvalue=None,col_widths={}, > > > _id=None,columns=None,col_width=80,width=700,height=300): > > """ > > just do to embed the jqGrid with ajax search capability and > > pagination > > {{=plugin_jqgrid(db.tablename)}} > > - table is the db.tablename > > - fieldname, fieldvalue are an optional filter > > (fieldname==fieldvalue) > > - _id is the "id" of the DIV that contains the jqGrid > > - columns is a list of columns names to be displayed > > - cold_width is the width of each column > > - height is the height of the jqGrid > > """ > > from gluon.serializers import json > > _id = 'jqgrid_%s' % table > > columns = columns or [x for x in table.fields if > > table[x].readable] > > colnames = [x.replace('_',' ').capitalize() for x in columns] > > colmodel = [{'name':x,'index':x, > > 'width':col_widths.get(x,col_width), 'sortable':True} \ > > for x in columns if table[x].readable] > > callback = URL(r=request,c='plugin_jqgrid',f='data', > > vars=dict(tablename=table._tablename, > > columns=','.join(columns), > > fieldname=fieldname or '', > > fieldvalue=fieldvalue, > > )) > > script=""" > > var server_time=null; > > jQuery(document).ready(function(server_time){jQuery("#% > > (id)s").jqGrid({ > > url:'%(callback)s', > > datatype: "json", > > colNames: %(colnames)s, > > colModel:%(colmodel)s, > > rowNum:10, > > rowList:[20,50,100], > > pager: '#%(id)s_pager', > > onSelectRow: function(postdata) {web2py_ajax_page('get','/jqgrid2/ > > default/tabs2/'+(postdata),null,'panel');}, > > loadComplete: function () { > > var server_time=jQuery("#%(id)s").getGridParam('userData'); > > > setTimeout(function(){ > > alert(server_time); > > jQuery("#%(id)s").jqGrid().setGridParam({datatype:"json"}); > > jQuery("#%(id)s").jqGrid().trigger("reloadGrid", > > [{current:true}]); > > > }, 1000); /* 1000..after 1 seconds */ > > }, > > > loadError: function () { > > setTimeout(function(){ > > > jQuery("#%(id)s").jqGrid().setGridParam({datatype:"json"}); > > jQuery("#%(id)s").jqGrid().trigger("reloadGrid", > > [{current:true}]); > > > }, 15000); /* milliseconds (15seconds) */ > > }, > > > caption:'%(tablename)s', > > viewrecords: true, > > height:%(height)s, > > loadui:"disabled"}); > > jQuery("#%(id)s").jqGrid('navGrid','#%(id)s_pager', > > {search:true,add:false,edit:false,del:false}); > > jQuery("#%(id)s").setGridWidth(%(width)s,false);}); > > """ % dict(callback=callback,colnames=json(colnames), > > tablename=table._tablename.capita
[web2py] Re: Plugin_JqGrid long-polling
tems['userdata']=request.now items['page']=page items['total']=int((nrecords+(rows-1))/rows) items['records']=nrecords readable_fields=[f.name for f in fields if f.readable] def f(value,fieldname): r = table[fieldname].represent if r: value=r(value) try: return value.xml() except: return cgi.escape(str(value)) items['rows']=[{'id':r.id,'cell':[f(r[x],x) for x in readable_fields]} \ for r in records] return json(items) app/controllers/default.py: # -*- coding: utf-8 -*- # ## This is a samples controller ## - index is the default action of any application ## - user is required for authentication and authorization ## - download is for downloading files uploaded in the db (does streaming) ## - call exposes all registered services (none by default) # def index(): """ example action using the internationalization operator T and flash rendered by views/default/index.html or views/generic.html """ response.flash = T('Welcome to web2py') return dict(message=T('Hello World')) def user(): """ exposes: http:///[app]/default/user/login http:///[app]/default/user/logout http:///[app]/default/user/register http:///[app]/default/user/profile http:///[app]/default/user/retrieve_password http:///[app]/default/user/change_password use @auth.requires_login() @auth.requires_membership('group name') @auth.requires_permission('read','table name',record_id) to decorate functions that need access control """ return dict(form=auth()) def download(): """ allows downloading of uploaded files http:///[app]/default/download/[filename] """ return response.download(request,db) def call(): """ exposes services. for example: http:///[app]/default/call/jsonrpc decorate with @services.jsonrpc the functions to expose supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv """ session.forget() return service() def jqgrid(): """ exposes services. for example: http:///[app]/default/call/jsonrpc decorate with @services.jsonrpc the functions to expose supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv """ return dict(grid=plugin_live_grid(db.device)) _ THX Dieter Asman On 10 Nov., 15:37, mdipierro wrote: > Sorry I did not help. I cannot help you because the code you have > above is incomplete. It opens a """ but never closes so I not > understand how callback is used. Anyway I assume in the view you have: > > {{callback = URL(r=request,c='plugin_jqgrid',f='data', > vars=dict(tablename=table._tablename, > columns=','.join(columns), > fieldname=fieldname or '', > fieldvalue=fieldvalue, > ))}} > > var server_time="test" > > ... jQuery.getJSON('{{=callback}} > &'server_time='+escape(server_time)) ... > > hope this helps. > > On Nov 10, 8:24 am, AsmanCom wrote: > > > Is there no solution to my concerns? > > > It´s such a pity... > >
[web2py] Re: Plugin_JqGrid long-polling
Is there no solution to my concerns? It´s such a pity...
[web2py] Re: Plugin_JqGrid long-polling
How can I add the JavaScript: var server_time="test" to the vars dict: callback = URL(r=request,c='plugin_jqgrid',f='data', vars=dict(tablename=table._tablename, columns=','.join(columns), fieldname=fieldname or '', fieldvalue=fieldvalue, )) ??? THX On 7 Nov., 15:25, "mr.freeze" wrote: > Anything that is put in the vars dict of a URL will end up in > request.vars when navigated to. For example: > URL(vars=dict(server_time=request.now)) will be > request.vars.server_time. Is that what you're asking? > > On Nov 7, 3:12 am, AsmanCom wrote: > > > Can I include the var server_time in the vars=dict somehow? > > > THX > >
[web2py] Re: Plugin_JqGrid long-polling
Who can help me with this? THX On 8 Nov., 08:04, AsmanCom wrote: > THX mr.freeze > > Yeah request.vars, but the vars=dict is already set in "callback =", > how can I add the Javascript var to the vars=dict? > > On loadComplete: I set the server_time var("last successful relaod") > and * 1000..after 1 seconds * the ReloadGrid calls the URL with the > included server_time var, now the called controller(plugin_jqgrid.py) > can check for new/updated records with > last_update=request.vars.server_time new_items since last_update or > sleep(60). > With "URL(vars=dict(server_time=request.now))" the Problem is that I > need to set the server _time var to "last successful relaod", but with > this method i am passing "request.now". > > Any further suggestions... > > Dieter Asman > > On 7 Nov., 15:25, "mr.freeze" wrote: > > > Anything that is put in the vars dict of a URL will end up in > > request.vars when navigated to. For example: > > URL(vars=dict(server_time=request.now)) will be > > request.vars.server_time. Is that what you're asking? > > > On Nov 7, 3:12 am, AsmanCom wrote: > > > > Can I include the var server_time in the vars=dict somehow? > > > > THX > >
[web2py] Re: Plugin_JqGrid long-polling
THX mr.freeze Yeah request.vars, but the vars=dict is already set in "callback =", how can I add the Javascript var to the vars=dict? On loadComplete: I set the server_time var("last successful relaod") and * 1000..after 1 seconds * the ReloadGrid calls the URL with the included server_time var, now the called controller(plugin_jqgrid.py) can check for new/updated records with last_update=request.vars.server_time new_items since last_update or sleep(60). With "URL(vars=dict(server_time=request.now))" the Problem is that I need to set the server _time var to "last successful relaod", but with this method i am passing "request.now". Any further suggestions... Dieter Asman On 7 Nov., 15:25, "mr.freeze" wrote: > Anything that is put in the vars dict of a URL will end up in > request.vars when navigated to. For example: > URL(vars=dict(server_time=request.now)) will be > request.vars.server_time. Is that what you're asking? > > On Nov 7, 3:12 am, AsmanCom wrote: > > > Can I include the var server_time in the vars=dict somehow? > > > THX > >
[web2py] Re: Plugin_JqGrid long-polling
Can I include the var server_time in the vars=dict somehow? THX
[web2py] Re: Plugin_JqGrid long-polling
Anyone? It´s only about passing the var with the URL THX
[web2py] Plugin_JqGrid long-polling
Hi, I need some help with plugin_jqgrid: What I basicaly want to do is steady refreshing the grid with on loadComplete .trigger("reloadGrid"), how can i pass the var server_time with the url:'%(callback)s' to the controllers/ plugin_jqgrid/data call? I need this var in the controller to return data only if ther is new/ updated records(the var changes every loadComplete). ___ models/plugin_jqgrid.py: callback = URL(r=request,c='plugin_jqgrid',f='data', vars=dict(tablename=table._tablename, columns=','.join(columns), fieldname=fieldname or '', fieldvalue=fieldvalue, )) script=""" var server_time=null; ... ... url:'%(callback)s', datatype: "json", ... loadComplete: function () { var server_time=$.getJSON("http:domain/app/default/time.html", time_callback); function time_callback(data) { var server_time=data; alert(server_time); }; setTimeout(function(){ jQuery("#%(id)s").jqGrid().setGridParam({datatype:"json"}); jQuery("#%(id)s").jqGrid().trigger("reloadGrid", [{current:true}]); }, 1000); /* 1000..after 1 seconds */ }, loadError: function () { setTimeout(function(){ jQuery("#%(id)s").jqGrid().setGridParam({datatype:"json"}); jQuery("#%(id)s").jqGrid().trigger("reloadGrid", [{current:true}]); }, 15000); /* milliseconds (15seconds) */ }, ... ... ___ THX Dieter Asman
[web2py] Re: new welcome (scaffolding) app
Hi, I would advise to integrate jquery.ui and the ThemeSwitcher widget (http://docs.jquery.com/UI/Theming/ThemeSwitcher) to make the app visual appealing vor novices. THX Dieter Asman On Jul 9, 3:34 pm, mdipierro wrote: > let's consider anewscaffolding app. > > What should be in it? > What should not be in it? > > possible suggestions: > [ ] js menu > [ ]newlayout (suggestions?) > [ ] more complex views/layout? > [ ] simpler views/layout.html > [ ] example plugins > [ ] plugin_wiki from cube2py? > [ ] jquery.ui > > Massimo
[web2py] Re: JQGrid Plugin with multiple Databases
I take that as a no ;-) On 7 Jul., 13:51, mdipierro wrote: > The plugin would need to define a list of possible database and pass > an index (pointing to an element in the list) during the ajax > callback. > > It seems an un-necessary complication to be implemented in general. > > Massimo > > On 6 Lug, 11:59, AsmanCom wrote: > > > Could you advise me a Workaround for that? > > > THX > > > Dieter Asman > > > On 6 Jul., 18:16, mdipierro wrote: > > > > I see there is a problem. There is no mechanism to pass the database > > > via ajax at this time. > > > > On 6 Lug, 10:39, AsmanCom wrote: > > > > > Hi, > > > > > i´ve tried it, but it won´t work. > > > > > Installed the new Version from > > > > ->http://www.web2py.com/plugins/default/jqgrid > > > > > controller-> > > > > > def jqgrid(): > > > > return dict(grid=plugin_jqgrid(db_1.maingrid)) > > > > > model-> > > > > > db_1 = DAL("sqlite://db1.db") > > > > > db_1.define_table('maingrid', > > > > Field('field1', 'string'), > > > > Field('field2', 'string'), > > > > Field('field3', 'string'), > > > > Field('field4', 'string'), > > > > Field('field5', 'string')) > > > > > The colnames are right, but the Grid is empty. > > > > > Do you know how I can get this to work? > > > > > THX > > > > > Dieter Asman > > > > > On 5 Jul., 14:00, mdipierro wrote: > > > > > > I have fixed it an uploaded. Please give it a try. > > > > > > On 5 Lug, 04:07, AsmanCom wrote: > > > > > > > I´ve elready tried to change the controller/plugin_jqgrid.py, by > > > > > > replacing > > > > > > > table=db[tablename] > > > > > > if request.vars.fieldname: > > > > > > dbset = > > > > > > db(table[request.vars.fieldname]==request.vars.fieldvalue) > > > > > > else: > > > > > > dbset = db(table.id>0) > > > > > > > with: > > > > > > > table=db_1[tablename] > > > > > > if request.vars.fieldname: > > > > > > dbset = > > > > > > db_1(table[request.vars.fieldname]==request.vars.fieldvalue) > > > > > > else: > > > > > > dbset = db_1(table.id>0) > > > > > > > But without success. > > > > > > > THX > > > > > > > On Jul 5, 11:00 am, AsmanCom wrote: > > > > > > > > Hi, > > > > > > > > I try to get the JQGrid Plugin > > > > > > > (http://www.web2py.com/plugins/default/ > > > > > > > jqgrid) to work with multiple Databases. > > > > > > > > Like this: > > > > > > > > db_1 = DAL("sqlite://db1.db") > > > > > > > db_2 = DAL("sqlite://db2.db") > > > > > > > db_3 = DAL("sqlite://db3.db") > > > > > > > > plugin_jqgrid(db_1.shout) > > > > > > > > But the Grid is empty. > > > > > > > > If I do it like that, it works: > > > > > > > > db = DAL("sqlite://db1.db") > > > > > > > > plugin_jqgrid(db.shout) > > > > > > > > How to change the plugin to work with multiple Databases? > > > > > > > > P.S if I put "db=db_1" in the model/plugin_jqgrid.py it works but > > > > > > > only > > > > > > > for 1 DB. > > > > > > > > Can anyone help? > > > > > > > > THX
[web2py] Re: Editable jqgrid
Hi, you have to press enter when you have finished your changes. Dieter Asman On 11 Jul., 22:45, Kenneth wrote: > Hello, > > I´m trying to make a editable jqgrid or something like a editable > jqgrid. It doesn´t have to be a jqgrid. > > I have downloaded the plugin from Eban Software but can´t get it to > work. If I edit a row in the grid it doesn´t get saved. Same if I go > tohttp://app.ebansoftware.net/editable_jqgrid/default/show_example > and try to edit a row, can´t get it to save the change. > > Has anybody used the Eban Software plugin or something like that. > > Kenneth
[web2py] Re: JQGrid Plugin with multiple Databases
Hi, in the editable jqgrid plugin from ebansoftware you can symply pass the db_name as string: invoice=plugin_editable_jqgrid(db_invoice.invoice,grid_name='invoice',db_name='db_invoice')) I think this is very useful, I am trying to port this functionality to your plugin, but without success right now. Would you further take a look at this? THX Dieter Asman On Jul 7, 1:51 pm, mdipierro wrote: > The plugin would need to define a list of possible database and pass > an index (pointing to an element in the list) during the ajax > callback. > > It seems an un-necessary complication to be implemented in general. > > Massimo > > On 6 Lug, 11:59, AsmanCom wrote: > > > Could you advise me a Workaround for that? > > > THX > > > Dieter Asman > > > On 6 Jul., 18:16, mdipierro wrote: > > > > I see there is a problem. There is no mechanism to pass the database > > > via ajax at this time. > > > > On 6 Lug, 10:39, AsmanCom wrote: > > > > > Hi, > > > > > i´ve tried it, but it won´t work. > > > > > Installed the new Version from > > > > ->http://www.web2py.com/plugins/default/jqgrid > > > > > controller-> > > > > > defjqgrid(): > > > > return dict(grid=plugin_jqgrid(db_1.maingrid)) > > > > > model-> > > > > > db_1 = DAL("sqlite://db1.db") > > > > > db_1.define_table('maingrid', > > > > Field('field1', 'string'), > > > > Field('field2', 'string'), > > > > Field('field3', 'string'), > > > > Field('field4', 'string'), > > > > Field('field5', 'string')) > > > > > The colnames are right, but the Grid is empty. > > > > > Do you know how I can get this to work? > > > > > THX > > > > > Dieter Asman > > > > > On 5 Jul., 14:00, mdipierro wrote: > > > > > > I have fixed it an uploaded. Please give it a try. > > > > > > On 5 Lug, 04:07, AsmanCom wrote: > > > > > > > I´ve elready tried to change the controller/plugin_jqgrid.py, by > > > > > > replacing > > > > > > > table=db[tablename] > > > > > > if request.vars.fieldname: > > > > > > dbset = > > > > > > db(table[request.vars.fieldname]==request.vars.fieldvalue) > > > > > > else: > > > > > > dbset = db(table.id>0) > > > > > > > with: > > > > > > > table=db_1[tablename] > > > > > > if request.vars.fieldname: > > > > > > dbset = > > > > > > db_1(table[request.vars.fieldname]==request.vars.fieldvalue) > > > > > > else: > > > > > > dbset = db_1(table.id>0) > > > > > > > But without success. > > > > > > > THX > > > > > > > On Jul 5, 11:00 am, AsmanCom wrote: > > > > > > > > Hi, > > > > > > > > I try to get theJQGridPlugin > > > > > > > (http://www.web2py.com/plugins/default/ > > > > > > >jqgrid) to work with multiple Databases. > > > > > > > > Like this: > > > > > > > > db_1 = DAL("sqlite://db1.db") > > > > > > > db_2 = DAL("sqlite://db2.db") > > > > > > > db_3 = DAL("sqlite://db3.db") > > > > > > > > plugin_jqgrid(db_1.shout) > > > > > > > > But the Grid is empty. > > > > > > > > If I do it like that, it works: > > > > > > > > db = DAL("sqlite://db1.db") > > > > > > > > plugin_jqgrid(db.shout) > > > > > > > > How to change the plugin to work with multiple Databases? > > > > > > > > P.S if I put "db=db_1" in the model/plugin_jqgrid.py it works but > > > > > > > only > > > > > > > for 1 DB. > > > > > > > > Can anyone help? > > > > > > > > THX
[web2py] Re: JQGrid Plugin with multiple Databases
Could you advise me a Workaround for that? THX Dieter Asman On 6 Jul., 18:16, mdipierro wrote: > I see there is a problem. There is no mechanism to pass the database > via ajax at this time. > > On 6 Lug, 10:39, AsmanCom wrote: > > > Hi, > > > i´ve tried it, but it won´t work. > > > Installed the new Version from > > ->http://www.web2py.com/plugins/default/jqgrid > > > controller-> > > > def jqgrid(): > > return dict(grid=plugin_jqgrid(db_1.maingrid)) > > > model-> > > > db_1 = DAL("sqlite://db1.db") > > > db_1.define_table('maingrid', > > Field('field1', 'string'), > > Field('field2', 'string'), > > Field('field3', 'string'), > > Field('field4', 'string'), > > Field('field5', 'string')) > > > The colnames are right, but the Grid is empty. > > > Do you know how I can get this to work? > > > THX > > > Dieter Asman > > > On 5 Jul., 14:00, mdipierro wrote: > > > > I have fixed it an uploaded. Please give it a try. > > > > On 5 Lug, 04:07, AsmanCom wrote: > > > > > I´ve elready tried to change the controller/plugin_jqgrid.py, by > > > > replacing > > > > > table=db[tablename] > > > > if request.vars.fieldname: > > > > dbset = > > > > db(table[request.vars.fieldname]==request.vars.fieldvalue) > > > > else: > > > > dbset = db(table.id>0) > > > > > with: > > > > > table=db_1[tablename] > > > > if request.vars.fieldname: > > > > dbset = > > > > db_1(table[request.vars.fieldname]==request.vars.fieldvalue) > > > > else: > > > > dbset = db_1(table.id>0) > > > > > But without success. > > > > > THX > > > > > On Jul 5, 11:00 am, AsmanCom wrote: > > > > > > Hi, > > > > > > I try to get the JQGrid Plugin (http://www.web2py.com/plugins/default/ > > > > > jqgrid) to work with multiple Databases. > > > > > > Like this: > > > > > > db_1 = DAL("sqlite://db1.db") > > > > > db_2 = DAL("sqlite://db2.db") > > > > > db_3 = DAL("sqlite://db3.db") > > > > > > plugin_jqgrid(db_1.shout) > > > > > > But the Grid is empty. > > > > > > If I do it like that, it works: > > > > > > db = DAL("sqlite://db1.db") > > > > > > plugin_jqgrid(db.shout) > > > > > > How to change the plugin to work with multiple Databases? > > > > > > P.S if I put "db=db_1" in the model/plugin_jqgrid.py it works but only > > > > > for 1 DB. > > > > > > Can anyone help? > > > > > > THX
[web2py] Re: JQGrid Plugin with multiple Databases
Hi, i´ve tried it, but it won´t work. Installed the new Version from -> http://www.web2py.com/plugins/default/jqgrid controller-> def jqgrid(): return dict(grid=plugin_jqgrid(db_1.maingrid)) model-> db_1 = DAL("sqlite://db1.db") db_1.define_table('maingrid', Field('field1', 'string'), Field('field2', 'string'), Field('field3', 'string'), Field('field4', 'string'), Field('field5', 'string')) The colnames are right, but the Grid is empty. Do you know how I can get this to work? THX Dieter Asman On 5 Jul., 14:00, mdipierro wrote: > I have fixed it an uploaded. Please give it a try. > > On 5 Lug, 04:07, AsmanCom wrote: > > > I´ve elready tried to change the controller/plugin_jqgrid.py, by > > replacing > > > table=db[tablename] > > if request.vars.fieldname: > > dbset = > > db(table[request.vars.fieldname]==request.vars.fieldvalue) > > else: > > dbset = db(table.id>0) > > > with: > > > table=db_1[tablename] > > if request.vars.fieldname: > > dbset = > > db_1(table[request.vars.fieldname]==request.vars.fieldvalue) > > else: > > dbset = db_1(table.id>0) > > > But without success. > > > THX > > > On Jul 5, 11:00 am, AsmanCom wrote: > > > > Hi, > > > > I try to get the JQGrid Plugin (http://www.web2py.com/plugins/default/ > > > jqgrid) to work with multiple Databases. > > > > Like this: > > > > db_1 = DAL("sqlite://db1.db") > > > db_2 = DAL("sqlite://db2.db") > > > db_3 = DAL("sqlite://db3.db") > > > > plugin_jqgrid(db_1.shout) > > > > But the Grid is empty. > > > > If I do it like that, it works: > > > > db = DAL("sqlite://db1.db") > > > > plugin_jqgrid(db.shout) > > > > How to change the plugin to work with multiple Databases? > > > > P.S if I put "db=db_1" in the model/plugin_jqgrid.py it works but only > > > for 1 DB. > > > > Can anyone help? > > > > THX
[web2py] Re: A few questions about jqgrid
You could have a look at this plugin for for Inline edit with JQGrid and Web2py: http://app.ebansoftware.net/editable_jqgrid/default/index On 5 Jul., 21:25, Johann Spies wrote: > I am a javascipt and jquery novice and would appreciate some > information to help me understand how to use a jqgrid-plugin. > > My questions are overlapping in some cases. > > 1. How does jqgrid communicate with the backend database? > 2. Do I have to put special mechanisms in place to make sure that > changes in an editable grid end up in the database? > 3. At what stage does this communication with the database take place > (I mean sending information back to the database). > 4. How do I send a selection from the database to the grid? At the > moment the documentation on the available web2py jqgrid plugins is not > clear to me about this. > 5. How do I specify a specific cell to be editable or not? > 6. Overlapping with some earlier questions: How do I submit changes to a grid? > 7. How do I check for valid input in a cell? > > Regards > Johann > > -- > "Finally, brethren, whatsoever things are true, whatsoever things are > honest, whatsoever things are just, whatsoever things are pure, > whatsoever things are lovely, whatsoever things are of good report; if > there be any virtue, and if there be any praise, think on these > things." Philippians 4:8
[web2py] Re: JQGrid Plugin with multiple Databases
THX, that was damn fast! I´ll try it later and will let you know if it works. Dieter Asman On Jul 5, 2:00 pm, mdipierro wrote: > I have fixed it an uploaded. Please give it a try. > > On 5 Lug, 04:07, AsmanCom wrote: > > > I´ve elready tried to change the controller/plugin_jqgrid.py, by > > replacing > > > table=db[tablename] > > if request.vars.fieldname: > > dbset = > > db(table[request.vars.fieldname]==request.vars.fieldvalue) > > else: > > dbset = db(table.id>0) > > > with: > > > table=db_1[tablename] > > if request.vars.fieldname: > > dbset = > > db_1(table[request.vars.fieldname]==request.vars.fieldvalue) > > else: > > dbset = db_1(table.id>0) > > > But without success. > > > THX > > > On Jul 5, 11:00 am, AsmanCom wrote: > > > > Hi, > > > > I try to get the JQGrid Plugin (http://www.web2py.com/plugins/default/ > > > jqgrid) to work with multiple Databases. > > > > Like this: > > > > db_1 = DAL("sqlite://db1.db") > > > db_2 = DAL("sqlite://db2.db") > > > db_3 = DAL("sqlite://db3.db") > > > > plugin_jqgrid(db_1.shout) > > > > But the Grid is empty. > > > > If I do it like that, it works: > > > > db = DAL("sqlite://db1.db") > > > > plugin_jqgrid(db.shout) > > > > How to change the plugin to work with multiple Databases? > > > > P.S if I put "db=db_1" in the model/plugin_jqgrid.py it works but only > > > for 1 DB. > > > > Can anyone help? > > > > THX
[web2py] Re: JQGrid Plugin with multiple Databases
I´ve elready tried to change the controller/plugin_jqgrid.py, by replacing table=db[tablename] if request.vars.fieldname: dbset = db(table[request.vars.fieldname]==request.vars.fieldvalue) else: dbset = db(table.id>0) with: table=db_1[tablename] if request.vars.fieldname: dbset = db_1(table[request.vars.fieldname]==request.vars.fieldvalue) else: dbset = db_1(table.id>0) But without success. THX On Jul 5, 11:00 am, AsmanCom wrote: > Hi, > > I try to get the JQGrid Plugin (http://www.web2py.com/plugins/default/ > jqgrid) to work with multiple Databases. > > Like this: > > db_1 = DAL("sqlite://db1.db") > db_2 = DAL("sqlite://db2.db") > db_3 = DAL("sqlite://db3.db") > > plugin_jqgrid(db_1.shout) > > But the Grid is empty. > > If I do it like that, it works: > > db = DAL("sqlite://db1.db") > > plugin_jqgrid(db.shout) > > How to change the plugin to work with multiple Databases? > > P.S if I put "db=db_1" in the model/plugin_jqgrid.py it works but only > for 1 DB. > > Can anyone help? > > THX
[web2py] JQGrid Plugin with multiple Databases
Hi, I try to get the JQGrid Plugin (http://www.web2py.com/plugins/default/ jqgrid) to work with multiple Databases. Like this: db_1 = DAL("sqlite://db1.db") db_2 = DAL("sqlite://db2.db") db_3 = DAL("sqlite://db3.db") plugin_jqgrid(db_1.shout) But the Grid is empty. If I do it like that, it works: db = DAL("sqlite://db1.db") plugin_jqgrid(db.shout) How to change the plugin to work with multiple Databases? P.S if I put "db=db_1" in the model/plugin_jqgrid.py it works but only for 1 DB. Can anyone help? THX
[web2py] Hidden SQLFORM.factory Field
Hi, i can make a hidden Field by: form = SQLFORM.factory(Field("field_name", type="hidden", default="Off")) Now the Form is hidden, but the Fieldname is still there, how can I hide this? THX
[web2py] Re: Download an external file to 'uploads'
Hi, that could be useful for the unzip part: http://www.web2py.com/examples/static/epydoc/web2py.gluon.admin-pysrc.html#unzip And that could be used/customized for the downloading part (Its taken from the great clienttools module: http://www.web2pyslices.com/main/slices/take_slice/8): def __init__(self, environment): self.environment = Storage(environment) self.resources = [] self.onready = [] def include(self, path, download=False, overwrite=False, subfolder=None): request = self.environment.request out = path if hasattr(path, 'xml'): out = path.xml() if download and path.startswith("http://";): if not request.env.web2py_runtime_gae: fname = valid_filename(path.split("/")[-1]) if len(fname): pieces = (request.folder, 'static', subfolder) fld = os.path.join(*(x for x in pieces if x)) if not os.path.exists(fld): os.mkdir(fld) fpath = os.path.join(fld,fname) exists = os.path.exists(fpath) if (not exists) or (exists and overwrite): urllib.urlretrieve(path, fpath) out = URL(r=request,c='/'.join( x for x in ['static', subfolder] if x),f=fname) self.resources.append(out) On 18 Jun., 15:12, scausten wrote: > Should have tried harder myself - this works, but is there a better > way of doing it? > > filename, headers = urllib.urlretrieve(link, path.join(os.getcwd(), > "applications", request.application, "uploads", "foo.zip")) > > On Jun 18, 1:56 pm, scausten wrote: > > > I'm trying to download (using urllib.urlretrieve) a remote file into > > my application. It's a zip file containing an IP-to-country lookup > > table. I want to download the zip to the application's file system > > (probably 'uploads'), unzip it, process the csv and then import the > > sanitised data into my ip-to-country database (using > > import_from_csv_file). > > > How should I specify/access locations in the filesystem?
[web2py] Re: request.vars from Javascript
Yeah, that gos in the right direction, I am already using an JQuery "Toggle" Button: jQuery(".my_button").toggle(function(){ jQuery(this).val("On"); jQuery("#anything").stop(true,true).show("slow"); },function(){ jQuery(this).val("Off"); jQuery("#anything").stop(true,true).hide("slow"); }); But i need to make client side Value available vor a server-side Callback without submitting the form. I thought i could some how read the value the button holds. But may i´ve to use a workaround by changing the value of an hidden form elemet with Button onclick event (How can I do this ??), client-side. And then i can do request.vars.formelemt How can i change the Value of this, without submitting the form: form = SQLFORM.factory(Field('switch', requires=IS_IN_SET(['On','Off']), default="Off", widget=SQLFORM.widgets.radio.widget)) THX Dieter Asman On 19 Jun., 12:52, David Marko wrote: > For the form based applications I like Dojo Toolkit, especially > declarative mode. See the Checkbox widget > here:http://www.dojotoolkit.org/reference-guide/dijit/form/ToggleButton.ht... > > David > > On 19 čvn, 11:25, AsmanCom wrote: > > > I don´t think so, but I need to receive the Value contained in the > > Button. > > > Checkbox would be the Solution, but it must look like a Button. > > > Any Ideas? > > > THX > > > Dieter Asman > > > On 19 Jun., 02:30, Richard wrote: > > > > can buttons post form data? > > > > Are you perhaps after a checkbox instead? > > > > On Jun 19, 3:11 am, AsmanCom wrote: > > > > > Hi, > > > > > I need to retrieve the request.vars from an JavaScript Object. > > > > > controller code: > > > > > form.append(INPUT( _id="buttonid", _type="button", _class="my_button", > > > > _name="buttonName", _value="Off")) > > > > > and then i want to get the value from this, like so: > > > > > if request.vars.buttonName == "Off": > > > > do anything > > > > > But it doesn´t work. > > > > > Could you explain how to achieve this? > > > > > TXH > > > > > Dieter Asman
[web2py] Re: request.vars from Javascript
I don´t think so, but I need to receive the Value contained in the Button. Checkbox would be the Solution, but it must look like a Button. Any Ideas? THX Dieter Asman On 19 Jun., 02:30, Richard wrote: > can buttons post form data? > > Are you perhaps after a checkbox instead? > > On Jun 19, 3:11 am, AsmanCom wrote: > > > Hi, > > > I need to retrieve the request.vars from an JavaScript Object. > > > controller code: > > > form.append(INPUT( _id="buttonid", _type="button", _class="my_button", > > _name="buttonName", _value="Off")) > > > and then i want to get the value from this, like so: > > > if request.vars.buttonName == "Off": > > do anything > > > But it doesn´t work. > > > Could you explain how to achieve this? > > > TXH > > > Dieter Asman
[web2py] request.vars from Javascript
Hi, I need to retrieve the request.vars from an JavaScript Object. controller code: form.append(INPUT( _id="buttonid", _type="button", _class="my_button", _name="buttonName", _value="Off")) and then i want to get the value from this, like so: if request.vars.buttonName == "Off": do anything But it doesn´t work. Could you explain how to achieve this? TXH Dieter Asman
[web2py] Client Tools Application corrupt on web2py Version 1.79.2 ?
Hi, it seems that Client Tools wont work anymore on web2py Version 1.79.2: Traceback (most recent call last): File "gluon/restricted.py", line 178, in restricted File "D:/web2py/applications/clienttools/controllers/default.py", line 265, in File "gluon/globals.py", line 96, in File "D:/web2py/applications/clienttools/controllers/default.py", line 147, in jqueryui_slider File "D:\web2py\applications\clienttools\modules\clienttools.py", line 307, in __call__ File "D:\web2py\applications\clienttools\modules\clienttools.py", line 292, in __str__ File "D:\web2py\applications\clienttools\modules\clienttools.py", line 293, in __str__ File "D:\web2py\applications\clienttools\modules\clienttools.py", line 288, in encode AttributeError: 'function' object has no attribute 'dumps' Is there any known workaround? THX Dieter Asman
[web2py] Re: PluginManager?
env(a, import_models=False, c=1, f=1, dir='', extra_request={}) Return web2py execution environment for application (a), controller (c), function (f). If import_models is True the exec all application models into the environment. extra_request allows you to pass along any extra variables to the request object before your models get executed. This was mainly done to support web2py_utils.test_runner, however you can use it with any wrapper scripts that need access to the web2py environment. On 8 Jun., 05:42, Doug Warren wrote: > So I'm writing a plugin to handle scheduling of tasks with a dynamic > granularity of a second or less, and I went to use PluginManger per > it's definition in tools.py: > class PluginManager(dict): > """ > This object stored parameters to configure plugins (if they need > configuration) > In models/db.py instantiate the PluginManager > > plugins=PluginManager() > > then set the parameters required plugins, for example > > plugins.comments.db=db > > (each plugin should have a documented set of required parameters) > """ > > My code: > plugins = PluginManager() > db = plugins.plugin_scheduler.db or None > > if db is not None: > db.define_table(plugins.plugin_scheduler.table_name or > 'plugin_scheduler_table', > db.Field('execution_time', 'datetime', default=request.now), > db.Field('controller', 'string'), > db.Field('function', 'string') > ) > > Only problem... > def __init__(self,env): > self['globals'] = env > > What's that env? Has anyone written a plugin that uses PluginManager? > I checked on the official site and none seem to be using it... If > it's request.env shouldn't it have a default arg of None? Am I using > it as it was expected to be used?
[web2py] Re: PluginManager?
Hi, a Task Scheduler Plugin would be very nice. Kindly keep me posted about your progress! What exactly is the Problem, do you have a traceback? On 8 Jun., 05:42, Doug Warren wrote: > So I'm writing a plugin to handle scheduling of tasks with a dynamic > granularity of a second or less, and I went to use PluginManger per > it's definition in tools.py: > class PluginManager(dict): > """ > This object stored parameters to configure plugins (if they need > configuration) > In models/db.py instantiate the PluginManager > > plugins=PluginManager() > > then set the parameters required plugins, for example > > plugins.comments.db=db > > (each plugin should have a documented set of required parameters) > """ > > My code: > plugins = PluginManager() > db = plugins.plugin_scheduler.db or None > > if db is not None: > db.define_table(plugins.plugin_scheduler.table_name or > 'plugin_scheduler_table', > db.Field('execution_time', 'datetime', default=request.now), > db.Field('controller', 'string'), > db.Field('function', 'string') > ) > > Only problem... > def __init__(self,env): > self['globals'] = env > > What's that env? Has anyone written a plugin that uses PluginManager? > I checked on the official site and none seem to be using it... If > it's request.env shouldn't it have a default arg of None? Am I using > it as it was expected to be used?
[web2py] Barchart solution (with Callback) available?
I would like to show Database Fields as Barcharts (widget) like this: http://web2py.appspot.com/t3/default/wiki/charts or better http://t.wits.sg/jquery-progress-bar/ It should be possible to show more then one barchart per Page, which can be updated by a Callback (I want to use them in a Grid) I´ve tried the ProgressBar from Client Tools for web2py, but its not possible to show more then one per Page. Thats my first approach: response.files.append(URL(r=request,c='static/jquery- autocomplete',f='jquery.progressbar')) def barchart(): get_value= URL(r=request,f="get_percent") wrapper = DIV() script_1 = SCRIPT("jQuery('#bar').progressBar('%s');" % (get_percent),_type="text/javascript") wrapper.components.extend([script_1]) return wrapper db.define_table('task', Field('name', 'string'), Field('percent', 'integer', widget=barchart)) But this is work in progress... Is there any widget in web2py, to show a value as Barchart/Progressbar or any other already implemented Solution? THX Dieter Asman
[web2py] Re: jQgrid navigator - form editing through a grid
What about that http://app.ebansoftware.net/editable_jqgrid/default/show_example On 29 Mai, 19:21, Yarko Tymciurak wrote: > btw - trying to wade thru these doesn't seem to point to anything (and > just makes my head hurt!): > > http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator&s[]=navigatorhttp://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_ruleshttp://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing&s[]=ajax > > On May 29, 12:16 pm, Yarko Tymciurak > wrote: > > > I admit it - I'm a jQuery novice; no, worse: a javascript ninny: I > > have not been able (yet) to make sense of how things work, what the > > underlying structure is, so that I can "know" what I need to do (even > > before I think about "all the ways" I can do something). > > > So - I wanted to use a few jquery components on the same page. > > > I have not gotten past even the first one - maybe I'm missing > > something fundamental, simple; > > Maybe I haven't learened the ritual dance necessary - I don't know. > > I do know I need some help breaking through this. > > > Here's the deal: > > >http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator&s[]=navigator > > > Is what I want to implement. > > > Getting a table to show in the grid - not too tough. > > Configuring so that "edit" (at least - let's not worry about create / > > delete yet!) --- I managed to stumble through. > > > Getting "the right thing to happen" when "Submit" is clicked on the > > form - that's another story. > > > Anybody able to help? > > > The controller is fairly easy (template is just a table name): > > > def jqindex(): > > # let's try this: > > grid = plugin_jqgrid(db.template) > > return dict( grid=grid); > > > then, in models/plugin_jqgrid, I changed > > > < add:false, > > < edit:false, > > < del:false > > --- > > > > add: true, > > > edit:true, > > > del:true, > > > So far, so good --- but the 3 or 4 things I've tried to get this to > > connect to a controller action on clickSubmit, > > > no joy, no connection... > > > Can anybody point the right path / incantation / way to think of this? > > > Thanks. > > > - Yarko
[web2py] Re: [SOLVED] jqgrid onSelectRow trigger web2py_component
You helped me a lot, man! i´ve tried like you suggested, i only keeped the LOAD, but it´s the same... Page is loading the Grid, underneath the Grid rises "loading" and then a new layer pops up with with the form in the default Template (Its showed twice). I´ve checked: www.web2py.com/AlterEgo/default/show/252 But it doesent´t helped very much. It seems I am stucked, right before finish... ;-( Any help is appreciated, would so cool if I could get this done today. Dieter Asman On 20 Mai, 17:23, Jason Lotz wrote: > web2py LOAD function will create generate id="target">Loading... and fills your component. I'm sorry I can't > test it right now but it seems that by adding the in your > view and including the LOAD you are creating two form. Maybe try remove > your div and only keep the LOAD. > > {{extend 'layout.html'}} > This is the default/test.html template > {{=jqgrid_table}} > > jQuery(document).ready(function() > {jQuery("#grid_id").jqGrid({onSelectRow: function(postdata) > {web2py_ajax_page('get','/myapp/default/form/'+ > (postdata),null,'my_form');}}); > > {{=LOAD('default','form',args=1,ajax=True,target='my_form')}} > > check out LOAD function dochttp://www.web2py.com/AlterEgo/default/show/252 > > On 05/21/2010 12:09 AM, AsmanCom wrote: > > > Many thanks, it go�s in the right direction now. > > > I am using > > thehttp://app.ebansoftware.net/editable_jqgrid/default/show_example > > , but it is quite similar. > > > Now the is loaded is loaded with the default template and then a > > second layer covers it with the form and the default Template(loaded > > twice) > > > The code so far: > > > View: > > > {{extend 'layout.html'}} > > This is the default/test.html template > > {{=jqgrid_table}} > > > > jQuery(document).ready(function() > > {jQuery("#grid_id").jqGrid({onSelectRow: function(postdata) > > {web2py_ajax_page('get','/myapp/default/form/'+ > > (postdata),null,'my_form');}}); > > > > > > {{=LOAD('default','form',args=1,ajax=True,target='my_form')}} > > > Controller: > > > def jqgrid_table_test(): > > return > > dict(jqgrid_table=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_table',db_name='db')) > > > def form(): > > #id = request.args[0] > > form = SQLFORM(db.jqgrid_table) > > if form.accepts(request.vars, session): > > response.flash = 'form accepted' > > elif form.errors: > > response.flash = 'form has errors' > > else: > > response.flash = 'please fill out the form' > > return dict(form=form) > > > On 20 Mai, 16:55, Jason Lotz wrote: > > >> Are you using the web2py jqgrid_plugin? > > >>http://web2py.com/plugins/default/jqgrid > > >> On 05/20/2010 11:53 PM, AsmanCom wrote: > > >>> can this be caused by the function, which set in /static/ > >>> plugin_editable_jqgrid/plugin_editable_jqgrid.js ?: > > >>> onSelectRow: function(id){ > >>> if(id&& lastSel!=''&& id!==lastSel){ > >>> jQuery(grid_name).restoreRow(lastSel); > >>> } > >>> lastSel=id; > >>> jQuery(grid_name).editRow(id, true, '', '', '', '', > >>> function(rowid, resultText){reload(grid_name,rowid, resultText);}); > >>> }, > >>> colNames:col_names, > >>> colModel:col_models, > >>> pager: pager, > >>> rowNum:10, > >>> rowList:[10,100,1000], > >>> sortorder: 'desc', > >>> multiselect: true, > >>> multiboxonly:true, > >>> viewrecords: true, > >>> editurl:edit_url, > >>> caption: caption > >>> }); > > >>> Thank you in advance. > > >>> Dieter Asman > > >>> On 20 Mai, 15:52, Jason Lotz wrote: > > >>>> Try > > >>>> {{=jqgrid_table}} > >>>> > >>>> jQuery(document).ready(function(){ > >>>> jQuery("#grid_id").jqGrid({ > >>>> onSelectRow: function(postdata) { > >>>> web2py_ajax_page('get','/myapp/default/form/'+(postdata),null,'m
[web2py] Re: [SOLVED] jqgrid onSelectRow trigger web2py_component
I meant: The Grid is loaded with the default template and then a second layer covers it with the form and the default Template(loaded twice) ;-) On 20 Mai, 16:55, Jason Lotz wrote: > Are you using the web2py jqgrid_plugin? > > http://web2py.com/plugins/default/jqgrid > > On 05/20/2010 11:53 PM, AsmanCom wrote: > > > can this be caused by the function, which set in /static/ > > plugin_editable_jqgrid/plugin_editable_jqgrid.js ?: > > > onSelectRow: function(id){ > > if(id&& lastSel!=''&& id!==lastSel){ > > jQuery(grid_name).restoreRow(lastSel); > > } > > lastSel=id; > > jQuery(grid_name).editRow(id, true, '', '', '', '', > > function(rowid, resultText){reload(grid_name,rowid, resultText);}); > > }, > > colNames:col_names, > > colModel:col_models, > > pager: pager, > > rowNum:10, > > rowList:[10,100,1000], > > sortorder: 'desc', > > multiselect: true, > > multiboxonly:true, > > viewrecords: true, > > editurl:edit_url, > > caption: caption > > }); > > > Thank you in advance. > > > Dieter Asman > > > On 20 Mai, 15:52, Jason Lotz wrote: > > >> Try > > >> {{=jqgrid_table}} > >> > >> jQuery(document).ready(function(){ > >> jQuery("#grid_id").jqGrid({ > >> onSelectRow: function(postdata) { > >> web2py_ajax_page('get','/myapp/default/form/'+(postdata),null,'my_form');}}); > >> > > >> On 05/20/2010 10:45 PM, AsmanCom wrote: > > >>> Thanks for your effort, but it gives an empty page.. > >>> I will use two or more Grids at least one of them must keep the > >>> "editable" behaveure. > >>> But in this case it should work like your approach, controlling the > >>> form. > > >>> May i missed something..? > >>> Could you tell me how to set up the form? > > >>> should the view look something like that?: > > >>> {{=jqgrid_table}} > >>> > >>> jQuery("#grid_id").jqGrid({ > >>> onSelectRow: function(postdata) { > >>> web2py_ajax_page('get','/myapp/default/form/'+ > >>> (postdata),null,'my_form'); > >>> } > > >>> }); > >>> > >>> > >>> {{=form}} > > >>> Thank you in advance. > > >>> Dieter Asman > > >>> On 20 Mai, 14:54, Jason Lotz wrote: > > >>>> You could try passing SCRIPT from the controller. > > >>>> ## View > >>>> {{extend 'layout.html'}} > >>>> This is the default/test.html template > >>>> {{=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_ > >>>> table',db_name='db')}} > >>>> {{=script}} > > >>>> ## Controller > >>>> def jqgrid_table_test(): > >>>> script = """jQuery(document).ready(function(){ > >>>> jQuery("#grid_id").jqGrid({ > >>>> onSelectRow: function(postdata) > >>>> {web2py_ajax_page('get','/myapp/default/form/'+ > >>>> (postdata),null,'my_form'); }});""" > >>>> return SCRIPT(script) > > >>>> I haven't tested this so let me know if it works out for you. > > >>>> I am only using a single grid for my app so I actually included the > >>>> onSelectRow event to /models/jqgrid_plugin. The function > >>>> plugin_jqgrid() is where the default jqgrid script is retrieved when > >>>> the {{=plugin_jqgrid(db.table,columns=[...])}} is called. If you do it > >>>> this way you will want to add it to the .jqGrid({ }) parameters not in > >>>> the 'navGrid', 'toolbar' or other extended option parameters. > > >>>> Jay > > >>>> On May 20, 8:47 pm, AsmanCom wrote: > > >>>>> Could you help me setting this up too? > > >>>>> This is the view: > > >>>>> {{extend 'layout.html'}} > >>>>> This is the default/test.html template > >>>>> {{=jqgrid_table}} > >>>>> jQuery("#g
[web2py] Re: [SOLVED] jqgrid onSelectRow trigger web2py_component
Many thanks, it go´s in the right direction now. I am using the http://app.ebansoftware.net/editable_jqgrid/default/show_example , but it is quite similar. Now the is loaded is loaded with the default template and then a second layer covers it with the form and the default Template(loaded twice) The code so far: View: {{extend 'layout.html'}} This is the default/test.html template {{=jqgrid_table}} jQuery(document).ready(function() {jQuery("#grid_id").jqGrid({onSelectRow: function(postdata) {web2py_ajax_page('get','/myapp/default/form/'+ (postdata),null,'my_form');}}); {{=LOAD('default','form',args=1,ajax=True,target='my_form')}} Controller: def jqgrid_table_test(): return dict(jqgrid_table=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_table',db_name='db')) def form(): #id = request.args[0] form = SQLFORM(db.jqgrid_table) if form.accepts(request.vars, session): response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill out the form' return dict(form=form) On 20 Mai, 16:55, Jason Lotz wrote: > Are you using the web2py jqgrid_plugin? > > http://web2py.com/plugins/default/jqgrid > > On 05/20/2010 11:53 PM, AsmanCom wrote: > > > can this be caused by the function, which set in /static/ > > plugin_editable_jqgrid/plugin_editable_jqgrid.js ?: > > > onSelectRow: function(id){ > > if(id&& lastSel!=''&& id!==lastSel){ > > jQuery(grid_name).restoreRow(lastSel); > > } > > lastSel=id; > > jQuery(grid_name).editRow(id, true, '', '', '', '', > > function(rowid, resultText){reload(grid_name,rowid, resultText);}); > > }, > > colNames:col_names, > > colModel:col_models, > > pager: pager, > > rowNum:10, > > rowList:[10,100,1000], > > sortorder: 'desc', > > multiselect: true, > > multiboxonly:true, > > viewrecords: true, > > editurl:edit_url, > > caption: caption > > }); > > > Thank you in advance. > > > Dieter Asman > > > On 20 Mai, 15:52, Jason Lotz wrote: > > >> Try > > >> {{=jqgrid_table}} > >> > >> jQuery(document).ready(function(){ > >> jQuery("#grid_id").jqGrid({ > >> onSelectRow: function(postdata) { > >> web2py_ajax_page('get','/myapp/default/form/'+(postdata),null,'my_form');}}); > >> > > >> On 05/20/2010 10:45 PM, AsmanCom wrote: > > >>> Thanks for your effort, but it gives an empty page.. > >>> I will use two or more Grids at least one of them must keep the > >>> "editable" behaveure. > >>> But in this case it should work like your approach, controlling the > >>> form. > > >>> May i missed something..? > >>> Could you tell me how to set up the form? > > >>> should the view look something like that?: > > >>> {{=jqgrid_table}} > >>> > >>> jQuery("#grid_id").jqGrid({ > >>> onSelectRow: function(postdata) { > >>> web2py_ajax_page('get','/myapp/default/form/'+ > >>> (postdata),null,'my_form'); > >>> } > > >>> }); > >>> > >>> > >>> {{=form}} > > >>> Thank you in advance. > > >>> Dieter Asman > > >>> On 20 Mai, 14:54, Jason Lotz wrote: > > >>>> You could try passing SCRIPT from the controller. > > >>>> ## View > >>>> {{extend 'layout.html'}} > >>>> This is the default/test.html template > >>>> {{=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_ > >>>> table',db_name='db')}} > >>>> {{=script}} > > >>>> ## Controller > >>>> def jqgrid_table_test(): > >>>> script = """jQuery(document).ready(function(){ > >>>> jQuery("#grid_id").jqGrid({ > >>>> onSelectRow: function(postdata) > >>>> {web2py_ajax_page('get','/myapp/default/form/'+ > >>>> (postdata),null,'my_form'); }});""" > >>>> return SCRIPT(script) > >
[web2py] Re: [SOLVED] jqgrid onSelectRow trigger web2py_component
can this be caused by the function, which set in /static/ plugin_editable_jqgrid/plugin_editable_jqgrid.js ?: onSelectRow: function(id){ if(id && lastSel!='' && id!==lastSel){ jQuery(grid_name).restoreRow(lastSel); } lastSel=id; jQuery(grid_name).editRow(id, true, '', '', '', '', function(rowid, resultText){reload(grid_name,rowid, resultText);}); }, colNames:col_names, colModel:col_models, pager: pager, rowNum:10, rowList:[10,100,1000], sortorder: 'desc', multiselect: true, multiboxonly:true, viewrecords: true, editurl:edit_url, caption: caption }); Thank you in advance. Dieter Asman On 20 Mai, 15:52, Jason Lotz wrote: > Try > > {{=jqgrid_table}} > > jQuery(document).ready(function(){ > jQuery("#grid_id").jqGrid({ > onSelectRow: function(postdata) { > web2py_ajax_page('get','/myapp/default/form/'+(postdata),null,'my_form');}}); > > > On 05/20/2010 10:45 PM, AsmanCom wrote: > > > Thanks for your effort, but it gives an empty page.. > > I will use two or more Grids at least one of them must keep the > > "editable" behaveure. > > But in this case it should work like your approach, controlling the > > form. > > > May i missed something..? > > Could you tell me how to set up the form? > > > should the view look something like that?: > > > {{=jqgrid_table}} > > > > jQuery("#grid_id").jqGrid({ > > onSelectRow: function(postdata) { > > web2py_ajax_page('get','/myapp/default/form/'+ > > (postdata),null,'my_form'); > > } > > > }); > > > > > > {{=form}} > > > Thank you in advance. > > > Dieter Asman > > > On 20 Mai, 14:54, Jason Lotz wrote: > > >> You could try passing SCRIPT from the controller. > > >> ## View > >> {{extend 'layout.html'}} > >> This is the default/test.html template > >> {{=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_ > >> table',db_name='db')}} > >> {{=script}} > > >> ## Controller > >> def jqgrid_table_test(): > >> script = """jQuery(document).ready(function(){ > >> jQuery("#grid_id").jqGrid({ > >> onSelectRow: function(postdata) > >> {web2py_ajax_page('get','/myapp/default/form/'+ > >> (postdata),null,'my_form'); }});""" > >> return SCRIPT(script) > > >> I haven't tested this so let me know if it works out for you. > > >> I am only using a single grid for my app so I actually included the > >> onSelectRow event to /models/jqgrid_plugin. The function > >> plugin_jqgrid() is where the default jqgrid script is retrieved when > >> the {{=plugin_jqgrid(db.table,columns=[...])}} is called. If you do it > >> this way you will want to add it to the .jqGrid({ }) parameters not in > >> the 'navGrid', 'toolbar' or other extended option parameters. > > >> Jay > > >> On May 20, 8:47 pm, AsmanCom wrote: > > >>> Could you help me setting this up too? > > >>> This is the view: > > >>> {{extend 'layout.html'}} > >>> This is the default/test.html template > >>> {{=jqgrid_table}} > >>> jQuery("#grid_id").jqGrid({ > >>> onSelectRow: function(postdata) { > >>> web2py_ajax_page('get','/myapp/default/form/'+ > >>> (postdata),null,'my_form'); > >>> } > > >>> }); > > >>> This is the Controller: > > >>> def jqgrid_table_test(): > >>> return > >>> dict(jqgrid_table=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_ > >>> table',db_name='db')) > > >>> def form(): > >>> id = request.args[0] > >>> form=FORM(TABLE(TR("Your > >>> name:",INPUT(_type="text",_name="name",requires=IS_NOT_EMPTY())), > >>> TR("Your > >>> email:",INPUT(_type="text",_name="email",requires=IS_EMAIL())), > >>> TR("Admin",INPUT(_type="checkbox",_name="admin")), > > >>> TR("Sure?",SELECT('yes&
[web2py] Re: [SOLVED] jqgrid onSelectRow trigger web2py_component
I tried like that: View: {{=jqgrid_table}} jQuery(document).ready(function(){ jQuery("#grid_id").jqGrid({ onSelectRow: function(postdata) {web2py_ajax_page('get','/myapp/ default/form/'+(postdata),null,'my_form');}}); Controller: def jqgrid_table_test(): return dict(jqgrid_table=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_table',db_name='db')) def form(): #id = request.args[0] form = SQLFORM(db.jqgrid_table) if form.accepts(request.vars, session): response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill out the form' return dict(form=form) ## Now the Grid is showed, but no form. do you have any further suggestions? Thank you in advance. Dieter Asman On 20 Mai, 15:52, Jason Lotz wrote: > Try > > {{=jqgrid_table}} > > jQuery(document).ready(function(){ > jQuery("#grid_id").jqGrid({ > onSelectRow: function(postdata) { > web2py_ajax_page('get','/myapp/default/form/'+(postdata),null,'my_form');}}); > > > On 05/20/2010 10:45 PM, AsmanCom wrote: > > > Thanks for your effort, but it gives an empty page.. > > I will use two or more Grids at least one of them must keep the > > "editable" behaveure. > > But in this case it should work like your approach, controlling the > > form. > > > May i missed something..? > > Could you tell me how to set up the form? > > > should the view look something like that?: > > > {{=jqgrid_table}} > > > > jQuery("#grid_id").jqGrid({ > > onSelectRow: function(postdata) { > > web2py_ajax_page('get','/myapp/default/form/'+ > > (postdata),null,'my_form'); > > } > > > }); > > > > > > {{=form}} > > > Thank you in advance. > > > Dieter Asman > > > On 20 Mai, 14:54, Jason Lotz wrote: > > >> You could try passing SCRIPT from the controller. > > >> ## View > >> {{extend 'layout.html'}} > >> This is the default/test.html template > >> {{=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_ > >> table',db_name='db')}} > >> {{=script}} > > >> ## Controller > >> def jqgrid_table_test(): > >> script = """jQuery(document).ready(function(){ > >> jQuery("#grid_id").jqGrid({ > >> onSelectRow: function(postdata) > >> {web2py_ajax_page('get','/myapp/default/form/'+ > >> (postdata),null,'my_form'); }});""" > >> return SCRIPT(script) > > >> I haven't tested this so let me know if it works out for you. > > >> I am only using a single grid for my app so I actually included the > >> onSelectRow event to /models/jqgrid_plugin. The function > >> plugin_jqgrid() is where the default jqgrid script is retrieved when > >> the {{=plugin_jqgrid(db.table,columns=[...])}} is called. If you do it > >> this way you will want to add it to the .jqGrid({ }) parameters not in > >> the 'navGrid', 'toolbar' or other extended option parameters. > > >> Jay > > >> On May 20, 8:47 pm, AsmanCom wrote: > > >>> Could you help me setting this up too? > > >>> This is the view: > > >>> {{extend 'layout.html'}} > >>> This is the default/test.html template > >>> {{=jqgrid_table}} > >>> jQuery("#grid_id").jqGrid({ > >>> onSelectRow: function(postdata) { > >>> web2py_ajax_page('get','/myapp/default/form/'+ > >>> (postdata),null,'my_form'); > >>> } > > >>> }); > > >>> This is the Controller: > > >>> def jqgrid_table_test(): > >>> return > >>> dict(jqgrid_table=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_ > >>> table',db_name='db')) > > >>> def form(): > >>> id = request.args[0] > >>> form=FORM(TABLE(TR("Your > >>> name:",INPUT(_type="text",_name="name",requires=IS_NOT_EMPTY())), > >>> TR("Your > >>> email:",INPUT(_type="text",_name="email",requires=IS_EMAIL())), >
[web2py] Re: [SOLVED] jqgrid onSelectRow trigger web2py_component
Thanks for your effort, but it gives an empty page.. I will use two or more Grids at least one of them must keep the "editable" behaveure. But in this case it should work like your approach, controlling the form. May i missed something..? Could you tell me how to set up the form? should the view look something like that?: {{=jqgrid_table}} jQuery("#grid_id").jqGrid({ onSelectRow: function(postdata) { web2py_ajax_page('get','/myapp/default/form/'+ (postdata),null,'my_form'); } }); {{=form}} Thank you in advance. Dieter Asman On 20 Mai, 14:54, Jason Lotz wrote: > You could try passing SCRIPT from the controller. > > ## View > {{extend 'layout.html'}} > This is the default/test.html template > {{=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_ > table',db_name='db')}} > {{=script}} > > ## Controller > def jqgrid_table_test(): > script = """jQuery(document).ready(function(){ > jQuery("#grid_id").jqGrid({ > onSelectRow: function(postdata) > {web2py_ajax_page('get','/myapp/default/form/'+ > (postdata),null,'my_form'); }});""" > return SCRIPT(script) > > I haven't tested this so let me know if it works out for you. > > I am only using a single grid for my app so I actually included the > onSelectRow event to /models/jqgrid_plugin. The function > plugin_jqgrid() is where the default jqgrid script is retrieved when > the {{=plugin_jqgrid(db.table,columns=[...])}} is called. If you do it > this way you will want to add it to the .jqGrid({ }) parameters not in > the 'navGrid', 'toolbar' or other extended option parameters. > > Jay > > On May 20, 8:47 pm, AsmanCom wrote: > > > Could you help me setting this up too? > > > This is the view: > > > {{extend 'layout.html'}} > > This is the default/test.html template > > {{=jqgrid_table}} > > jQuery("#grid_id").jqGrid({ > > onSelectRow: function(postdata) { > > web2py_ajax_page('get','/myapp/default/form/'+ > > (postdata),null,'my_form'); > > } > > > }); > > > This is the Controller: > > > def jqgrid_table_test(): > > return > > dict(jqgrid_table=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_ > > table',db_name='db')) > > > def form(): > > id = request.args[0] > > form=FORM(TABLE(TR("Your > > name:",INPUT(_type="text",_name="name",requires=IS_NOT_EMPTY())), > > TR("Your > > email:",INPUT(_type="text",_name="email",requires=IS_EMAIL())), > > TR("Admin",INPUT(_type="checkbox",_name="admin")), > > > TR("Sure?",SELECT('yes','no',_name="sure",requires=IS_IN_SET(['yes','no'])) > > ), > > TR("Profile",TEXTAREA(_name="profile",value="write > > something here")), > > TR("",INPUT(_type="submit",_value="SUBMIT" > > if form.accepts(request.vars,session): > > response.flash="form accepted" > > elif form.errors: > > response.flash="form is invalid" > > else: > > response.flash="please fill the form" > > return dict(form=form,vars=form.vars) > > > > > > The JQGrid works, but underneath the Grid i only see the following > > text: > > jQuery("#grid_id").jqGrid({ onSelectRow: function(postdata) > > { web2py_ajax_page('get','/core/default/form/'+ > > (postdata),null,'my_form'); } }); > > > It would be very nice if you could help me gettin this to work. > > Thank you in advance. > > > Dieter Asman > > > On 17 Mai, 08:22, Jason Lotz wrote: > > > > Thanks mdipierro!! > > > > I actually saw that in the header of the generated page but didn't put > > > it together. For what ever reason, trying to call web2py_component > > > from another function wouldn't work, but calling web2py_ajax_page > > > directly worked! > > > > Working code: > > > > jQuery("#grid_id").jqGrid({ > > > onSelectRow: function(postdata) { > > > web2py_ajax_page('get
[web2py] Re: [SOLVED] jqgrid onSelectRow trigger web2py_component
Could you help me setting this up too? This is the view: {{extend 'layout.html'}} This is the default/test.html template {{=jqgrid_table}} jQuery("#grid_id").jqGrid({ onSelectRow: function(postdata) { web2py_ajax_page('get','/myapp/default/form/'+ (postdata),null,'my_form'); } }); This is the Controller: def jqgrid_table_test(): return dict(jqgrid_table=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_table',db_name='db')) def form(): id = request.args[0] form=FORM(TABLE(TR("Your name:",INPUT(_type="text",_name="name",requires=IS_NOT_EMPTY())), TR("Your email:",INPUT(_type="text",_name="email",requires=IS_EMAIL())), TR("Admin",INPUT(_type="checkbox",_name="admin")), TR("Sure?",SELECT('yes','no',_name="sure",requires=IS_IN_SET(['yes','no']))), TR("Profile",TEXTAREA(_name="profile",value="write something here")), TR("",INPUT(_type="submit",_value="SUBMIT" if form.accepts(request.vars,session): response.flash="form accepted" elif form.errors: response.flash="form is invalid" else: response.flash="please fill the form" return dict(form=form,vars=form.vars) The JQGrid works, but underneath the Grid i only see the following text: jQuery("#grid_id").jqGrid({ onSelectRow: function(postdata) { web2py_ajax_page('get','/core/default/form/'+ (postdata),null,'my_form'); } }); It would be very nice if you could help me gettin this to work. Thank you in advance. Dieter Asman On 17 Mai, 08:22, Jason Lotz wrote: > Thanks mdipierro!! > > I actually saw that in the header of the generated page but didn't put > it together. For what ever reason, trying to call web2py_component > from another function wouldn't work, but calling web2py_ajax_page > directly worked! > > Working code: > > jQuery("#grid_id").jqGrid({ > onSelectRow: function(postdata) { > web2py_ajax_page('get','/Test/default/a_form/'+ > (postdata),null,'my_form'); > } > > }); > > Jay > > On May 17, 2:35 pm, mdipierro wrote: > > > This is the definition of web2py_component > > > function web2py_component(action,target) > > { > > jQuery(document).ready(function() > > { web2py_ajax_page('get',action,null,target); }); > > > } > > > I think you just want to call web2py_ajax_page instead of > > web2py_component. > > > On May 16, 11:50 pm, Jason Lotz wrote: > > > > I was using an iframe to show the details of a selected row from > > > jqgrid. Which worked. However I realized that it is a pain to get > > > iframe to recognize parent size so resizing produces an awkward > > > looking form. I came across web2py LOAD helper and thought it to be a > > > good fix to my frame resizing issue. > > > > I'm trying to change a LOAD(form) based on the row_id from a selected > > > row in jqgrid. Using the jqgrid event onSelectRow I'm trying to > > > trigger web2py_component to reload the form. > > > > I came up with a test link to update the form, which worked. > > > > > > onclick="web2py_component('{{=URL(...)}}','my_form');">Load Page 3 > > > {{=LOAD('default','a_form/1',ajax=True,target='my_form')}} > > > > If possible I would like to get jqgrid to trigger the same > > > web2py_component feature. > > > > My latest failed attempt was something like > > > > jQuery(document.ready(function(){ > > > onSelectRow: function() > > > { jQuery("#my_form").trigger('web2py_component',['/Test/default/ > > > a_form/'+(postdata),'my_form']);} > > > ;}) > > > > Is it possible to trigger web2py_component function or LOAD helper > > > without an action input (button or link)? > > > > Jay > >
[web2py] Re: jqgrid onSelectRow refresh iframe
Hi, i am working with JQGrid plugin too. Just to get your approach right.. you´ve realised a Master-Detail function with the JQGrid? Very nice! May i can use this too. Is the code(for Controller, View) from your last post working, right now? Did you made any changes to the ##model code? I am trying to implemented the "Subgrid" feature: http://www.trirand.com/blog/jqgrid/jqgrid.html ->"New since beta 3.0" ->"subgrid with JSON Data" This could be a nice feature, and also it would be cool to let the grid show Images from the "upload" Field. Dieter Asman On 14 Mai, 11:32, Jason Lotz wrote: > Sorry to keep replying to myself. Just wanted to let you know my > progress. After stepping back and evaluating the case I managed to > configure it as I wanted. > > ## View > jQuery(document).ready(function(){jQuery("#%(id)s").jqGrid({ > onSelectRow: function(postdata){$("#myframe").attr('src',"/MyApp/ > default/details/"+(postdata));} > > }); > > ## Controller > def details(): > id = request.args[0] > // everything else > return dict() > > Jay > > On May 14, 5:58 pm, Jason Lotz wrote: > > > The first and obvious thing I see I did wrong was trying to put python > > into jquery script. > > > jQuery("#%(id)s").jqGrid({ onSelectRow: function() { > > $ > > ('#myframe').attr('src',"{{=URL(r=request,f='details',args=2)}}");} > > > But I still don't understand how I can make it dynamic src, or how to > > get jquery to communicate with the server. > > > Jay > > > On May 14, 4:59 pm, Jason Lotz wrote: > > > > Now I have two containers, one includes jqgrid_plugin the other > > > includes iframe to display /default/details view. Both work fine on > > > the initial load of the page. Using jqgrid onSelectRow event I tried > > > to add a function to update the iframe page. > > > > ## View > > > > > > {{=plugin_jqgrid(db.test,columns=['fields'],height=200)}} > > > > > > > > > > > iframe> > > > > > > > ## model > > > jQuery(document).ready(function(){ > > > jQuery("#%(id)s").jqGrid({ onSelectRow: function() {$ > > > ('#myframe').attr('src',"{{=URL(r=request,f='details',args=2)}}");} > > > > }); > > > > However when a row is selected the iframe returns Invalid Request. > > > It's not even calling the controller, just displays Invalid Request. I > > > haven't quite figured out how to get jqgrid and the server > > > communicating. I've been able to show grid values using alert and get > > > jquery to handle data sent from server but can't get jqgrid to trigger > > > the server and the server read jqgrid.Parameters. > > > > Any suggestions as to the best way to update iframe contents by > > > selecting a row? And/Or someone kindly provide some sort of > > > explanation how jquery and server communicate would be greatly > > > appreciated !!.. > > > > Jay > >
[web2py] Re: JqGrid Plugin
@Andrea Your plugin is absolutely awesome, that´s what i´ve looked for! Are going to implement further JQGrid functions in the near future? I would appreciate if the "Subgrid" feature would be implemented in the plugin: http://www.trirand.com/blog/jqgrid/jqgrid.html ->"New since beta 3.0" ->"subgrid with JSON Data" OR If anyone could help me up a little adapt this feature for the existing plugin? Thank you in anticipation! Dieter Asman On 27 Mrz., 18:51, parroit wrote: > Hi. I've developed a plugin to useJqGridwith inline editing and json > updates. > I've published some help at this page:http://app.ebansoftware.net, > but I think it be more useful > to publish it also onhttp://www.web2py.com/plugins. What is the > correct procedure > to publish the plugin on that site? > > Thanks > > Andrea
[web2py] Re: Catch and replace vars
That would be a great solution, but i´ve to do this in model because i am using the awesome JQGrid plugin (app.ebansoftware.net/ editable_jqgrid/). The dilemma is: - I need to do this in the model - I can`t get the vars from table.field.default (self-evident) - I need a working IS_IN_DB(db,'table.id','table.name') validator and label (for the JQGrid plugin) - I can´t add an aditional validator (because IS_IN_DB +label don´t show up right, when combined with other validators) - The form must be visible to the user, so i can´t go with table.field.compute So I think to implement this with Field default function is the right approach? But I need to catch the vars, compute someth. and Insert. Any ideas? On 10 Mai, 19:47, Iceberg wrote: > Model: > db.define_table('table_1', > Field('field_1'), > Field('field_2') > ) > > Controller: > def index(): > def magic(form): > form.vars.field_2 = form.vars.field_1 > form = SQLFORM(db.table_1) > if form.accepts(request.vars, onvalidation=magic): > pass # ok > return {'form': form} > > I did not test it. But it shows you the key of using onvalidation() > trick. > > Regards, > Iceberg > > On May11, 12:08am, AsmanCom wrote: > > > Hi, > > > i want to do a simple task: > > > def function_1(): > > var_field_1=request.vars.field_1 > > if var_field_1: > > return var_field_1 > > > db.define_table('table_1', > > Field('field_1','string' ), > > Field('field_2', default=function_1) > > ) > > > db.table_1.field_1.default='Autogenerated' > > db.table_1.field_2.default='Autogenerated' > > > I want to catch default vars from field 1 and insert them in field_2 > > instead. > > Is this possible? > > > ###becomes interesting when combined, with IS_IN_DB and the > > get_or_create function### > >
[web2py] Catch and replace vars
Hi, i want to do a simple task: def function_1(): var_field_1=request.vars.field_1 if var_field_1: return var_field_1 db.define_table('table_1', Field('field_1','string' ), Field('field_2', default=function_1) ) db.table_1.field_1.default='Autogenerated' db.table_1.field_2.default='Autogenerated' I want to catch default vars from field 1 and insert them in field_2 instead. Is this possible? ###becomes interesting when combined, with IS_IN_DB and the get_or_create function###
[web2py] Re: Reverse Search with .like
Hey Guys, that helped a lot! with a lil correction it works very nice. Thanks for the Support. On 8 Mai, 04:18, Russell wrote: > You might want to try something like this:. > > from gluon.sql import Expression > db(table1.field1.like(Expression("('%' || table2.field2 || > '%')".select(db.table1.field1) > > Not very pretty, but it does work. > > On May 8, 9:13 am, mdipierro wrote: > > > Can you try > > > from gluon.sql import Query > > print db(Query(" '%' || NEW.field_1 || '%' LIKE table_1.field_1 > > "))._select(db.table_1.field_1) > > > Do you get the query you want? > > > On May 7, 10:48 am, AsmanCom wrote: > > > > It returns nothing... even if I write in the exact value and it should > > > work like a fuzzy logic.. > > > like that: > > > > find_value= request.vars.value > > > > db('%' + table_1.field_1 + > > > '%').lower().like(find_value).select(db.table_1.field_1) > > > > or > > > > db('%' + table_1.field_1 + '%').lower().like('%' + find_value + > > > '%').select(db.table_1.field_1) > > > > Any Idea? > > > > On 7 Mai, 17:03, mdipierro wrote: > > > > > This should work > > > > > db("'%' || NEW.field_1 || '%' LIKE > > > > table_1.field_1").select(db.table_1.field_1) > > > > > On May 7, 9:35 am, AsmanCom wrote: > > > > > > Hi, > > > > > > here is the important Code from an Sqlite trigger i use very often, is > > > > > this possible with web2py to? > > > > > > Sqlite: > > > > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' > > > > > LIKE table_1.field_1 ) > > > > > > or i can even do: > > > > > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' > > > > > LIKE '%' || table_1.field_1 || '%' ) > > > > > > w2p: > > > > > db.person.name.lower().like(‘m%’)
[web2py] Re: Reverse Search with .like
I´ll try to explain, I need check if any record of a given field is contained in a string. Is there any solution? On 7 Mai, 17:03, mdipierro wrote: > This should work > > db("'%' || NEW.field_1 || '%' LIKE > table_1.field_1").select(db.table_1.field_1) > > On May 7, 9:35 am, AsmanCom wrote: > > > Hi, > > > here is the important Code from an Sqlite trigger i use very often, is > > this possible with web2py to? > > > Sqlite: > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' > > LIKE table_1.field_1 ) > > > or i can even do: > > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' > > LIKE '%' || table_1.field_1 || '%' ) > > > w2p: > > db.person.name.lower().like(‘m%’)
[web2py] Re: Reverse Search with .like
It returns nothing... even if I write in the exact value and it should work like a fuzzy logic.. like that: find_value= request.vars.value db('%' + table_1.field_1 + '%').lower().like(find_value).select(db.table_1.field_1) or db('%' + table_1.field_1 + '%').lower().like('%' + find_value + '%').select(db.table_1.field_1) Any Idea? On 7 Mai, 17:03, mdipierro wrote: > This should work > > db("'%' || NEW.field_1 || '%' LIKE > table_1.field_1").select(db.table_1.field_1) > > On May 7, 9:35 am, AsmanCom wrote: > > > Hi, > > > here is the important Code from an Sqlite trigger i use very often, is > > this possible with web2py to? > > > Sqlite: > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' > > LIKE table_1.field_1 ) > > > or i can even do: > > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' > > LIKE '%' || table_1.field_1 || '%' ) > > > w2p: > > db.person.name.lower().like(‘m%’)
[web2py] Re: Reverse Search with .like
The || operator is "concatenate", its like + in python. On 7 Mai, 16:48, Mengu wrote: > is || just a string or have any purpose? > > On 7 Mayıs, 17:35, AsmanCom wrote: > > > Hi, > > > here is the important Code from an Sqlite trigger i use very often, is > > this possible with web2py to? > > > Sqlite: > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' > > LIKE table_1.field_1 ) > > > or i can even do: > > > (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' > > LIKE '%' || table_1.field_1 || '%' ) > > > w2p: > > db.person.name.lower().like(‘m%’)
[web2py] Reverse Search with .like
Hi, here is the important Code from an Sqlite trigger i use very often, is this possible with web2py to? Sqlite: (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' LIKE table_1.field_1 ) or i can even do: (SELECT table_1.field_1 FROM table_1 WHERE '%' || NEW.field_1 || '%' LIKE '%' || table_1.field_1 || '%' ) w2p: db.person.name.lower().like(‘m%’)
[web2py] Reference Fields
1. In this Example i need to take the input string from table_1.field_1 and get_or_create a record in table_2 with table_1.field_1 value in table_2.field_1 and insert the table_2.field_2 refernce in table_1.field_2: def get_or_create(table, fields): logic=reduce(lambda a,b:a&b,[table[k]==fields[k] for k in fields]) record = db_bluetooth(logic).select(table['id'],limitby=(0,1)).first() if record: return record.id else: return table.insert(**fields).id def get_reference_3(): value=request.vars.field_1 if value: get_table2_id=get_or_create(db.table2, {'field_1': value,}) query=(db.table_2.id==get_table_2_id) record = db(query).select(db.table_2.field_2) return record else: pass db.define_table('table_1', Field('field_1','string', default=get_reference_3), Field('field_2', db.table_3) ) db.table1.field_2.requires=IS_IN_DB(db,'table_3.id','table_3.field1') db.define_table('table_2', Field('field_1','string'), Field('field_2', db.table_3) ) db.table2.field_2.requires=IS_IN_DB(db,'table_3.id','table_3.field1') db.define_table('table_3', Field('field_1','string') ) # 2. and i need to know how to do this: lets say we have two IS_IN_DB dropdown-lists in a table, like this drop-down_1 drop-down_2 major_item_1 minor_1_major1 major_item_2 minor_2_major1 major_item_3 minor_3_major2 minor_4_major3 when the user selects major_item_1, only minor 1 and 2 should be available in drop_down_2 Thank you.
[web2py] Re: Ext JS REST Grid + WEB2PY CRUD ?
Hi, yeah i´ve to expose CRUD functions by JSON or XML to the JS client. Like ist done here in PHP: http://www.extjs.com/deploy/dev/examples/writer/writer.html But I need an Code example for web2py, I think. That should be simple right? Because it has all been done before Should be similar connecting web2py to JQ Datatables? What i need is an Real-Time DB view such as: http://www.extjs.com/deploy/dev/examples/direct/direct.php But connected to web2py Can anybody help me up? Thank you in advance. Dieter Asman On 3 Mrz., 01:26, "mr.freeze" wrote: > I would use an xml service to feed the grid data instead. > > http://web2py.com/book/default/section/9/2?search=%40service.xmlhttp://www.extjs.com/deploy/dev/examples/grid/xml-grid.html > > On Mar 2, 7:35 am, AsmanCom wrote: > > > Hi, > > > any idea how to make the Ext JS Grids woking with > > WEB2PY?http://www.extjs.com/deploy/dev/examples/#sample-3 > > > In particular the RESTful > > Store:http://www.extjs.com/deploy/dev/examples/restful/restful.html > > > I think it must be connected to CRUD somehow? > > Any Examples to connect such JS Grids to the WEB2PY DB ? > > > Thank you in advance. > > > Dieter Asman -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Ext JS REST Grid + WEB2PY CRUD ?
Hi, any idea how to make the Ext JS Grids woking with WEB2PY? http://www.extjs.com/deploy/dev/examples/#sample-3 In particular the RESTful Store: http://www.extjs.com/deploy/dev/examples/restful/restful.html I think it must be connected to CRUD somehow? Any Examples to connect such JS Grids to the WEB2PY DB ? Thank you in advance. Dieter Asman -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: Download and Update Progress +a general question
@Thadeus Burgess If rendering the standard output from scripts is not natively supported, there must be a better solution than changing the prog. language. a real-time logger or something like that. Best regards, Dieter Asman - AsmanCom - Germany On 24 Feb., 23:14, Thadeus Burgess wrote: > ... > > response.write("hello world", escape=False) > > The issue is that you will not see until the request actually > finishes. There is no way to "stream" text to the server in the way > that you are asking unless using a system such as "comet" > > -Thadeus > > On Wed, Feb 24, 2010 at 4:09 PM, Tiago Almeida > > wrote: > > can redirect stdout to a string. Execute your untouched -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
[web2py] Re: Download and Update Progress +a general question
@Dragonfyre >have something in the >controller display realtime like the print command, instead of display >all of the information at once) You got it! I need a solution to run standard Python scripts and render the output in my browser. with less effort. +a solution to update the Progressbar from my functions (1. donload text file in %, 2. import text file line by line to the DB in %) to show the Progress in browser window. Best regards, Dieter Asman - AsmanCom - Germany On 24 Feb., 23:01, Dragonfyre13 wrote: > So, let me make sure I understand this right, you want to stream the > response, from the server, to the browser. (have something in the > controller display realtime like the print command, instead of display > all of the information at once) > > Or, are you talking about actually using print, and having it output > to the page? For that I redirect stdout to a stringIO var, and then > simply read the variable out to the view. > > On Feb 24, 11:33 am, AsmanCom wrote: > > > Hi Tiango, > > > no i need an equivalent for print, like: > > > def print_1(): > > print "1" > > print "2" > > = > > 1 > > 2 > > > def print_2(): > > while True: > > print "1" > > = > > 1 > > 1 > > 1 > > 1 > > ... > > > I need to execute scripts like in terminal, but output rendered in > > html. (should be very simple?) > > > Best regards, > > > Dieter Asman > > > - AsmanCom - > > Germany > > > On 24 Feb., 18:17, Tiago Almeida wrote: > > > > > for quick development-shots, i need to execute my untouched(may i > > > > could change "print" to "return") Python scripts(..with loops) in the > > > > Controller. > > > > The output should be renderd direct via http, without long-winded > > > > setting up the view for each function. > > > > Is that possible? > > > > If I understand you want to return a string directly without being > > > processed > > > by the view. > > > On a controller function, if you return a string (not a dict) it will be > > > rendered as is. > > > > Tiago > > > -- > > > > On Wed, Feb 24, 2010 at 4:48 PM, AsmanCom wrote: > > > > Hi, > > > > > for quick development-shots, i need to execute my untouched(may i > > > > could change "print" to "return") Python scripts(..with loops) in the > > > > Controller. > > > > The output should be renderd direct via http, without long-winded > > > > setting up the view for each function. > > > > Is that possible? > > > > > To my next concern > > > > > On my actual Project i have simple form field with submit button on my > > > > controller: > > > > form = SQLFORM.factory(Field('update_url', default='http://.domain.org/ > > > > text_file.txt <http://domain.org/%0Atext_file.txt>', > > > > requires=IS_NOT_EMPTY())) > > > > > On Submit the text file should be downloaded to Server indicated by an > > > > Progress Bar on the Page. > > > > Next the file should be inserted to the DB line by line(for loop with > > > > regex) and again indicated by the same Progress Bar . > > > > > My Code so far(... relies on clienttools example specifically on > > > > jqueryUI-progressbar and an urllib2 +report_hook snippet i´ve found > > > > somewhere): > > > > ___ > > > > def chunk_report(bytes_so_far, chunk_size, total_size): > > > > percent = float(bytes_so_far) / total_size > > > > percent = round(percent*100) > > > > return percent > > > > > if bytes_so_far >= total_size: > > > > return ('100.0') > > > > > def chunk_read(response, chunk_size=8192, report_hook=None): > > > > total_size = response.info().getheader('Content-Length').strip() > > > > total_size = int(total_size) > > > > bytes_so_far = 0 > > > > > while 1: > > > > chunk = response.read(chunk_size) > > > > bytes_so_far += len(chunk) > > > > > if not chunk: > > > > break > > > > > if report_hook: > > > > report_hook(bytes_so_far, chunk_size, total_size) > > > > > percent = f
[web2py] Re: Download and Update Progress +a general question
Yo Tiango, many thanks for your effort. But if you say: > this is horrible! I´ll forget about that. > The least you should do is transform your scripts > so that instead of printing, they return the strings that's what i meant with: "(may i could change "print" to "return")" But i don´t know how to do this? May we could return to my example: def chunk_report(bytes_so_far, chunk_size, total_size): percent = float(bytes_so_far) / total_size percent = round(percent*100) return percent which is called by the def chunk_read: while 1: chunk = response.read(chunk_size) bytes_so_far += len(chunk) if not chunk: break if report_hook: report_hook(bytes_so_far, chunk_size, total_size) How to display the output of chunk_report properly? (or how to update the ProgressBar with that output?) Best regards, Dieter Asman - AsmanCom - Germany On 24 Feb., 23:09, Tiago Almeida wrote: > This is nasty as hell but you can redirect stdout to a string. Execute your > untouched scripts, all they print goes to the string and then, in the web2py > controller return that string instead of a dict. > > Example: > -- file print1_script.py: -- > def print1(): > print "1" > > #call print1 > print1() > > -- file whatever.py: -- > import sys > from cStringIO import StringIO > > #redirect stdout to string > sys.stdout = mystdout = StringIO() > > #execute script print1_script.py > execfile('print1_script.py') > > #reset the stdout > sys.stdout = sys.__stdout__ > > #the output is available *as a string* in mystdout.getvalue() > print mystdout.getvalue() > > --- end -- > > Again, this is horrible! The least you should do is transform your scripts > so that instead of printing, they return the strings. Then in web2py > controller you just return whatever your function returns. > > Regards, > Tiago > > > On Wed, Feb 24, 2010 at 5:33 PM, AsmanCom wrote: > > Hi Tiango, > > > no i need an equivalent for print, like: > > > def print_1(): > > print "1" > > print "2" > > = > > 1 > > 2 > > > def print_2(): > > while True: > > print "1" > > = > > 1 > > 1 > > 1 > > 1 > > ... > > > I need to execute scripts like in terminal, but output rendered in > > html. (should be very simple?) > > > Best regards, > > > Dieter Asman > > > - AsmanCom - > > Germany > > > On 24 Feb., 18:17, Tiago Almeida wrote: > > > > for quick development-shots, i need to execute my untouched(may i > > > > could change "print" to "return") Python scripts(..with loops) in the > > > > Controller. > > > > The output should be renderd direct via http, without long-winded > > > > setting up the view for each function. > > > > Is that possible? > > > > If I understand you want to return a string directly without being > > processed > > > by the view. > > > On a controller function, if you return a string (not a dict) it will be > > > rendered as is. > > > > Tiago > > > -- > > > > On Wed, Feb 24, 2010 at 4:48 PM, AsmanCom wrote: > > > > Hi, > > > > > for quick development-shots, i need to execute my untouched(may i > > > > could change "print" to "return") Python scripts(..with loops) in the > > > > Controller. > > > > The output should be renderd direct via http, without long-winded > > > > setting up the view for each function. > > > > Is that possible? > > > > > To my next concern > > > > > On my actual Project i have simple form field with submit button on my > > > > controller: > > > > form = SQLFORM.factory(Field('update_url', default='http://. > > domain.org/ > > > > text_file.txt <http://domain.org/%0Atext_file.txt>', > > > > requires=IS_NOT_EMPTY())) > > > > > On Submit the text file should be downloaded to Server indicated by an > > > > Progress Bar on the Page. > > > > Next the file should be inserted to the DB line by line(for loop with > > > > regex) and again indicated by the same Progress Bar . > > > > > My Code so far(... relies on clienttools example specifically on > > > > jqueryUI-progressbar and an urllib2 +report_hook snippet i´ve found > > > > somewhere): > > > >
[web2py] Re: Download and Update Progress +a general question
Hi Tiango, no i need an equivalent for print, like: def print_1(): print "1" print "2" = 1 2 def print_2(): while True: print "1" = 1 1 1 1 ... I need to execute scripts like in terminal, but output rendered in html. (should be very simple?) Best regards, Dieter Asman - AsmanCom - Germany On 24 Feb., 18:17, Tiago Almeida wrote: > > for quick development-shots, i need to execute my untouched(may i > > could change "print" to "return") Python scripts(..with loops) in the > > Controller. > > The output should be renderd direct via http, without long-winded > > setting up the view for each function. > > Is that possible? > > If I understand you want to return a string directly without being processed > by the view. > On a controller function, if you return a string (not a dict) it will be > rendered as is. > > Tiago > -- > > On Wed, Feb 24, 2010 at 4:48 PM, AsmanCom wrote: > > Hi, > > > for quick development-shots, i need to execute my untouched(may i > > could change "print" to "return") Python scripts(..with loops) in the > > Controller. > > The output should be renderd direct via http, without long-winded > > setting up the view for each function. > > Is that possible? > > > To my next concern > > > On my actual Project i have simple form field with submit button on my > > controller: > > form = SQLFORM.factory(Field('update_url', default='http://.domain.org/ > > text_file.txt <http://domain.org/%0Atext_file.txt>', > > requires=IS_NOT_EMPTY())) > > > On Submit the text file should be downloaded to Server indicated by an > > Progress Bar on the Page. > > Next the file should be inserted to the DB line by line(for loop with > > regex) and again indicated by the same Progress Bar . > > > My Code so far(... relies on clienttools example specifically on > > jqueryUI-progressbar and an urllib2 +report_hook snippet i´ve found > > somewhere): > > ___ > > def chunk_report(bytes_so_far, chunk_size, total_size): > > percent = float(bytes_so_far) / total_size > > percent = round(percent*100) > > return percent > > > if bytes_so_far >= total_size: > > return ('100.0') > > > def chunk_read(response, chunk_size=8192, report_hook=None): > > total_size = response.info().getheader('Content-Length').strip() > > total_size = int(total_size) > > bytes_so_far = 0 > > > while 1: > > chunk = response.read(chunk_size) > > bytes_so_far += len(chunk) > > > if not chunk: > > break > > > if report_hook: > > report_hook(bytes_so_far, chunk_size, total_size) > > > percent = float(bytes_so_far) / total_size > > percent = round(percent*100) > > return percent #bytes_so_far > > > def url_progress(): > > wrapper = DIV(progress,_style="width:400px;") > > jqueryui_progress() > > form = SQLFORM.factory(Field('update_url', > > default='http://.domain.org/text_file.txt', requires=IS_NOT_EMPTY())) > > if form.accepts(request.vars, session): > > response.flash = "Got it!" > > try: > > import urllib2 > > openurl = urllib2.urlopen(request.vars.update_url) > > chunk_read(openurl, report_hook=chunk_report) > > except Exception, e: > > session.flash = DIV(T('Unable to download from url > > because:'),PRE(str(e))) > > redirect(URL(r=request)) > > event.listen('submit',"form","return confirm('Are you sure?');") # > > adds a confirmation to submit > > page.ready(jq("update_oui").focus()()) > > # return dict(form=form) > > return dict(wrapper=wrapper, form=form) > > > # jQuery progress bar > > progress = DIV(_id="progress") > > def jqueryui_progress(): > > wrapper = DIV(progress,_style="width:400px;") > > page.include("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/ > > jquery-ui.min.js<http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/%0Ajquery-ui.min.js>", > > download=True) > > page.include("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/ > > themes/ui-darkness/jquery-ui.css<http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/%0Athemes/ui-dark...>", > > do
[web2py] Download and Update Progress +a general question
Hi, for quick development-shots, i need to execute my untouched(may i could change "print" to "return") Python scripts(..with loops) in the Controller. The output should be renderd direct via http, without long-winded setting up the view for each function. Is that possible? To my next concern On my actual Project i have simple form field with submit button on my controller: form = SQLFORM.factory(Field('update_url', default='http://.domain.org/ text_file.txt', requires=IS_NOT_EMPTY())) On Submit the text file should be downloaded to Server indicated by an Progress Bar on the Page. Next the file should be inserted to the DB line by line(for loop with regex) and again indicated by the same Progress Bar . My Code so far(... relies on clienttools example specifically on jqueryUI-progressbar and an urllib2 +report_hook snippet i´ve found somewhere): ___ def chunk_report(bytes_so_far, chunk_size, total_size): percent = float(bytes_so_far) / total_size percent = round(percent*100) return percent if bytes_so_far >= total_size: return ('100.0') def chunk_read(response, chunk_size=8192, report_hook=None): total_size = response.info().getheader('Content-Length').strip() total_size = int(total_size) bytes_so_far = 0 while 1: chunk = response.read(chunk_size) bytes_so_far += len(chunk) if not chunk: break if report_hook: report_hook(bytes_so_far, chunk_size, total_size) percent = float(bytes_so_far) / total_size percent = round(percent*100) return percent #bytes_so_far def url_progress(): wrapper = DIV(progress,_style="width:400px;") jqueryui_progress() form = SQLFORM.factory(Field('update_url', default='http://.domain.org/text_file.txt', requires=IS_NOT_EMPTY())) if form.accepts(request.vars, session): response.flash = "Got it!" try: import urllib2 openurl = urllib2.urlopen(request.vars.update_url) chunk_read(openurl, report_hook=chunk_report) except Exception, e: session.flash = DIV(T('Unable to download from url because:'),PRE(str(e))) redirect(URL(r=request)) event.listen('submit',"form","return confirm('Are you sure?');") # adds a confirmation to submit page.ready(jq("update_oui").focus()()) #return dict(form=form) return dict(wrapper=wrapper, form=form) # jQuery progress bar progress = DIV(_id="progress") def jqueryui_progress(): wrapper = DIV(progress,_style="width:400px;") page.include("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/ jquery-ui.min.js", download=True) page.include("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/ themes/ui-darkness/jquery-ui.css", download=True) callback = js.call_function(get_progress) page.ready(jq(progress).progressbar( dict(value='0') )() ) page.ready(js.timer(callback,2000)) return dict(wrapper=wrapper) def get_progress(): return jq(progress).progressbar('option', 'value', request.now.second)()# But now i stuck can anyone put me on the right way? When the Page is loaded, both elemts show up correctly. When i do the submit: - The Progressbar freezes(Callback dont work while downloading the file...) - The Download works and shows 100% when completed(but the while 1 loop, which calls the report_hook dont work at all! and i need it to update the Progress bar... I think?) + I need to change the Progressbar callback source when updating DB after downloading the file... Anyone any suggestions? Best regards, Dieter Asman - AsmanCom - Germany -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.