Re: [web2py] Re: KWEB on Raspberry-pi Zero, can't login to admin page
thanks Massimo, but I know the password, because I can get to the admin pages if I use another browser. So the combination of the KWEB browser and Web2py behaves strange and I can't explain or solve that. cheer, Stef On 11-Jun-17 10:16, Massimo Di Pierro wrote: You may want to reset the web2py admin password: cd /path/tp/web2py sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)" On Saturday, 10 June 2017 17:21:33 UTC-5, Stef Mientki wrote: hello, I've installed web2py on my Raspberry-pi Zero. The sit is working well and I can get to the admin pages through the default browser (I think it's Epiphany). While this browser is mch to heavy for the Raspberry (consumes 100% processor time) I installed a lean browser KWEB. This is much faster, but when I try to go to the admin pages, I get "Invalid Password". Any idea what's going on here ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com <mailto:web2py+unsubscr...@googlegroups.com>. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] KWEB on Raspberry-pi Zero, can't login to admin page
hello, I've installed web2py on my Raspberry-pi Zero. The sit is working well and I can get to the admin pages through the default browser (I think it's Epiphany). While this browser is mch to heavy for the Raspberry (consumes 100% processor time) I installed a lean browser KWEB. This is much faster, but when I try to go to the admin pages, I get "Invalid Password". Any idea what's going on here ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: Service call problem with new installation on Windows and raspberry
thanks Dave, I checked routes.py and indeed there's the default application defined. So changing routes.py solved the problem. But I guess I used the wrong URL's in my html views: "../call/csv/service_platdak", now if I change that with "{{=URL('default','call/csv/service_plat_dak')}}", I don't need routes anymore. So I suppose the later solution is better ? cheers, Stef On 12-May-17 3:02, Dave S wrote: On Thursday, May 11, 2017 at 5:05:14 PM UTC-7, Stef Mientki wrote: Hello, 3 years ago I made a web2py site, which has run on a Raspberry Pi without any problems since 3 years. I now want to replace the Raspberry Pi with a Raspberry Pi Zero (larger/faster). I haven't used web2py for 3 years and thought simply installing a new web2py and moving the application files would do the job, but unfortunately this isn't enough. But it wasn't that easy. Probably something has changed and I can't find what's the crucial difference. The problem is in the service calls to get dynamic data in graphs (dygraphs). Old Web2py on the Raspberry Pi = version 2.9.5 I've tried 2 situations, which both give the same problem: Windows 10: version 2.14.6 Raspberry: version 1.99(the official version from Raspberry?) This surprises me, because one version is older and the other one is newer, still the give the same problems. Should I mess with routes or something like that ? # In ../controllers/default.py # from gluon.tools import Service service = Service(globals()) def call(): ##session.forget() return service() @cache('service_platdak_cache', cache_time_short, cache.ram ) def service_platdak_cache(): # Build the list of data samples here Rows = [] Rows.append (...) Rows.append (...) Rows.append (...) return Rows @service.csv def service_platdak(): return service_platdak_cache() # In../views/default/index.html I call the service # graph2 = new Dygraph( document.getElementById ( "pygraph2" ), "../call/csv/service_platdak", { customBars: false, title: 'Platdak:Inkomsten / Uitgaven = {{=response.Inkomsten_Platdak}}', legend: 'follow', …. } ); # Now if I ask the service in a browser http://127.0.0.1:8000/SolarPower_Molenhoek/call/csv/service_platdak <http://127.0.0.1:8000/SolarPower_Molenhoek/call/csv/service_platdak> I get: invalid controller (call/csv) If I ask for index.html in a browser, I don’t see any graphs. If I look in the debug screen of the browser, I see http://127.0.0.1:8000/SolarPower_Molenhoek/call/csv/service_platdak <http://127.0.0.1:8000/SolarPower_Molenhoek/call/csv/service_platdak> 404 (NOT FOUND) Does anyone has a clue what's the problem/ Thanks, Stef 3 years isn't that many versions back (we've been at 2.14.6 for a couple of years as the Py3 push has slowed updates), and there shouldn't be too many differences back to 2.11 (which should cover your original use). This seems to be a routing issue (app/controller/function stuff) ... were you using a router configuration in your original? Or did you change the controller file from default.py? /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com <mailto:web2py+unsubscr...@googlegroups.com>. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Service call problem with new installation on Windows and raspberry
Hello, 3 years ago I made a web2py site, which has run on a Raspberry Pi without any problems since 3 years. I now want to replace the Raspberry Pi with a Raspberry Pi Zero (larger/faster). I haven't used web2py for 3 years and thought simply installing a new web2py and moving the application files would do the job, but unfortunately this isn't enough. But it wasn't that easy. Probably something has changed and I can't find what's the crucial difference. The problem is in the service calls to get dynamic data in graphs (dygraphs). Old Web2py on the Raspberry Pi = version 2.9.5 I've tried 2 situations, which both give the same problem: Windows 10: version 2.14.6 Raspberry: version 1.99(the official version from Raspberry?) This surprises me, because one version is older and the other one is newer, still the give the same problems. Should I mess with routes or something like that ? # In ../controllers/default.py # from gluon.tools import Service service = Service(globals()) def call(): ##session.forget() return service() @cache('service_platdak_cache', cache_time_short, cache.ram ) def service_platdak_cache(): # Build the list of data samples here Rows = [] Rows.append (...) Rows.append (...) Rows.append (...) return Rows @service.csv def service_platdak(): return service_platdak_cache() # In../views/default/index.html I call the service # graph2 = new Dygraph( document.getElementById ( "pygraph2" ), "../call/csv/service_platdak", { customBars: false, title: 'Platdak:Inkomsten / Uitgaven = {{=response.Inkomsten_Platdak}}', legend: 'follow', …. } ); # Now if I ask the service in a browser http://127.0.0.1:8000/SolarPower_Molenhoek/call/csv/service_platdak I get: invalid controller (call/csv) If I ask for index.html in a browser, I don’t see any graphs. If I look in the debug screen of the browser, I see http://127.0.0.1:8000/SolarPower_Molenhoek/call/csv/service_platdak 404 (NOT FOUND) Does anyone has a clue what's the problem/ Thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: does cache decorator work for services ?
ok I found a solution - split the service into a function that will be cached and in the service just call that function but I'm still interested in why I get the error below @cache('service_platdak_absolutely_necessary', 10, cache.ram ) def service_platdak_absolutely_necessary(): .. do the calculation here return Rows @service.csv def service_platdak(): return service_platdak_absolutely_necessary() thanks, Stef On 12-Jan-15 23:07, Stef Mientki wrote: thanks Massimo, but ... when I use the suggested order, I get Traceback(most recent call last): Filegluon\restricted.pyc,line217,inrestricted FileP:/web2py_2_8_2/applications/SolarPower_Molenhoek/controllers/default.py http://127.0.0.1:8000/admin/edit/SolarPower_Molenhoek/controllers/default.py,line1445,inmodule Filegluon\globals.pyc,line372,inlambda FileP:/web2py_2_8_2/applications/SolarPower_Molenhoek/controllers/default.py http://127.0.0.1:8000/admin/edit/SolarPower_Molenhoek/controllers/default.py,line1438,incall returnservice() Filegluon\tools.pyc,line4911,in__call__ Filegluon\tools.pyc,line4549,inserve_csv Filegluon\tools.pyc,line4247,inuniversal_caller AttributeError:'CacheAction'object has no attribute'func_code' On 12-Jan-15 05:04, Massimo Di Pierro wrote: The order of the decorators is important. This: @cache('service_platdak', 300, cache.ram ) @service.csv def service_platdak(): registers the service (without caching) and the defined a cached action (normal action). This: @service.csv @cache('service_platdak', 300, cache.ram ) def service_platdak(): defined a cached action (normal cached action) and then exposes the cached actions as csv service. On Sunday, 11 January 2015 14:02:32 UTC-6, aapaap wrote: thanks Paolo and Leonel, things seems even weirder than I had in mind: 1. changing the order of the decorators: the program doesn't work anymore, there's no csv response anymore 2. the code form Leonel works, as long as you use it as a plain example Now I made 2 identical csv services, both with a cache decorator (code below). The first one is called as a procedure in a controller * response.baapje = service_platdak2()** * and the other one is used a csv file for the javascript DyGraph in the viewer *script type=text/javascript** ** graph2 = new Dygraph(** **document.getElementById ( pygraph2 ),** **../call/csv/service_platdak,** **{** * The call in the controller is perfectly well cached, the javascript call is not cached. To be sure that the code was the same, I exchanged the name in the controler call and viewer call * response.baapje = service_platdak()** * and the other one is used a csv file for the javascript DyGraph in the viewer *script type=text/javascript** ** graph2 = new Dygraph(** **document.getElementById ( pygraph2 ),** **../call/csv/service_platdak2,** **{** * with exactly the same result: The call in the controller is perfectly well cached, the javascript call is not cached. Any ideas ? The complete code of the service: # # try: sys.test_platdak except : sys.test_platdak = 1 @cache('service_platdak', 300, cache.ram ) @service.csv def service_platdak(): ToDay = date.today() Tomorrow = ( ToDay + timedelta (1) ) Yesterday = ( ToDay - timedelta (1) ) # ** # Get Solar Power current day # ** SQL = select Date, M2, M2_s1 from Compare_Model where Date = ? and Date ? and M2_s1 0 order by Date Current = db.executesql ( SQL, ( ToDay, Tomorrow ) ) # ** # Get total result of yesterday # ** SQL = select total(M2), total(M2_s1) from Compare_Model where Date = ? and Date ? and M2_s1 0 Gisteren = db.executesql ( SQL, ( Yesterday, ToDay ) ) Sum= Molenhoek_2.WattPeak * float ( Gisteren[0][0] ) / 6000 SumM = Molenhoek_2.WattPeak * float ( Gisteren[0][1] ) / 6000 # ** # build the result # ** Rows = [] Rows.append ('Date,Power[Watt],Energy[kWh],Model[Watt],Model[kWh]'.split(',')) # ** # add previous day sum to first and second row # ** Row= [ 0, 0, Sum, 0, SumM ] Row[0] = Current[0][0] - timedelta ( hours = 1 ) Row[1] = sys.test_platdak sys.test_platdak += 1 Rows.append ( Row ) Row = copy ( Row
[web2py] does cache decorator work for services ?
hello, I've a service, for which the output can change only ones every 10 minutes. So I want to cache the resulting output. To test if caching is working, I made the following setup: - In the view there's a javascript that requests a refresh of the data every minute. - A global sys.N_Schuurdak signals is used to see if the calculations are done try: sys.N_Schuurdak except : sys.N_Schuurdak = 10 # # @cache('service_schuurdak', 600, cache.ram ) @service.csv def service_schuurdak(): sys.N_Schuurdak += 1 # here Rows are calculated (in which sys.N_Schuurdak is substituted for test) return Rows Now if I open the webpage in a browser, I see the variable sys.N_Schuurdak incremented every minute. So my conclusion is that caching is not working. Is my conclusion correct ? What am I doing wrong ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: does cache decorator work for services ?
thanks Paolo and Leonel, things seems even weirder than I had in mind: 1. changing the order of the decorators: the program doesn't work anymore, there's no csv response anymore 2. the code form Leonel works, as long as you use it as a plain example Now I made 2 identical csv services, both with a cache decorator (code below). The first one is called as a procedure in a controller * response.baapje = service_platdak2()** * and the other one is used a csv file for the javascript DyGraph in the viewer *script type=text/javascript** ** graph2 = new Dygraph(** **document.getElementById ( pygraph2 ),** **../call/csv/service_platdak,** **{** * The call in the controller is perfectly well cached, the javascript call is not cached. To be sure that the code was the same, I exchanged the name in the controler call and viewer call * response.baapje = service_platdak()** * and the other one is used a csv file for the javascript DyGraph in the viewer *script type=text/javascript** ** graph2 = new Dygraph(** **document.getElementById ( pygraph2 ),** **../call/csv/service_platdak2,** **{** * with exactly the same result: The call in the controller is perfectly well cached, the javascript call is not cached. Any ideas ? The complete code of the service: # # try: sys.test_platdak except : sys.test_platdak = 1 @cache('service_platdak', 300, cache.ram ) @service.csv def service_platdak(): ToDay = date.today() Tomorrow = ( ToDay + timedelta (1) ) Yesterday = ( ToDay - timedelta (1) ) # ** # Get Solar Power current day # ** SQL = select Date, M2, M2_s1 from Compare_Model where Date = ? and Date ? and M2_s1 0 order by Date Current = db.executesql ( SQL, ( ToDay, Tomorrow ) ) # ** # Get total result of yesterday # ** SQL = select total(M2), total(M2_s1) from Compare_Model where Date = ? and Date ? and M2_s1 0 Gisteren = db.executesql ( SQL, ( Yesterday, ToDay ) ) Sum= Molenhoek_2.WattPeak * float ( Gisteren[0][0] ) / 6000 SumM = Molenhoek_2.WattPeak * float ( Gisteren[0][1] ) / 6000 # ** # build the result # ** Rows = [] Rows.append ('Date,Power[Watt],Energy[kWh],Model[Watt],Model[kWh]'.split(',')) # ** # add previous day sum to first and second row # ** Row= [ 0, 0, Sum, 0, SumM ] Row[0] = Current[0][0] - timedelta ( hours = 1 ) Row[1] = sys.test_platdak sys.test_platdak += 1 Rows.append ( Row ) Row = copy ( Row ) Row[0] = Current[0][0] Rows.append ( Row ) # ** # add all measurements of today # ** Sum = 0 SumM = 0 for Row in Current : Power = 0 PowerM = 0 if not Row[1] is None : Power = Molenhoek_2.WattPeak * float ( Row[1] ) Sum += Power if not Row[2] is None : PowerM = Molenhoek_2.WattPeak * float ( Row[2] ) SumM += PowerM New = [ Row[0], Power, Sum/6000, PowerM, SumM/6000 ] Rows.append ( New ) return Rows On 11-Jan-15 16:55, Leonel Câmara wrote: There must be something else wrong with your code. This should work. My test: @cache('test', 600, cache.ram ) @service.csv def test(): import sys try: sys.N_Schuurdak += 1 except : sys.N_Schuurdak = 10 return {'N_Schuurdak': sys.N_Schuurdak} As expected it returned 10 for 10 minutes and then 11. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com mailto:web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: how can I ensures list-order
thanks Anthony, No, I don't need a list of dictionairies. From your question, I assume there's also a way to get a plain table ? I need a list of lists or even better a 2D-numpy array (so I can easily perform some conversions). The final list of lists (or numpy array) must be converted to a csv file (by a service) cheers, Stef On 01-Jan-15 21:22, Anthony wrote: The problem is that you call .as_list(), which converts to a list of dictionaries, and dictionaries do not preserve the order of keys. Do you need a list of dictionaries? On Thursday, January 1, 2015 3:09:22 PM UTC-5, aapaap wrote: hello, I'm using dygraph to plot a number of parameters. Dygraph needs a csv file as it's input. So I made a service: @service.csv def service_platdak(): ToDay= date.today() Tomorrow = ( ToDay + timedelta (1) ) Fields = [ db.Compare_Model.Date, db.Compare_Model.M2,db.Compare_Model.M2_s1 ] Rows = db ( ( db.Compare_Model.Date = ToDay ) ( db.Compare_Model.Date Tomorrow ) ( db.Compare_Model.M2 0.01 ) ).select( *Fields, orderby = db.Compare_Model.Date ).as_list() return Rows This works almost, except the order of the fileds is not maintained (M2 and M2_s1 are exchanged): Date,M2_s1,M2 2015-01-01 09:20:00,,0.6667 2015-01-01 09:30:00,,3.92857142857 2015-01-01 09:40:00,,8.5 is there a way (other than raw SQL) to maintain the column order ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com mailto:web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] how can I ensures list-order
hello, I'm using dygraph to plot a number of parameters. Dygraph needs a csv file as it's input. So I made a service: @service.csv def service_platdak(): ToDay= date.today() Tomorrow = ( ToDay + timedelta (1) ) Fields = [ db.Compare_Model.Date, db.Compare_Model.M2,db.Compare_Model.M2_s1 ] Rows = db ( ( db.Compare_Model.Date = ToDay ) ( db.Compare_Model.Date Tomorrow ) ( db.Compare_Model.M2 0.01 ) ).select( *Fields, orderby = db.Compare_Model.Date ).as_list() return Rows This works almost, except the order of the fileds is not maintained (M2 and M2_s1 are exchanged): Date,M2_s1,M2 2015-01-01 09:20:00,,0.6667 2015-01-01 09:30:00,,3.92857142857 2015-01-01 09:40:00,,8.5 is there a way (other than raw SQL) to maintain the column order ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: how can I ensures list-order
thanks Anthony, your answer looks really great, exactly what I was looking for and more ;-) I'll probably try it to morrow. cheers, Stef On 01-Jan-15 22:39, Anthony wrote: In that case, I wouldn't bother having the DAL create a Rows object. Instead, the database cursor will return a list of tuples, which you can feed directly to numpy to create an array. There are two approaches to do this: | importnumpy asnp my_array =np.asarray(db.executesql(db(query)._select(*fields))) | When you call ._select() instead of .select(), it simply returns the SQL string, which then gets passed to db.executesql(), which returns the raw results from the database (i.e., a list of tuples) without any further processing by the DAL. A similar option is to use the processor argument to .select(), which allows you to specify a custom processor rather than having the DAL create a Rows object: | defnp_array(records,fields,columns,cacheable): returnnp.asarray(records) my_array =db(query).select(*fields,processor=np_array) | In the above case, the DAL will take the raw results from the database and pass them to the custom np_array function. Anthony On Thursday, January 1, 2015 4:07:23 PM UTC-5, aapaap wrote: thanks Anthony, No, I don't need a list of dictionairies. From your question, I assume there's also a way to get a plain table ? I need a list of lists or even better a 2D-numpy array (so I can easily perform some conversions). The final list of lists (or numpy array) must be converted to a csv file (by a service) cheers, Stef On 01-Jan-15 21:22, Anthony wrote: The problem is that you call .as_list(), which converts to a list of dictionaries, and dictionaries do not preserve the order of keys. Do you need a list of dictionaries? On Thursday, January 1, 2015 3:09:22 PM UTC-5, aapaap wrote: hello, I'm using dygraph to plot a number of parameters. Dygraph needs a csv file as it's input. So I made a service: @service.csv def service_platdak(): ToDay= date.today() Tomorrow = ( ToDay + timedelta (1) ) Fields = [ db.Compare_Model.Date, db.Compare_Model.M2,db.Compare_Model.M2_s1 ] Rows = db ( ( db.Compare_Model.Date = ToDay ) ( db.Compare_Model.Date Tomorrow ) ( db.Compare_Model.M2 0.01 ) ).select( *Fields, orderby = db.Compare_Model.Date ).as_list() return Rows This works almost, except the order of the fileds is not maintained (M2 and M2_s1 are exchanged): Date,M2_s1,M2 2015-01-01 09:20:00,,0.6667 2015-01-01 09:30:00,,3.92857142857 2015-01-01 09:40:00,,8.5 is there a way (other than raw SQL) to maintain the column order ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com mailto:web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com mailto:web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] how to get just one instance of a complex class ?
hello, I've a class, that reads a huge file and parses it. Therefor I want just one instance per session or even one over all sessions. # The next code (placed in controler default.py) generates an error if session.Book_Loaded is None : session.Book_Loaded = PuntHoofd_support.PuntHoofd_Doc ( Text ) session.Test_One_Instance = random.randint ( 0, 1000 ) Book_Source = session.Book_Loaded Test_One_Instance = session.Test_One_Instance #Chapters = Test_One_Instance.Get_Chapters ( Book ) #AttributeError: 'str' object has no attribute 'Get_Chapters' Error: session.Book_Loaded has become a string Now I've found a workaround that does work: try : sys.Book_Loaded except : sys.Book_Loaded = PuntHoofd_support.PuntHoofd_Doc ( Text ) sys.Test_One_Instance = random.randint ( 0, 1000 ) Book_Source = sys.Book_Loaded Test_One_Instance = sys.Test_One_Instance Is there a better/cleaner way to realize this ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] new web2py videos
great Nico and Massimo. one small remark, the titles can't be read (other than hoovering), so if I may suggest, change the title by removing Web2py video course 2013 (or put it at the end of the title). cheers, Stef On 31-Aug-14 04:56, Massimo DiPierro wrote: Nico has helped edit and re-organize some my class lectures about web2py. They are now split into 30 small videos: https://vimeo.com/album/3016728 Please join me in thanking Nico. Massimo -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] PythonAnywhere Web2py Script
I'm not sure what all those command line parameters mean, so I don't know if this helps, but I run the same script on my Desktop, Raspberry Pi and PythonWhyWhere without parameters in the following way: # detect if I'm on PythonAnyWhere import platform Uname = platform.uname () CurDir = os.curdir ## PythonAnyWhere if Uname[0] == 'Linux' and 'x86' in Uname[4] : ##Uname[1].startswith ( 'giles-' ) : DB_Path= r'/home/knutselen/web2py/applications/SolarPower_Molenhoek/databases' Gluon_Path = r'/home/knutselen/web2py/' elif Uname[0] == 'Windows' : DB_Path= r'P:\web2py_2_8_2\applications\SolarPower_Molenhoek\databases' Gluon_Path = r'P:\web2py_2_8_2\library.zip' ## Raspberry-PI else : DB_Path = r'/home/pi/web2py/applications/SolarPower_Molenhoek/databases' Gluon_Path = r'/home/pi/web2py/' try : from gluon import DAL, Field except : sys.path.append ( Gluon_Path ) from gluon import DAL, Field db = DAL ( 'sqlite://storage.sqlite', folder = DB_Path, auto_import = True ) Result = db.executesql ( SQL_Model % ( D ) ) cheers, Stef On 16-07-14 15:37, Tom Russell wrote: I am trying to run a script that I have in my app. While the log files seem to show my script ran, it does not update the db I have for my app. On the schedule tab in pythonanywhere I have this set up so not sure if it is correct: | python2.7/home/tsrdatatech/web2py/web2py.py -S ttheorydataextractor -M -R /home/tsrdatatech/web2py/applications/ttheorydataextractor/modules/voltrin_grabber.py | And a sample output of what the log says when it runs is below: | 2014-07-14 23:00:44 -- Completed task, took17.00 seconds, return code was0. web2pyWeb Framework Created by Massimo Di Pierro, Copyright 2007-2014 Version 2.9.5-stable+timestamp.2014.03.16.02.35.39 Database drivers available: SQLite(sqlite3), MySQL(pymysql), MySQL(MySQLdb), MySQL(mysqlconnector), PostgreSQL(psycopg2), PostgreSQL(pg8000), MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), MongoDB(pymongo), IMAP(imaplib) 2014-07-15 23:00:30 -- Completed task, took11.00 seconds, return code was0. | It seems like it opens web2py but doesnt really run the script I have I think. Thanks. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com mailto:web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: how to determine the server (name) ?
thanks Leonel and Michael. forgot to tell there are 2 programs running at least on one of those servers, a web2py application and another application polling a solar system. So I don't always have the request variable. So I hoped I could use os.curdir, but for some unknown reason that doesn't work correctly. Instead I now use platform.uname () which is unique enough (although on PythonAnyWhere the name of the server is not constant) cheers, Stef On 30-05-14 14:24, Michael Beller wrote: Depending on your server and hosting environment, request.env.http_host may always return '127.0.0.1:8000' when you're using the browser based shell (in admin) or running web2py from console. I found it was more reliable to use request.env.web2py_path which always gave a unique path (in the browser shell, while running web2py from the shell, and normally) for the server environment. I use this to detect my dev, test, or prod environment. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com mailto:web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] how to determine the server (name) ?
hello, I'm trying to run the same application on different servers. On each specific server there should be some small differences, so I would like to detect the server on which the web2py application is running. thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: is it allowed/possible to replace the database within a controler ?
thanks Anthony, Thought it was difficult to generate a scheduled task. But in PythonAnyWhere it'standard available. So I'll go that way. Still wondering if it's allowed to copy the default web2py database in a controler function ? cheers, Stef On 09-05-14 0:02, Anthony wrote: You probably don't want a web request to potentially have to wait for a database copy over the network before returning a result. It would probably make more sense to set up a scheduled task to replicate the database once a day. Or better yet, look into the replication options offered by your RDBMS (e.g., http://www.postgresql.org/docs/9.3/static/high-availability.html). Anthony On Thursday, May 8, 2014 4:30:03 PM UTC-4, aapaap wrote: hello, I've a web2py site, which should run, more or less synchronized, (with the same data) on 2 different servers. The first one is filling the database. The second one should copy the db from the first one if the database was refreshed more than 24 hours ago. So the solution I've in mind is the following: - on the second system I keep the last refresh of the database in some extra table of this database (I can't find another global storage) - when a specific controler is requested on this second system, it checks if the database needs to be refreshed, downloads the database from the first server and copies this over it's own database. Is replacing the database allowed in a controler ? Are there better solutions ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: is it allowed/possible to replace the database within a controler ?
thanks Anthony. On 09-05-14 22:22, Anthony wrote: Sure, it should be allowed, but nothing will be returned to the browser while you're waiting for the copy to happen. If the copy takes too long, the HTTP request may time out. Anthony On Friday, May 9, 2014 4:17:05 PM UTC-4, aapaap wrote: thanks Anthony, Thought it was difficult to generate a scheduled task. But in PythonAnyWhere it'standard available. So I'll go that way. Still wondering if it's allowed to copy the default web2py database in a controler function ? cheers, Stef On 09-05-14 0:02, Anthony wrote: You probably don't want a web request to potentially have to wait for a database copy over the network before returning a result. It would probably make more sense to set up a scheduled task to replicate the database once a day. Or better yet, look into the replication options offered by your RDBMS (e.g., http://www.postgresql.org/docs/9.3/static/high-availability.html http://www.postgresql.org/docs/9.3/static/high-availability.html). Anthony On Thursday, May 8, 2014 4:30:03 PM UTC-4, aapaap wrote: hello, I've a web2py site, which should run, more or less synchronized, (with the same data) on 2 different servers. The first one is filling the database. The second one should copy the db from the first one if the database was refreshed more than 24 hours ago. So the solution I've in mind is the following: - on the second system I keep the last refresh of the database in some extra table of this database (I can't find another global storage) - when a specific controler is requested on this second system, it checks if the database needs to be refreshed, downloads the database from the first server and copies this over it's own database. Is replacing the database allowed in a controler ? Are there better solutions ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com mailto:web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] is it allowed/possible to replace the database within a controler ?
hello, I've a web2py site, which should run, more or less synchronized, (with the same data) on 2 different servers. The first one is filling the database. The second one should copy the db from the first one if the database was refreshed more than 24 hours ago. So the solution I've in mind is the following: - on the second system I keep the last refresh of the database in some extra table of this database (I can't find another global storage) - when a specific controler is requested on this second system, it checks if the database needs to be refreshed, downloads the database from the first server and copies this over it's own database. Is replacing the database allowed in a controler ? Are there better solutions ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [web2py] Re: how to get globals like request available in my own modules ?
thanks guys, current works perfect, I missed it in the huge amount of information cheers, Stef On 17-02-14 1:40, Anthony wrote: Note, instead of this method, you can now use gluon.current. Anthony On Sunday, February 16, 2014 6:32:13 PM UTC-5, Julio F. Schwarzbeck wrote: I assume that if you will use modules they'll probably be implemented in some kind of class, I'd personally do something similar to this.. # mymodule.py class ModuleHelper(object): Sample Helper for common methods. def __init__(self, environment): self.request = environment['request'] self.response = environment['response'] self.session = environment['session'] self.cache = environment['cache'] self.db = environment['db'] self.auth = environment['auth'] def method(self): self.request.get('variable', ) ... And when instantiating the module say from a model: # mymodel.py from mymodule import ModuleHelper ... And Later in the same mymodel.py ... # Make the module class/methods available: my_module_helper = ModuleHelper(globals()) Now you can use my_module_helper.my_method(params) from within any view or controller.. Hope it helps. Julio On 02/16/2014 01:55 PM, Stef Mientki wrote: hello, how to get globals like request available in my own modules ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: is there a way to detect x-frames ?
found something that seems to work (after some modifications) #http://chase-seibert.github.io/blog/2011/01/21/youtube-detecting-x-frame-optionsframebreaking-in-python.htm def Is_Framing_Allowed ( URL ) : import urllib2 req = urllib2.Request ( URL ) ##req.add_header ( Referer, http://example.com;) # you should put your real URL here try : opener = urllib2.urlopen ( req ) except : return False # returns True if ANY x-frame-options header is present # the only options at present are DENY and SAMEORIGIN, either of which means you can't frame return not x-frame-options in opener.headers.dict On 16-02-14 1:26, Stef Mientki wrote: hello, I want to show external sites in an IFRAME (including the link to the orginal site), so I can add comment to the external website, but some sites won't show in an IFRAME. This seems to e due to X-Frame options. Is there a way to detect if there are any x-frame-options, so I can make a choose to display the site in an IFrame or as a direct link to the externa website? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] how to get globals like request available in my own modules ?
hello, how to get globals like request available in my own modules ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] is there a way to detect x-frames ?
hello, I want to show external sites in an IFRAME (including the link to the orginal site), so I can add comment to the external website, but some sites won't show in an IFRAME. This seems to e due to X-Frame options. Is there a way to detect if there are any x-frame-options, so I can make a choose to display the site in an IFrame or as a direct link to the externa website? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: how to embed an image (or another solution) ?
thanks Michele, didn't know about that function On 13-02-14 17:18, Michele Comitini wrote: if you wish to embed images in html, web2py has a little know, but handy function: embed64(data, extension) in your case you coud simply use: img src={{=embed64(data=data, extension='image/png')}}/ without doing the base64 encoding yourself. Embedding is very efficient for small images, can be bad for large ones mic 2014-02-13 0:48 GMT+01:00 Anthony abasta...@gmail.com mailto:abasta...@gmail.com: If you use the built-in upload mechanism (i.e., an upload type field in a db table), then files uploaded via that method can be downloaded via response.download. The welcome app includes a /default/download function to do just that. Check out http://web2py.com/books/default/chapter/29/03/overview#An-image-blog. Anthony On Monday, February 10, 2014 4:43:32 PM UTC-5, aapaap wrote: hello, maybe I'm totally on the wrong path, but this is my script for the moment: - users can upload pictures. Uploads seems to be allowed only in myapp/uploads - I want to show these images, but images to be shown are only allowed in myapp/static - so I have to show images from myapp/uploads I have the following controller: def Show_Plaatje(): fh = open ( os.path.join ( 'applications', request.application, 'uploads', 'images', 'pic_53.png' ), 'rb') data = fh.read() fh.close() return data And in my view: img src={{=URL('Show_Plaatje')}}/ This doesn't seem to work, if I look at the resulting html-source, I see img src=/Knutselen_Voor_Kinderen/default/Show_Plaatje thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com mailto:web2py%2bunsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: how to embed an image (or another solution) ?
thanks Anthony, but I want to browse the image directory, so I don't want to store them in the database. cheers, Stef On 13-02-14 0:48, Anthony wrote: If you use the built-in upload mechanism (i.e., an upload type field in a db table), then files uploaded via that method can be downloaded via response.download. The welcome app includes a /default/download function to do just that. Check out http://web2py.com/books/default/chapter/29/03/overview#An-image-blog. Anthony On Monday, February 10, 2014 4:43:32 PM UTC-5, aapaap wrote: hello, maybe I'm totally on the wrong path, but this is my script for the moment: - users can upload pictures. Uploads seems to be allowed only in myapp/uploads - I want to show these images, but images to be shown are only allowed in myapp/static - so I have to show images from myapp/uploads I have the following controller: def Show_Plaatje(): fh = open ( os.path.join ( 'applications', request.application, 'uploads', 'images', 'pic_53.png' ), 'rb') data = fh.read() fh.close() return data And in my view: img src={{=URL('Show_Plaatje')}}/ This doesn't seem to work, if I look at the resulting html-source, I see img src=/Knutselen_Voor_Kinderen/default/Show_Plaatje thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] why is auth.messages.... not working
hello, I want to redefine the texts of the login screen so in models/db.py I've : auth.messages.label_username='Gebruikersnaam' and my login controler: @auth.requires_login() def Inloggen(): redirect ( URL ( Show_Knutselen )) but I keep seeing : username thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: why is auth.messages.... not working
thanks Anthony, that did the trick, cheers, Stef On 14-02-14 16:30, Anthony wrote: Field labels have to be set before calling auth.define_tables. Is that the case here? Anthony On Friday, February 14, 2014 10:28:21 AM UTC-5, aapaap wrote: hello, I want to redefine the texts of the login screen so in models/db.py I've : auth.messages.label_username='Gebruikersnaam' and my login controler: @auth.requires_login() def Inloggen(): redirect ( URL ( Show_Knutselen )) but I keep seeing : username thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: how to embed an image (or another solution) ?
found a solution, but it needs ugly code in the view. And I'm not sure if this is an unsafe action. {{import os}} {{import base64}} {{fh = open ( os.path.join ( 'applications', request.application, 'uploads', 'images', 'pic_%s.png' % response.Edits.id), 'rb')}} {{data = fh.read()}} {{fh.close()}} {{data= base64.encodestring ( data )}} {{data='data:image/png;base64,' + data}} img height=100px img src={{=data}}/ input name=Upload type=file value=Upload thanks, Stef On Mon, Feb 10, 2014 at 10:43 PM, Stef Mientki stef.mien...@gmail.comwrote: hello, maybe I'm totally on the wrong path, but this is my script for the moment: - users can upload pictures. Uploads seems to be allowed only in myapp/uploads - I want to show these images, but images to be shown are only allowed in myapp/static - so I have to show images from myapp/uploads I have the following controller: def Show_Plaatje(): fh = open ( os.path.join ( 'applications', request.application, 'uploads', 'images', 'pic_53.png' ), 'rb') data = fh.read() fh.close() return data And in my view: img src={{=URL('Show_Plaatje')}}/ This doesn't seem to work, if I look at the resulting html-source, I see img src=/Knutselen_Voor_Kinderen/default/Show_Plaatje thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] how to embed an image (or another solution) ?
hello, maybe I'm totally on the wrong path, but this is my script for the moment: - users can upload pictures. Uploads seems to be allowed only in myapp/uploads - I want to show these images, but images to be shown are only allowed in myapp/static - so I have to show images from myapp/uploads I have the following controller: def Show_Plaatje(): fh = open ( os.path.join ( 'applications', request.application, 'uploads', 'images', 'pic_53.png' ), 'rb') data = fh.read() fh.close() return data And in my view: img src={{=URL('Show_Plaatje')}}/ This doesn't seem to work, if I look at the resulting html-source, I see img src=/Knutselen_Voor_Kinderen/default/Show_Plaatje thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: how to keep request when redirecting
thanks, I didn't know about components will study that in the near future. For the moment I've replcaed the url with a auto-commit-checkbox, so I'll stay on the same page/controller. cheers, Stef On 05-02-14 10:46, Tim Richardson wrote: redirect starts a new request. I suppose your redirect URL can contain args and vars based on what comes in (see docs on the URL function), and then it would be up to the redirected controller to process them. In other words, you pass state in the URL. Your controller or view could use these get_vars or args to set form elements as you wish, or the view could embed those settings in javascript, which then takes effect on page load. Another option is to use web2py's component. Instead of reloading the whole page and creating a new request, the submit actions refresh a component in the page which contains the grid or form which has the data you want to refresh. In this case, you never leave the page you are on. This looks better too, it's very smooth. Read the components chapter in the book. On Monday, 3 February 2014 04:21:44 UTC+11, aapaap wrote: hello, I've a form with checkboxes and radiobuttons. All the checkboxes and radioboxes are auto-commit, i.e. the have an argument onchange=this.form.submit() Now this works perfect, as soon as a button is changed, the page is refreshed with a new selection from the database. Now I've some other actions on this form, which are realized by a link. This link points to a controler that does some action and then redirects to the orginal form. But now the settings of the checkboxes and radiobuttons is lost, I assume the request and specially the request.post_vars ar lost. The controler looks like : @auth.requires_login() def Block_Page(): if auth.user.id http://auth.user.id in Beheerders and request.args : ID = request.args [0] db ( db.Knutsels.id http://db.Knutsels.id == ID ).update ( Approved_Date = None ) redirect ( URL ( Show_Knutselen )) thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] how to keep request when redirecting
hello, I've a form with checkboxes and radiobuttons. All the checkboxes and radioboxes are auto-commit, i.e. the have an argument onchange=this.form.submit() Now this works perfect, as soon as a button is changed, the page is refreshed with a new selection from the database. Now I've some other actions on this form, which are realized by a link. This link points to a controler that does some action and then redirects to the orginal form. But now the settings of the checkboxes and radiobuttons is lost, I assume the request and specially the request.post_vars ar lost. The controler looks like : @auth.requires_login() def Block_Page(): if auth.user.id in Beheerders and request.args : ID = request.args [0] db ( db.Knutsels.id == ID ).update ( Approved_Date = None ) redirect ( URL ( Show_Knutselen )) thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: pythonanywhere, what's the adnmin password ?
thanks Massimo, Somewhere an error occured, either by me or by the software. When making the first web2py application (so I was logged in on Pythonanywhere) , I wasn't asked for an admin password. After deleting the first web2py application and creating my second web2py application, I was indeed asked for an admin password. Now it realy works beautifull, I packed my local web2py application and within 2 minutes is was running on Pythonanywhere, Fantastic !! cheers, Stef On 26-01-14 4:51, Massimo Di Pierro wrote: They give you one when you create the account. It is different for every user, even if you use the try-web2py option. Nobody else knows it. If you forgot it or did not write it down, try contact them. On Saturday, 25 January 2014 18:07:03 UTC-6, aapaap wrote: thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] pythonanywhere, what's the adnmin password ?
thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: filepaths for library and images ?
thanks, got in not working yet. I also tried the solution suggested in pass as parameter or import about an our later, but that didn't worked either. I don't understand the path philosophy of web2py at this moment. e.g. why is this working: img height=100px src={{= URL ( 'static', 'images', args='pic_%s.png'% record.id )}} / and why is this NOT working: img height=100px src={{= URL ( 'uploads', 'images', args='pic_%s.png'% record.id )}} / while the images are in both directories. cheers, Stef On 22-01-14 4:07, Anthony wrote: Please see http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules. On Tuesday, January 21, 2014 7:14:05 PM UTC-5, aapaap wrote: thanks Anthony, the import now works partially. The lib needs to know the database db is it possible to import that. from db import db doesn't work cheers, Stef On 21-01-14 23:55, Anthony wrote: Filename = os.path.join ( 'applications', request.application,'static\images\pic_%s.png' % Edit_Select), 'wb') | os.path.join(request.folder,'static','images','pic_%s.png'%Edit_Select) | Q2: I made some libraries that I want to use more than one project. Now I stored these in ..controllers/my_support_libs.py Controllers are not Python modules and cannot be imported. If you need to share a module, put it anywhere in the pythonpath and import from there. You can put it in the /modules folder of a given app and import from other apps via: | importapplications.myapp.modules.mymodule | Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] filepaths for library and images ?
hello, Q1: I want to store uploaded files manually, but I'm asking myself if this is the correct way to create the filepath, or is there a better way ? Filename = os.path.join ( 'applications', request.application,'static\images\pic_%s.png' % Edit_Select), 'wb') Q2: I made some libraries that I want to use more than one project. Now I stored these in ..controllers/my_support_libs.py but when I try to import this lib into a controller, I get an error message can't import my_support_libs cheers, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: filepaths for library and images ?
thanks Anthony, the import now works partially. The lib needs to know the database db is it possible to import that. from db import db doesn't work cheers, Stef On 21-01-14 23:55, Anthony wrote: Filename = os.path.join ( 'applications', request.application,'static\images\pic_%s.png' % Edit_Select), 'wb') | os.path.join(request.folder,'static','images','pic_%s.png'%Edit_Select) | Q2: I made some libraries that I want to use more than one project. Now I stored these in ..controllers/my_support_libs.py Controllers are not Python modules and cannot be imported. If you need to share a module, put it anywhere in the pythonpath and import from there. You can put it in the /modules folder of a given app and import from other apps via: | importapplications.myapp.modules.mymodule | Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: simplest way to get rid of None strings
thanks, I'll santinize the database onec a while. cheers, Stef On 19-01-14 13:45, Niphlod wrote: or, if indeed you want all strings fields with NULL values (backends side) or None (python side) to map to an empty string '', use none_value = None for f in db.table.fields: if db.table[f].type == 'string': db(db.table[f] == None).update(f='') On Sunday, January 19, 2014 3:21:49 AM UTC+1, Anthony wrote: but I mean the field is empty / Null / None (type), which is translated by web2py into a string value 'None'. None is translated into a string value as 'None' by Python, not web2py. If you want different behavior, you have to be explicit (no reason to assume the default behavior should be an empty string). You can achieve that by setting the represent attribute of the field: | Field('myfield',represent=lambdav,r:''ifv isNoneelsev) | or more simply: | Field('myfield',map_none='') | Those methods will work in the grid and SQLFORMs, but not if you simply do {{=row.myfield}} somewhere. In that case, you would have to do something like {{=row.myfield or ''}}, or use the Rows.render() method to extract the row, which will automatically apply the represent function -- {{=rows.render(0).myfield}}. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] simplest way to get rid of None strings
hello, my database (sqlite) is (partially) filled by another program, which inserts Null or None values. Now if I use these fields in an HTML form, they show up as None instead of an empty string. Is there a simple way to solve this for all fields at once ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: simplest way to get rid of None strings
thanks, it's a workaround, but I mean the field is empty / Null / None (type), which is translated by web2py into a string value 'None'. cheers, Stef On 18-01-14 19:06, Niphlod wrote: if you mean the other app fills the fields with an actual string that holds the 'None' value (it could be very well foo, bar or pizza) then fake_none_value = 'foo' for f in db.table.fields: db(db.table[f] == fake_none_value).update(f=None) should solve it On Saturday, January 18, 2014 5:12:36 PM UTC+1, aapaap wrote: hello, my database (sqlite) is (partially) filled by another program, which inserts Null or None values. Now if I use these fields in an HTML form, they show up as None instead of an empty string. Is there a simple way to solve this for all fields at once ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] How can I use a view in combination with a service ?
hello, maybe I'm doing this completely wrong, but it's a long time ago I used web2py. In the main page I have a lot of links. In fact these links are just indexes to a row in the database. As I understand, the only way to pass parameters from clicking a link, is to use services. An example of the link in my main document: a href={{=URL('call/run/Show_Page/%s' % record.id)}} {{=record.id}}.Link/a So I created a service: @service.run def Show_Page(ID): return 'Test' 'Test' is shown as the result, but the view views/default/Show_Page.html is not used. Can I not use a view with a service, or is it located on a different location ? thanks, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] where can I find older versions ?
thanks ! that one is working. cheers, Stef On 15-01-14 22:10, Niphlod wrote: he's seeking the binary. https://code.google.com/p/web2py/issues/detail?id=1809 However, I still can't reproduce the issue. You can download the 2.8.2 version that is not giving the error here https://www.dropbox.com/s/4o7ld0vmy9pl9g8/web2py_exe.py2exe.7z On Wednesday, January 15, 2014 3:19:17 PM UTC+1, Richard wrote: Github pick a tag download... Richard On Tue, Jan 14, 2014 at 7:28 PM, Stef Mientki stef.m...@gmail.com javascript: wrote: hi, where can I find older versions, because the latest version gives me this error wcscpy_s cound not be located in msvcrt.dll (winXP, 32 bit) cheers, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] where can I find older versions ?
hi, where can I find older versions, because the latest version gives me this error wcscpy_s cound not be located in msvcrt.dll (winXP, 32 bit) cheers, Stef -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] how to change the content of an IFRAME from a jquery menu
hello, Starting again with web2py (did a simple experiment 3 years ago), I'm struggling with changing the content of an IFrame. I've a few pages, one of them contains a vertical jquery menu on the left and an IFrame on the right (setting the width of the IFrame is also a small problem). Now I can attach URLs to the menu buttons, but that will redirect to the external file. I want the external file to be shown in the IFrame. How can it be done. cheers, Stef -- --- You received this message because you are subscribed to the Google Groups web2py-users group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Where to host web2py
is this really an Arduino, which chip, what clock frequency, which OS ? It seems much faster than the Raspberry-PI ! cheers, Stef On 20-08-2012 21:12, Simon Carr wrote: I think I have made a mistake with SWVPS, I would suggest that no one touch them. I had no response from them after sending my money, even though it was less than $20. I have sent them two emails to what is supposed to be 24/7 tech support and got no response. I am writing my $20 off, but don't wont anyone else to get burnt. If I had looked before I would have also have seen mountains of negative reviews. For the time being I have decided to self. Here is the URL for the welcome app, it seems to run very fast. http://www.arduino-mega.com Simon On 19 August 2012 15:24, Mike Girard mikegirar...@gmail.com mailto:mikegirar...@gmail.com wrote: Wow, those are great prices for VPS. Was there anything besides price that made you choose them? On Sunday, August 19, 2012 5:42:32 AM UTC-4, Simon Carr wrote: I have just found this service http://webkeepers.com I think i will give their medium service a try on the one month contract and see how it goes. The 4gb version seems very reasonable even on the monthly rates and better still if i decide to stick with them for a year. My only worry is that i am in the uk and so will most of my visitors/customers so latency might become an issue. I also have another option. I have virgin fibreoptic broadband with 120mb download and 10mb upload and a static ip. I have tried pointing my domain name at my home router before and it works fine. The only issue here is that i would have to invest in a new pc and the computer room shares a wall with the bedroom so the fan noise might become an issue at night. Will give webkeepers a try and report back with results. Simon On 19 Aug 2012 00:54, Simon Carr simon...@gmail.com wrote: After a few weeks of getting to know web2py i have decided that it should become one of the development tools in my tool belt. The only thing that is stopping me moving on however is hosting options. I am going to take a look at app engine as one option but i need to know that i can also deploy on a standard web server. I would need to be able to use apache which i know web2py can do but i am not sure how complicated this is. I also think that I am going to need to use a VPS but these go up in price very quickly beyond 1gb and 1 cpu. Can anyone give some comments on where they host, what spec server they have and what performance they get. Thanks Simon -- -- -- --
Re: [web2py] raspberry pi
I just did it, within 5 minutes. Python is already installed on the Raspberry-pi. - download the sources to the Raspberry - unpack the zip file - open a terminal window and go to the directory where it is unpacked - python web2py.py that's all. cheers, Stef On 13-03-2012 11:04, António Ramos wrote: it would be nice to be able to install web2py in raspberry pi http://www.raspberrypi.org/ --
Re: [web2py] Re: Published my collection of plugins
On 26-08-2011 19:18, Ross Peoples wrote: These are really great. The color picker plugin and form plugins are really useful to me. Thank you for sharing these. Maybe some of these could be integrated into web2py. +1
Re: [web2py] Re: fluxflex
really fantastic, despite the server 500 errors during sign up, web2py running within 2 minutes. cheers, Stef On 21-08-2011 22:11, Martín Mulone wrote: bye bye gae (?) 2011/8/21 Massimo Di Pierro massimo.dipie...@gmail.com mailto:massimo.dipie...@gmail.com This is fantastic. I will be travelling in the next few hours but I look forward to try it. I have been looking for something like this for long time! Massimo On Aug 21, 7:37 am, Omi Chiba ochib...@gmail.com mailto:ochib...@gmail.com wrote: Ichino who is a member of web2py Japan created a library on fluxflex and it works great ! http://www.fluxflex.com/library/47 1. Sign up fluxflex 2. Create new project (e.g. ochiba) 3. Install the library (It will be done in one second!) 4. Access to your project with HTTPS not HTTP (e.g.https://ochiba.fluxflex.com) 5. Access Administrative Interface with /admin (e.g.https://ochiba.fluxflex.com/admin ) 5. Admin password is the same as your MySQL database on fluxflex project. Enjoy :) -- http://martin.tecnodoc.com.ar
Re: [web2py] Re: LessCSS -- really interesting CSS compiler
On 25-06-2011 13:51, Joe Barnhart wrote: That's http://lesscss.org/ Sheesh. On Jun 25, 7:50 pm, Joe Barnhart joe.barnh...@gmail.com wrote: http://lescss.org/ thanks Joe, I've looking for such a tool for years. cheers, Stef
[web2py] has anyone used fathom (or something alike) with web2py DAL ?
hello, has anyone used pathom http://code.google.com/p/fathom/downloads/list especially the GraphViz representation looks usefull to me. Are there other packages that can show a representatie like this ? thanks, Stef
Re: [web2py] Re: Japan
On 13-03-2011 05:52, Anthony wrote: Note, the Sahana Software Foundation is looking for translators to complete a localization of Sahana Eden into Japanese: http://www.sahanafoundation.org/japan Sahana Eden is an open source disaster management system written in web2py. I read google would coordinate this, and it would be a bad idea if we go to the old way, in which a large number of communities starts to collect uncorrelated information ? cheers, Stef Anthony
[web2py] Re: mssql, login problems
As it doesn't seem possible to change self._uri in SQLDB, I solved the problem by adding an extra keyword argument (which travels to SQLDB): Database_Name = r'mssql://NKCV2 *MSSQL_Login = ';UID=MY_SQL_LOGIN;PWD=MY_PASSWORD' *My_DB = DAL ( Database_Name, folder = folder, *MSSQL_Login = MSSQL_Login* ) cheers, Stef On 05-03-2011 00:34, Stef Mientki wrote: hello, With the DAL I created tables in an MSSQL database, which I can access as long as I login as the same user. I created the table with a windows login on my own machine, like this Database_Name = r'mssql://NKCV2' My_DB = DAL ( Database_Name, folder = folder ) Now I'm on anther machine, I can not use the windows login, so I use a MSSQL login ( I found the syntax by trial and error) *Database_Name = r'mssql://NKCV2;UID=MY_SQL_LOGIN;PWD=MY_PASSWORD' *My_DB = DAL ( Database_Name, folder = folder ) The login works, I can contact de database, with the DAL is trying to create new tables (which I'm not allowed, and as far as know, I don't need to because they are already there) File P:\Python26\lib\site-packages\gluon\sql.py, line 1100, in lambda self._execute = lambda *a, **b: self._cursor.execute(*a, **b) ProgrammingError: ('42000', [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]CREATE TABLE permission denied in database 'NKCV2'. (262) (SQLExecDirectW)) Could this be caused, by the DAL creating other filenames to store the table information ? Any suggestions to solve this problem ? thanks, Stef Mientki
[web2py] mssql, login problems
hello, With the DAL I created tables in an MSSQL database, which I can access as long as I login as the same user. I created the table with a windows login on my own machine, like this Database_Name = r'mssql://NKCV2' My_DB = DAL ( Database_Name, folder = folder ) Now I'm on anther machine, I can not use the windows login, so I use a MSSQL login ( I found the syntax by trial and error) *Database_Name = r'mssql://NKCV2;UID=MY_SQL_LOGIN;PWD=MY_PASSWORD' *My_DB = DAL ( Database_Name, folder = folder ) The login works, I can contact de database, with the DAL is trying to create new tables (which I'm not allowed, and as far as know, I don't need to because they are already there) File P:\Python26\lib\site-packages\gluon\sql.py, line 1100, in lambda self._execute = lambda *a, **b: self._cursor.execute(*a, **b) ProgrammingError: ('42000', [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]CREATE TABLE permission denied in database 'NKCV2'. (262) (SQLExecDirectW)) Could this be caused, by the DAL creating other filenames to store the table information ? Any suggestions to solve this problem ? thanks, Stef Mientki
Re: [web2py] Re: text type fields in MSSQL
I've just started with mssql (after using sqlite, postgresql and mysql, I'm not very happy at the moment ;-) I guess utf-16 would be the best way to go for the future. (as my current database is quit large, I think at the moment I'll stick to windows-1252 coding ;-) further more in my humble opinion NTEXT should be replaced by NVARCHAR(MAX) IMAGE should be replaced by VARBINARY(MAX) Stef Mientkie On 02-03-2011 19:12, Ross Peoples wrote: Good question. If web2py is using unicode and going for internationalization, then NVARCHAR is the way to code. It stores all text as unicode, but it requires twice the storage space of VARCHAR because it uses two bytes to encode each character. And I have to ask: what is the motivation for using CHAR(1) over BIT for boolean fields? On Mar 2, 2011, at 12:49 PM, Massimo Di Pierro wrote: Makes sense. The name is not the issue. The issue is what should the mssql2005 types be: types = { 'boolean': 'BIT', 'string': 'VARCHAR(%(length)s)', 'text': 'TEXT', 'password': 'VARCHAR(%(length)s)', 'blob': 'IMAGE', 'upload': 'VARCHAR(%(length)s)', 'integer': 'INT', 'double': 'FLOAT', 'decimal': 'NUMERIC(%(precision)s,%(scale)s)', 'date': 'DATETIME', 'time': 'CHAR(8)', 'datetime': 'DATETIME', 'id': 'INT IDENTITY PRIMARY KEY', 'reference': 'INT, CONSTRAINT %(constraint_name)s FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_key)s ON DELETE % (on_delete_action)s', 'reference FK': ', CONSTRAINT FK_%(constraint_name)s FOREIGN KEY (% (field_name)s) REFERENCES %(foreign_key)s ON DELETE % (on_delete_action)s', 'reference TFK': ' CONSTRAINT FK_%(foreign_table)s_PK FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_table)s (%(foreign_key)s) ON DELETE %(on_delete_action)s', 'list:integer': 'TEXT', 'list:string': 'TEXT', 'list:reference': 'TEXT', } or types = { 'boolean': 'CHAR(1)', 'string': 'NVARCHAR(%(length)s)', 'text': 'NTEXT', 'password': 'NVARCHAR(%(length)s)', 'blob': 'IMAGE', 'upload': 'NVARCHAR(%(length)s)', 'integer': 'INT', 'double': 'FLOAT', 'decimal': 'NUMERIC(%(precision)s,%(scale)s)', 'date': 'DATETIME', 'time': 'CHAR(8)', 'datetime': 'DATETIME', 'id': 'INT IDENTITY PRIMARY KEY', 'reference': 'INT, CONSTRAINT %(constraint_name)s FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_key)s ON DELETE % (on_delete_action)s', 'reference FK': ', CONSTRAINT FK_%(constraint_name)s FOREIGN KEY (% (field_name)s) REFERENCES %(foreign_key)s ON DELETE % (on_delete_action)s', 'reference TFK': ' CONSTRAINT FK_%(foreign_table)s_PK FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_table)s (%(foreign_key)s) ON DELETE %(on_delete_action)s', 'list:integer': 'NTEXT', 'list:string': 'NTEXT', 'list:reference': 'NTEXT', } and should the string representation in SQL be 'value' or N'value' ? On Mar 2, 11:38 am, Ross Peoples ross.peop...@gmail.com wrote: Actually thinking about this a bit more, mssql should be used for MSSQL 2000, and mssql2005 instead of mssql2, and mssql3. The mssql will be compatible with 2000, 2005, and 2008, while mssql2005 will be compatible with 2005, 2008, and up. What do you think about that? On Mar 2, 2011, at 10:52 AM, Massimo Di Pierro wrote: Let's create a mssql3 that does it by the book (or do you think MS will keep changing the API?) On Mar 2, 9:11 am, Ross Peoples ross.peop...@gmail.com wrote: The only I problem I see is that MSSQL 2000 will not understand varchar(max). For reference, there is a StackOverflow question that relates to this:http://stackoverflow.com/questions/737755/varcharmax-ms-sql-server-20...
Re: [web2py] Re: MSSQL or MSSQL2
On 14-02-2011 22:17, Massimo Di Pierro wrote: The difference is subtle. as SQLserver uses utf-16, the size will double, am I correct ? thanks, Stef Mientki mssql is the first version of the adapter, the one that everybody uses. It stores data as UTF8 but in ascii. That means the length of the fields is not the number of unicode chars but the length of the utf8 encoded chars. It also uses BIT for booleans. mssql2 uses unicode so length is correct and CHAR(1) (T or F) for booleans. This is newer and less tested. On Feb 14, 1:15 pm, Ross Peoples ross.peop...@gmail.com wrote: I am new to web2py and I just finished reading the book and have started to develop my first application. I recently had the same problem mentioned in this thread:http://groups.google.com/group/web2py/browse_thread/thread/e620c5708f... I was wondering though, what is the difference between using mssql:// and mssql2? I am currently developing an application using am existing database on Microsoft SQL Server 2000 that will eventually be upgraded to Microsoft SQL Server 2008 R2. Thanks
[web2py] text type fields in MSSQL
hello, as text, ntext, image(blob), are deprecated, I would suggest to change these in varchar(max), nvarchar(max), varbinary(max) Assuming this is a correct suggestion, would it be enough to change the following 'mssql': { 'boolean': 'BIT', 'string': 'VARCHAR(%(length)s)', 'text': 'TEXT', 'password': 'VARCHAR(%(length)s)', 'blob': 'IMAGE', into 'mssql': { 'boolean': 'BIT', 'string': 'VARCHAR(%(length)s)', 'text': 'VARCHAR(%(length)s)', 'password': 'VARCHAR(%(length)s)', 'blob': 'VARBINARY(max)', or should there be mad other changes ? thanks, Stef Mientki
[web2py] mssql2, decoding Unicode is not supported
hello, using mssql2, gives me an error in sql.py, trying to connect to the database here: elif self._uri.startswith('mssql2://'): self._execute = lambda a: \ self._cursor.execute(unicode(a, 'utf8')) TypeError: decoding Unicode is not supported how can I solve it ? thanks, Stef Mientki
[web2py] connectionstring for mssql ? , DSN ?
hello, i'm a little bit confused about how the connectionstring should look fro coupling a remote mssql database through odbc. I was first searching for a odbc connecting string, and I'm finding that odbc is not considered as database engine but as a protocol ??? Both the databasename and the DSN name in the ODBC definition is test I can connect to the database with: conn = pyodbc.connect ( 'DSN=test; UID=z571117' ) print conn Now with the DAL, I tried several constructs (the constructs below are also tried with the correct password), and none of them seem to work Database_Name = r'mssql://z571117:@test/test' Database_Name = r'mssql://z571117:@test' Database_Name = r'mssql://z571117:@localhost/test' Database_Name = r'mssql://z571117:/test' My_DB = DAL ( Database_Name ) What shpuld the connectionstring look like ? Do I have to specify an alias in the ODBC manager or can I do without ? thanks, Stef Mientki
[web2py] [OT] Can I use the DAL to create a client/server PostgreSQl (or MySQL) on a home network ?
hello, The DAL is really great to switch between different backend databases !! Now I'ld like to use another computer in my home network (Windows) to do the heavy database stuff, is this possible with the DAL ? How should I address the Database server on the other computer ? And should I make special settings in the PostgreSQL (MySQL) server ? thanks, Stef Mientki
[web2py] logging time spent in sql statements ?
hello, is there a way to log the time-duration of all sql statements ? thanks, Stef Mientki
Re: [web2py] JQuery harmonica menu, but what's the use in web2py, I'm totally confused
Thanks Tom, your answer helped me a lot. I come to the following conclusion: - Relatively little information, which much GUI interactive changes can best be done in JS. (btw I use PyJamas for that so I can program in pure Python) - Much information, which heavily changes on the base of user interaction can best be done by web2py. - The use of fancy JQuery widgets within web2py had not much meaning (because of the reload of the whole page) - JQuery widgets within web2py should be limited to simple effects (with already available data), like flash objects, pull-down menus, calendars etc. cheers, Stef On 03-02-2011 09:16, Tom Atkins wrote: This isn't really a direct answer to your question but it might help clarify some things for you (it got me thinking anyway)... it's a quote from a user on another mailing list: There's been a big move toward Javascript-heavy web apps in the last couple of years, and new tools frameworks are springing up to ease JS development -- see Backbone.js, Knockout.js, etc. The model here is typically to move almost the entire app to the front end. After the initial page load, everything happens in a single page, with no page refresh. A server-side backend is still (usually) a necessary component, but it's reduced to a dumb pipe to shuttle data to/from the database via JSON. This approach makes it possible to create much richer apps with lower latency, so it's a pretty clear win for user experience. I'm creating an app right now (in Flask) that could benefit from such an approach. The problem is that you have to write most of your app in JS to do so. It also appears to increase the complexity of development quite a bit (beyond just learning a new tool), and tools in this space are fairly new and immature. But I think it's clear that this is where web development is headed. Most server-side frameworks are still firmly rooted in the old way of doing things. It's possible to pair them with a JS-centric front end, sure, but you give up most of their power by doing so. Do you see frameworks changing in the next couple of years to accommodate this approach? Are there big roadblocks to doing so? (link for the source of this quote is http://flask.pocoo.org/mailinglist/archive/2011/1/31/flask-and-javascript-centric-front-ends/) There are of course still huge uses for web2py and other server centric frameworks (not least ease of development) - but if your app is (almost) one page you may find a javascript option more suitable. The CoffeScript site is a good example of a single (large) page Javascript app (and if you know Python but not Javascript you may fall in love with CoffeScript): http://jashkenas.github.com http://jashkenas.github.com/ Have fun! On 3 February 2011 00:43, Stef Mientki stef.mien...@gmail.com mailto:stef.mien...@gmail.com wrote: hello, at the moment I'm totally confused about what should be where I made a page with 2 columns, on the left a vertical menu and on the center and right the contents to show. The contents to be shown are paragraphs of a book. The left menu shows the chapters of the book, and the submenus shows the paragraph titles. Now I wanted to use a harmonica menu for the left menu, so I found a JQuery harmonica menu, which works quit nice, the chapter on which you click is expanded and all other chapters are closed. As long as you don't attach a link to the paragraph menu items, it really looks very nice. This is the main JQuery script script src=static/jquery.js/script script $(document).ready(function(){ $(dd:not(:first)).hide(); $(dt a).click(function(){ $(dd:visible).slideUp(slow); $(this).parent().next().slideDown(slow); return false; }); }); /script But how should that work with web2py, if the whole page is refreshed each load of a new paragraph. A load also rebuilds the harmonica menu. Now I could think of 2 solutions, and I'm not sure which is the best, or if they are all bad. first solution: load the new paragraph in an I-frame (or something like that, I'm not an expert), but I think that will be destroy a lot of power of web2py. second solution: dont't use the jquery harmonica menu at all, but let the controller in web2py build a specific menu + (submenus for 1 menu item) for each new page. Another side effect is that reloading a new chapter gives a lot of flicker, because although the major part of the screen is (semi-) static, each new call the whole page is refreshed. How in general can you mainitain those static parts with web2py ? Sorry for the long story, but I've the feeling I'm missing something very essential in building web2py pages. thanks, Stef Mientki
[web2py] JQuery harmonica menu, but what's the use in web2py, I'm totally confused
hello, at the moment I'm totally confused about what should be where I made a page with 2 columns, on the left a vertical menu and on the center and right the contents to show. The contents to be shown are paragraphs of a book. The left menu shows the chapters of the book, and the submenus shows the paragraph titles. Now I wanted to use a harmonica menu for the left menu, so I found a JQuery harmonica menu, which works quit nice, the chapter on which you click is expanded and all other chapters are closed. As long as you don't attach a link to the paragraph menu items, it really looks very nice. This is the main JQuery script script src=static/jquery.js/script script $(document).ready(function(){ $(dd:not(:first)).hide(); $(dt a).click(function(){ $(dd:visible).slideUp(slow); $(this).parent().next().slideDown(slow); return false; }); }); /script But how should that work with web2py, if the whole page is refreshed each load of a new paragraph. A load also rebuilds the harmonica menu. Now I could think of 2 solutions, and I'm not sure which is the best, or if they are all bad. first solution: load the new paragraph in an I-frame (or something like that, I'm not an expert), but I think that will be destroy a lot of power of web2py. second solution: dont't use the jquery harmonica menu at all, but let the controller in web2py build a specific menu + (submenus for 1 menu item) for each new page. Another side effect is that reloading a new chapter gives a lot of flicker, because although the major part of the screen is (semi-) static, each new call the whole page is refreshed. How in general can you mainitain those static parts with web2py ? Sorry for the long story, but I've the feeling I'm missing something very essential in building web2py pages. thanks, Stef Mientki
[web2py] inconsistency ? == and belongs
hello, I thought the DAL was ment to be Pythonic. Writing a query to search for a records with some specific id, I have to use the Pythonic == instead of the SQL-like = Rows = DB ( DB.Excel_List.id == 3 ).select() Writing a query to search for a records with some a range of id's, I have to use the SQL-like belongs Rows = DB ( DB.Excel_List.id.belongs((3,4))).select() instead of the Pythonic in Rows = DB ( DB.Excel_List.id in (3,4) ).select() Why is that ? thanks, Stef Mientki
Re: [web2py] Re: inconsistency ? == and belongs
of course, stupid of me, thanks very much Massimo, cheers, Stef
Re: [web2py] Hassle-Free Application Hosting?
On 09-01-2011 18:04, Bruno Rocha wrote: hello Bruno, do have an easy recipy to setup a web2py site on alwaysdata ? (deploying is one of the scaring tasks for beginners) thanks, Stef Its in French - http://wiki.alwaysdata.com/wiki/D%C3%A9ployer_une_application_web2py a little outdated, needs to test if this still works. -- Bruno Rocha http://about.me/rochacbruno/bio thanks very much Bruno, finally found a friend who was willing to help me, because if you don't understand webinterfaces, even with your description I didn't get it working. Some small additions, which might seem very minor for people who know webinterfaces, but are very important for ignorant copiers: - translating your description with google, affects the case of some characters - you should start with a fresh web2py source and not a used copy from your harddisk - CR/LF which are automatically inserted under windows are not allowed inyour scripts, you may only use '\n' after that it works like a charm. We even got web2py now working under IIS7, with https and without Apache or Helicon package. If there's any interest, I'll post a description here soon. cheers, Stef Mientki
[web2py] is there a way to rename a database ?
hello, I would like to rename a database, is that possible ? thanks, Stef Mientki
Re: [web2py] Hassle-Free Application Hosting?
On 09-01-2011 16:21, Bruno Rocha wrote: I am playing with free beta on dotcloud (this will be great). for free that runs web2py I just know one (shared limited plan is free): http://www.alwaysdata.com/plans/shared/ http://web2py.alwaysdata.net/examples hello Bruno, do have an easy recipy to setup a web2py site on alwaysdata ? (deploying is one of the scaring tasks for beginners) thanks, Stef BTW, I do not know any other that works like heroku. 2011/1/9 Syed syed.f.ka...@gmail.com mailto:syed.f.ka...@gmail.com Are there any application hosting services for web2py that are similar to the following (for other frameworks): Heroku for Ruby on Rails Djangy for Django Pantheon for Drupal I know that it's possible to use GAE for hosting, but there are some limitations to going that route. I understand that Webfaction offers hosting, but it's just normal shared hosting, right? It would be great if there was a fire-and-forget application hosting option for web2py just like Heroku or Engine Yard. -- Bruno Rocha http://about.me/rochacbruno/bio
[web2py] a few small suggestions
hello, using some jQuery components (harmonica menu), I came across a few tags for which there is no helper function. I think these tags (DL, DD, DT) are regular in jQuery. So my first suggestion is to add helper functions DL, DD, DT. My second suggestion is to make the serialized output somewhat more readible, by inserting linefeeds ( and if possible indentation, but that might be quit difficult) so debugging becomes somewhat easier. thanks, Stef Mientki
Re: [web2py] a few small suggestions
On 03-01-2011 22:27, Bruno Rocha wrote: {{=TAG.DL('something')}} {{=TAG.DD('something')}} {{=TAG.DT('something')}} Yes, but as these tags are used in a rather nested way, like this Harmonica = DL() for Chapter in range ( N_Chapter ): My_URL = 'Show_Page/%s/%s/%s' % ( Book, Chapter, 0 ) My_Text = %s %( Chapters [ Chapter ] ) Harmonica.append ( DT ( A ( My_Text, _href = URL (My_URL ) ) ) ) Subs = UL () Paragraphs = PH.Get_Paragraphs ( Book, Chapter ) N_Paragraphs = len ( Paragraphs ) for i in range ( N_Paragraphs ) : My_URL = 'Show_Page/%s/%s/%s' % ( Book, Chapter, i ) My_Text = %s %( Paragraphs [ i ] ) Subs.append ( LI ( A ( My_Text, _href = URL ( My_URL ) ) ) ) Harmonica.append ( DD ( Subs ) ) I'ld like more something like this: class DL(DIV): tag = 'dl' class DD(DIV): tag = 'dd' class DT(DIV): tag = 'dt' ok, it was a small suggestion ;-) cheers, Stef 2011/1/3 Stef Mientki stef.mien...@gmail.com mailto:stef.mien...@gmail.com hello, using some jQuery components (harmonica menu), I came across a few tags for which there is no helper function. I think these tags (DL, DD, DT) are regular in jQuery. So my first suggestion is to add helper functions DL, DD, DT. My second suggestion is to make the serialized output somewhat more readible, by inserting linefeeds ( and if possible indentation, but that might be quit difficult) so debugging becomes somewhat easier. thanks, Stef Mientki -- Bruno Rocha http://about.me/rochacbruno/bio
[web2py] vertical accordion menu ?
hallo, has anyone a vertical accordion menu fro web2py ? thanks, Stef Mientki
Re: [web2py] Re: I don't understand this error, anyone to help ?
On 29-12-2010 21:37, Arun K.Rajeevan wrote: great as far as 25 page pdf is in consideration. next time a simple text file is good enough. sorry about the large file, but I thought to give as much information as possible how the page get rendered? Mozilla printing to pdf using generic.html or is it have a custom view file? And what's the controller returns? btw which version of web2py you are using? don't know, but got the problem, the strings are derived from a completely other website, with the use of BeautifulSoup, and then strings are of type class 'BeautifulSoup.NavigableString' so typecasting them as unicode solves the problem. thanks Stef Mientki --- for others: there's these lines in trace back File P:\Web2PY\web2py_src\web2py\gluon\html.py, line 118, in xmlescape data = data.encode('utf8', 'xmlcharrefreplace') TypeError: encode() takes at most 2 arguments (3 given) Detailed traceback description Exception: type 'exceptions.TypeError'(encode() takes at most 2 arguments (3 given)) Python 2.6.4: P:\Python26\python.exe
Re: [web2py] Re: I don't understand this error, anyone to help ?
thanks very much guys, but probably you missed the solution I posted about an hour ago: strings are of type class 'BeautifulSoup.NavigableString' cheers Stef On 29-12-2010 22:51, Jonathan Lundell wrote: On Dec 29, 2010, at 1:35 PM, mdipierro wrote: Probably it is counting data.encode('utf8', 'xmlcharrefreplace') data as self and 'utf8' as second argument. yet it is strange because this is valid syntax. That occurred to me, too, but that's not what's happening. See my test sequence: data = u'abcd' data.encode('utf8', 'xmlcharrefreplace') 'abcd' data.encode('utf8', 'xmlcharrefreplace', 1) Traceback (most recent call last): File stdin, line 1, in module TypeError: encode() takes at most 2 arguments (3 given) isinstance(data, unicode) True On Dec 29, 3:08 pm, Jonathan Lundell jlund...@pobox.com wrote: On Dec 29, 2010, at 12:37 PM, Arun K.Rajeevan wrote: great as far as 25 page pdf is in consideration. next time a simple text file is good enough. how the page get rendered? using generic.html or is it have a custom view file? And what's the controller returns? btw which version of web2py you are using? --- for others: there's these lines in trace back File P:\Web2PY\web2py_src\web2py\gluon\html.py, line 118, in xmlescape data = data.encode('utf8', 'xmlcharrefreplace') TypeError: encode() takes at most 2 arguments (3 given) Detailed traceback description Exception: type 'exceptions.TypeError'(encode() takes at most 2 arguments (3 given)) Python 2.6.4: P:\Python26\python.exe I looked at this briefly. It's a rather strange error message, given that in fact only two arguments are given. I ran a little test sequence to verify: data = u'abcd' data.encode('utf8', 'xmlcharrefreplace') 'abcd' data.encode('utf8', 'xmlcharrefreplace', 1) Traceback (most recent call last): File stdin, line 1, in module TypeError: encode() takes at most 2 arguments (3 given) isinstance(data, unicode) True
[web2py] What's the best way to insert raw html ?
hello, I'v raw html derived with BeautifulSoup from another webpage, which I want insert in the contents of the web. The images in the orginal webpage are located in the same directory as the html page. The orginal webpage is moved to a database, and the images are placed into the web2py application's static/images/... Now I encounter 2 problems: 1. the raw html contains tags, like: ptoch iets over stromen, een plaatje/ppbr //pbr /pnbsp;nbsp; I remove them with the helper function TAG. Although it seems to work, I'm not convinced that this is the right method. Is this the correct way ? Are there better ways ? The second problem is the image locations: pimg width=307 height=244 alt= src=veiligheid_website_img1.jpg //p I change the image location with, not a neat way, but it works. Any better ways ? Result = DIV () Result.append ( H2 ( Book + ', ' + Chapter ) ) Result.append ( H3 ( Paragraph ) ) Text = Text.replace ( 'src=', 'src=/E_Veiligheid/static/images/' ) Result.append ( TAG ( Text ) ) thanks, Stef Mientki
Re: [web2py] What's the best way to insert raw html ?
An alternative to Text.replace would be to do a global regex substitution, where the replacement pattern is a function that calls URL('static', 'images/%s' % matchobj.group(0)). See the re.sub section of http://docs.python.org/library/re.html for details. regex are too difficult for me But for your purposes, the code below, more or less, ought to do it. prefix = URL('static', 'images') Result = DIV( H2(Book + ', ' + Chapter), H3(Paragraph), XML(Text.replace('src=', 'src=%s/' % prefix) ) perfect, many thanks Jonathan, that's exactly what I'm looking for. cheers, Stef
Re: [web2py] Re: executing code from db
On 27-12-2010 21:23, mdipierro wrote: cube2py is just a scaffolding app + plugin_wiki. The code is in question is also in plugin_wiki although people do not seem to use it (and I am not sure it is in general a good idea to store code in db). I wonder why not ? it might be unconventional, and the advantage is that the code can not be so easily changed (by accident). And isn't a file system not just a crappy ( almost not relational) database ? And if you look at e.g. Sage, code is even stored in between text files ;-) cheers, Stef
Re: [web2py] Merry Christmas
+1, btw, what a nice signature !! cheers, Stef On 23-12-2010 08:17, ? Kuldeep Singh PHP FreeLancer Web Developer,SEO Services wrote: Marry Christmas to all of you ...From Kaysellers.com On 23 December 2010 12:40, ma...@rockiger.com mailto:ma...@rockiger.com rocki...@googlemail.com mailto:rocki...@googlemail.com wrote: Merry Christmas and a happy new your to all you web2py-contributors. You do an awesome work - everyone. Marco -- Kuldeep Singh... WebDeveloper And Freelancer Kay Sellers, Owner:http://kaysellers.com +9199142-41733,*+91-9501710226(Allways Switched On)* Skype ID : kaydeveloper Yahoo:deepulove123321 On Twitter:http://twitter.com/ruhisoftect We Provide:- Adobe AIR,E-Commerce PHP Web and Desktop Applications,Wordpress Themes,Drupal Themes,Joomla Templates,Joomla Components Modules Plugins,Java,ERP,MLM Development and Logic Design,Ajax,Jquery,RSS Feeds,PhotoShop,Flex,Payment Solutions.
[web2py] OT: why are old style classes still used ?
hello, a few weeks ago, I was debugging a web2py application, and printing some intermediate variables I got weird results, like : TypeError: 'int' object is not callable and |type 'instance'| || |I didn't understand these results then,| |and solved my problems in another way Now I debugging a totally different program, and I'm facing the same problems. As I can't get around the problem in another way, I looked up the problem. And it seems to be caused by using old-style classes. Now I wonder, is it deliberately that web2py uses old-style classes, or is it just an inheritance from the past ? thanks, Stef Mientki | || | |
Re: [web2py] Re: OT: why are old style classes still used ?
thanks Massimo. cheers, Stef On 18-12-2010 17:00, mdipierro wrote: web2py should use new style classee everywhere. Prompted by your messages and an email form Jonathan and double checked and I found a few old style classes around. I just fixed them in trunk. massimo On Dec 18, 4:32 am, Stef Mientki stef.mien...@gmail.com wrote:
Re: [web2py] Time to relax, off topic - Simple IQ Testing.
On 03-12-2010 15:32, António Ramos wrote: 2+3=10 7+2=63 6+5=66 8+4=96 So: 9+7=??? What is the answer? They say the IQ of people that can find it is above 120 Dont write here the answer.. Just the time, maybe 10s
Re: [web2py] Re: Time to relax, off topic - Simple IQ Testing.
Although the result seems to be ok, I don't understand a bit of this program, so my IQ must be well under 120 ;-) Can you explain the program, because I can not see the program and my solution. cheers, Stef On 03-12-2010 16:26, Richard Vézina wrote: Google! On Fri, Dec 3, 2010 at 10:22 AM, mdipierro mdipie...@cs.depaul.edu mailto:mdipie...@cs.depaul.edu wrote: I am too dumb to solve it but this program can: x=[(2,3,10),(7,2,63),(6,5,66),(8,4,96)] alphabet = 'ab+-*' for i in range(10): e = '' while i: e = e+alphabet[i%5] i = i / 5 try: for (a,b,c) in x: if eval(e)!=c: raise Exception a,b = 9,7 print eval(e) break except: pass On Dec 3, 8:32 am, António Ramos ramstei...@gmail.com mailto:ramstei...@gmail.com wrote: 2+3=10 7+2=63 6+5=66 8+4=96 So: 9+7=??? What is the answer? They say the IQ of people that can find it is above 120 Dont write here the answer.. Just the time, maybe
Re: [web2py] Re: Time to relax, off topic - Simple IQ Testing.
On 03-12-2010 16:39, Anthony wrote: 10s Are you saying it took you .002 + 83.3313 minutes? yep, very nice !!
Re: [web2py] Re: Time to relax, off topic - Simple IQ Testing.
very inserting!! (insert print e and the explanation is there ) On 03-12-2010 16:26, Richard Vézina wrote: Google! On Fri, Dec 3, 2010 at 10:22 AM, mdipierro mdipie...@cs.depaul.edu mailto:mdipie...@cs.depaul.edu wrote: I am too dumb to solve it but this program can: x=[(2,3,10),(7,2,63),(6,5,66),(8,4,96)] alphabet = 'ab+-*' for i in range(10): e = '' while i: e = e+alphabet[i%5] i = i / 5 try: for (a,b,c) in x: if eval(e)!=c: raise Exception a,b = 9,7 print eval(e) break except: pass On Dec 3, 8:32 am, António Ramos ramstei...@gmail.com mailto:ramstei...@gmail.com wrote: 2+3=10 7+2=63 6+5=66 8+4=96 So: 9+7=??? What is the answer? They say the IQ of people that can find it is above 120 Dont write here the answer.. Just the time, maybe
Re: [web2py] Re: Time to relax, off topic - Simple IQ Testing.
On 03-12-2010 17:31, Jonathan Lundell wrote: On Dec 3, 2010, at 7:22 AM, mdipierro wrote: I am too dumb to solve it but this program can: Cute, though the program somewhat presupposes the pattern of the answer. The answer was obvious at a glance to those of us who had multiplication tables drilled into us all those years ago, I think. and a lot of luck !!
Re: [web2py] convert a string to a table or field?
On 02-12-2010 01:11, Lorin Rivers wrote: I tried making a generic function that created a table variable by concatenating strings. myTable = tableBuilder('inverter',period=5) def tableBuilder(element,period=0): if element == 'inverter': if period = 0: return 'db4.' + 'arraydata_table' that doesn't return a table variable, but a string, so maybe you want return eval ( 'db4' + 'arraydata_table') cheers, Stef elif period = 1: return 'db4.array_mins' else: return 'db4.array_' + period + 'mins' That results in a syntax error. Can I do this or do I have to consider every elif? Like this: elif element == 'arrays': if period = 0: return db4.arraydata_table elif period = 1: return db4.array_mins elif period = 5: return db4.array_5mins
[web2py] Space makes the difference ? what's the preferred substitution, string or objects
hello, I'm trying to build some (not trivial) queries and encounter a number of problems my first problem is that a space makes a huge difference, is that to be expected ? this *works* as (I) expected Select = Name, Test_Count Rows = DB ( Query ).select ( Select ) print Rows[0] Row {'_extra': Row {'Test_Count': 1000, 'Name': u'breath_algvm'}} but removing the space from the string, gives me an *unexpected result* Select = Name,Test_Count ### -- space removed Rows = DB ( Query ).select ( Select ) print Rows[0] Row {'_extra': Row {'Name,Test_Count': u'breath_algvm'}} The second problem, has to do with what's the preferred substitution, string or objects ? this *works* : Select = DB.VraagList.Name Rows = DB ( Query ).select ( Select ) print Rows[0] This *doesn't work* Select = DB.VraagList.Name, DB.VraagList.id Rows = DB ( Query ).select ( Select ) print Rows[0] for the record, this is the Query in all the above PID = 1018 Query = ( DB.VraagList.id == DB.Opnamen.VLID ) \ ( DB.Opnamen.PID == PID ) thanks, Stef Mientki
Re: [web2py] Re: Space makes the difference ? what's the preferred substitution, string or objects
thanks Denes, I think I understand it now. I often make this mistake, I start as A.select ( 'Name', 'Module' ) now if the selct list becomes too large, I put it in an internediate variable, just by cutting and pasting Select = 'Name', 'Module' A.select ( Select ) and yes it's Python, now Select is packed :-( Or I start with a single Field name Select = 'Name' A.select ( Select ) And in my ignorance I add an extra fieldname to Select Select = 'Name', 'Module' same story :-( As web2py is so tolerant, I wonder why web2py doesn't it support the last remaining possibilities: Set.select ( x ), works if x = + nothing + DB.Table.ALL + fieldname as a string + FieldObject as DB.Table.Field + FieldObject as DB.Table [ 'Field' ] + unpacked iterable of fieldnames (each as a string) + unpacked iterable of FieldObjects Set.select ( x), doesn't work if x = - empty string - None - string, where fields are comma separated - packed iterable of fieldnames (each as a string) - packed iterable of FieldObjects as an excercise, I wrote a litlle wrapper, that takes anything, very handy for people like me ;-) def Test_Select ( Select, Text ) : from General_Globals import Iterable if not ( Select ) : print Text, A.select ()[:2] return if isinstance ( Select, basestring ) and ( ',' in Select ) : Select = Select.split(',') if Iterable ( Select ) : print Text, A.select ( *Select )[:2] else : print Text, A.select ( Select )[:2] Test_Select ( '', 'Empty string:') Test_Select ( None, 'None:') Test_Select ( 'Name,Module', 'Comma separated string:') Test_Select ( ['Name', 'Module'], 'Packed string iterable:') Test_Select ( [DB.VraagList.Name, DB.VraagList.Module], 'Packed iterable of FieldObjects') Test_Select ( [DB.VraagList['Name'], DB.VraagList['Module']], 'Packed iterable of FieldObjects') On 30-11-2010 15:10, DenesL wrote: On Nov 30, 7:57 am, Stef Mientki stef.mien...@gmail.com wrote: hello, I'm trying to build some (not trivial) queries and encounter a number of problems my first problem is that a space makes a huge difference, is that to be expected ? this *works* as (I) expected Select = Name, Test_Count Rows = DB ( Query ).select ( Select ) it is select(*fields, **attributes) where fields is a alist and attributes is a dictionary (according to python not web2py) print Rows[0] Row {'_extra': Row {'Test_Count': 1000, 'Name': u'breath_algvm'}} here you are just lucky that the internal processing builds something similar to what is required for the real DB query, you can see it using: DB(Query)._select(Select) # note the underscore but removing the space from the string, gives me an *unexpected result* Select = Name,Test_Count ### -- space removed Rows = DB ( Query ).select ( Select ) print Rows[0] Row {'_extra': Row {'Name,Test_Count': u'breath_algvm'}} The second problem, has to do with what's the preferred substitution, string or objects ? this *works* : Select = DB.VraagList.Name Rows = DB ( Query ).select ( Select ) print Rows[0] This *doesn't work* Select = DB.VraagList.Name, DB.VraagList.id python (not web2py) creates a tuple with both fields which is usable as explained below Rows = DB ( Query ).select ( Select ) the correct call (python's rules) would be: Rows = DB ( Query ).select( *Select ) print Rows[0] for the record, this is the Query in all the above PID = 1018 Query = ( DB.VraagList.id == DB.Opnamen.VLID ) \ ( DB.Opnamen.PID == PID ) thanks, Stef Mientki
Re: [web2py] Re: Scalability of web2py?
On 30-11-2010 21:08, VP wrote: I think .NET and web2py are not competitors. They are different ball games. When things scale large, everything is important. A small design issue might be magnified. I don't think web2py is proven yet, in terms of scalability. What web2py needs is at least one real example to show that it is scalable and what are the limits at the extreme. I'm not sure were session files are used for, but isn't file access much slower than database access ? Can session files be turned of ? cheers, Stef
[web2py] session files, what's in it, how can they be read ?
hello, session files, what's in it, how can they be read ? and how is the name of the file generated ? thanks, Stef
[web2py] sorry for this stupid / simple question ...
hello, I got a simple web2py site almost running, and I'm trying to put it onto a server right now, ( I want to show it tomorrow to some people) but I'm stocked on a question with a probably very simple answer: I've an intro page with a login button at the top, this page is generated by the controller default.py : index After a succesfull log in, I want to redirect to the content of the site, which is a function with parameters ( service ) @service.run def Set_Page ( Book, Chapter, Paragraph ): How can I redirect to the service Set_Page after a succesfull login ? In a somewhat simpeler form, I tried this (which doesn't work): def index(): if request.vars.visitor_name : redirect ( URL ( 'first') ) response.flash = T('Welcome to My First Page') return dict(message=T('Hello World')) def first(): return dict ( message= 'AAP' ) thanks, Stef Mientki
Re: [web2py] Re: sorry for this stupid / simple question ...
thanks, and maybe I'm doing it totally wrong On 28-11-2010 21:33, mdipierro wrote: If you have @service.run def Set_Page ( Book, Chapter, Paragraph ): return 'check' def call(): return service() you can redirect to this with redirect(URL('call',args=('run','Set_Pgae',book,chapter,paragraph))) But I do not see why you would every redirect a user to a service. A service is not designed to return html pages. But from the book I understood that if you want functions ( controllers) with parameters, you have to use services. Am I wrong ? The application looks like the web2py book application, but differs in a number of ways, - it's larger on the top side, i.e. it consists of a number of books (up to 10), - it's divided into more detail, not a whole chapter is shown, but just one paragraph - pages can contains forms, where the user must give answers - there should be a communication channel beside the book ( not realized yet) The current example, although not completely filled with real information, contains 6 books, each with about 20 chapters, each chapter has between 5 and 25 paragraphs. The controls on page ( mostly jquery menus), and the links embedded in the content, determine which is the next page to shown control. So each of these controls or links, determine book, chapter, paragraph, and they all go to a relative simple function, that extracts the pages from a database (at the moment the texts (and some layout information) are read from a python file, where the texts are placed in a nested list structure) and shows the pages in an uniform way. What's the better way to solve this ? (btw is the web2py book application already available ?, couldn't wait ;-) ) thanks again, Stef On Nov 28, 1:51 pm, Stef Mientki stef.mien...@gmail.com wrote: hello, I got a simple web2py site almost running, and I'm trying to put it onto a server right now, ( I want to show it tomorrow to some people) but I'm stocked on a question with a probably very simple answer: I've an intro page with a login button at the top, this page is generated by the controller default.py : index After a succesfull log in, I want to redirect to the content of the site, which is a function with parameters ( service ) @service.run def Set_Page ( Book, Chapter, Paragraph ): How can I redirect to the service Set_Page after a succesfull login ? In a somewhat simpeler form, I tried this (which doesn't work): def index(): if request.vars.visitor_name : redirect ( URL ( 'first') ) response.flash = T('Welcome to My First Page') return dict(message=T('Hello World')) def first(): return dict ( message= 'AAP' ) thanks, Stef Mientki
Re: [web2py] Re: sorry for this stupid / simple question ...
On 28-11-2010 23:42, mdipierro wrote: On Nov 28, 4:28 pm, Stef Mientki stef.mien...@gmail.com wrote: But from the book I understood that if you want functions ( controllers) with parameters, you have to use services. Not all all: I think you simply want this: def Set_Page() Book, Chapter, Paragraph = request.args[:3] return 'check' services are for function to be called by programs, not by the browsers. Sounds very good, but it's quite late now and I'm very exhausted ( and the site is working now, wow ;-), so I'm going to try that tomorrow. Massimo, thanks very much for your adequate and very fast support !! cheers,Stef
[web2py] can I add a hover text ( like image:alt) to the default menu ?
hello, Can I add a hover text ( like image:alt) to the default menu ? thanks, Stef Mientki
Re: [web2py] Re: can I add a hover text ( like image:alt) to the default menu ?
thanks very much Massimo ! cheers, Stef On 27-11-2010 17:22, mdipierro wrote: a=title b=True or False c=URL(...) d=[] # submenu response.menu=[(a,b,c,d)] instead of a URL, c can be a helper c=A('title',_href=URL(...),_onmouseover='') On Nov 27, 5:22 am, Stef Mientki stef.mien...@gmail.com wrote: hello, Can I add a hover text ( like image:alt) to the default menu ? thanks, Stef Mientki
[web2py] very weird + how do I align text around images ?
hello, probably this sounds very weird, my program worked great, but after changing a few unimportant words it didn't anymore. In a controller, I build a list of html elements and assigned it to Result = [] Result.append ( H2('hello') ) Result.append ( IMG ( _src=../static/images/ + parts[1], _align = 'left' )) Result.append ( H1('world') ) Result.append ( H1('world') ) Result.append ( H1('world') ) response.Content = Result I displayed it with the following lines in the viewer {{=response.Content or 'No Content'}} and it worked perfect, i.e. the 3 lines of text 'world' were neatly placed next to the image on the right. Suddenly it stopped working, and instead of the content, the list objects were displayed, like here (a simpeler list) [gluon.html.H2 object at 0x040DACB0, gluon.html.H1 object at 0x040DA430] So I realized, I needed BEAUTIFY, but I'm absolutely sure I didn't use BEAUTIFY before !! and indeed after using BEAUTIFY, the content was displayed again, but my text around images is totally gone :-( How could my program worked before ??? And of course more important, how can I get my text around the image ? thanks, Stef Mientki
Re: [web2py] Re: very weird + how do I align text around images ?
GREAT !! MANY THANKS Massimo, cheers, Stef On 27-11-2010 23:39, mdipierro wrote: I am not sure this should have ever worked. I think you want: result = DIV() ---
Re: [web2py] Re: can I add a hover text ( like image:alt) to the default menu ?
hello Massimo, couldn't it try it out, unitl I had a JavaScript. So I found this one: http://www.freejavascriptkit.com/free_javascripts/tooltip_hint/dhtml_mouseover_tooltip.html And here is my (relevant) code, if i != 1 : LSB_Menu.append ( [ My_Text, False, URL ( My_URL ) ] ) else : LSB_Menu.append ( [ '', False, A ( My_Text, _href=URL(My_URL ), _onmouseover = ddrivetip( %s,'blue', 300)%( My_Tooltip ), _onmouseout = hideddrivetip() )]) The tooltip works good, but my menu lookss a little weird. As you can see I only used the helper function on the second menu item. Any idea what's going wrong ? thanks, Stef On 27-11-2010 17:22, mdipierro wrote: a=title b=True or False c=URL(...) d=[] # submenu response.menu=[(a,b,c,d)] instead of a URL, c can be a helper c=A('title',_href=URL(...),_onmouseover='') On Nov 27, 5:22 am, Stef Mientki stef.mien...@gmail.com wrote: hello, Can I add a hover text ( like image:alt) to the default menu ? thanks, Stef Mientki inline: moz-screenshot-10.png
[web2py] where to place sizes (and other properties) ?
hello, I just downloaded one of the layouts, and I stumbled about the huge amounts of size / color definitions. I realize that this is not a typical web2py question, but with web2py and it's layout inheritance the problem becomes even bigger. I wonder what's the best place to organize size (and other properties) of objects. You can define size directly in pure html, where to place them in generic.html / layout.html / other.html ? You can place them in a style tag in html, is that a good choice ? You can place them in css, which can be heavily nested. What value of nesting is acceptable ? Opening the page in Mozilla with firebug, reveals that some components have 10 or more nested definitions of sizes / colors etc. (of which a lot are invalid) I wonder how anyone can maintain such a complex hierarchy. Is there a way (other than firebug) to show this hierarchy ? thanks, Stef Mientki
[web2py] is there a insert or replace for the DAL
hello, I wonder if there is a insert or replace or another mechanism, when insert fails ? thanks, Stef Mientki
Re: [web2py] unicode problem in DAL
On 05-11-2010 23:26, Tomeu Roig wrote: Hi, before to make the insert, you need change the string ascii to utf8, Newvalue=value.encode(utf-8) first of all a small type, quotes around utf-8 needed. Newvalue=value.encode( ' utf-8' ) But then it still doesn't work in my situation. I think the problem is a bit more complex, sorry for the long story. Normally I always use unicode strings in all my code, so there should never be a problem ;-) Using the DAL introduces a basic problem, suppose I've a dictionair My_Dict that I want to insert in a DAL table DB.Table.insert ( **My_Dict ) This is impossible, because the unpacking ** doesn't allow unicode keys. In gluon.sql this way of unpacking is done frequently. the next problem is that (because I generate my fieldnames by code), the filednames and tablenames becomes unicode: Fields.append ( eval ( str ( FLine ) ) ) print 'LLVV', FLine, Fields[-1].name, type (Fields[-1].name) resulting in UNICODE !! LLVV Field ( 'Verzekering_ID','integer') Verzekering_ID type 'unicode' the third problem is that in the Table._insert method sql_f = ', '.join(fs) sql_v = ', '.join(vs) sql_t = self._tablename print '==jdhsadjs==',type(sql_t), type(sql_f), type(sql_v) return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v) resulting in invalid combinations of unicode and strings ==jdhsadjs== type 'unicode' type 'unicode' type 'str' What really solves the problem is to convert sql_t and sql_f in Table._insert into strings sql_f = ', '.join(fs) sql_v = ', '.join(vs) sql_t = self._tablename sql_t = sql_t.encode('utf-8') sql_f = sql_f.encode('utf-8') return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v) I've the feeling that this is not a good solution in the first place. Secondly, there probably are more of this code parts in gluon.sql. Any suggestions ? thanks, Stef El 05/11/2010 12:18, Stef Mientki stef.mien...@gmail.com mailto:stef.mien...@gmail.com escribió: I'm trying to insert a record with a filed value uëLocatie and I get an error in sql.Table._insert at the last line: return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v) here the traceback File D:\Data_Python_25\support\Web2Py_DAL_support.py, line 250, in DAL_Table Description = Value[3][:-1]) File P:\Web2PY\web2py_src\web2py\gluon\sql.py, line 2035, in insert query = self._insert(**fields) File P:\Web2PY\web2py_src\web2py\gluon\sql.py, line 2028, in _insert return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 35: ordinal not in range(128) I don't understand the problem and know what I'm doing wrong Wwith print statements I tried to narrow the problem, and in : def sql_represent(obj, fieldtype, dbname, db_codec='UTF-8'): there's is this part if isinstance(obj, unicode): print '', type(obj),obj if len(obj)0 : print ord(obj[0]) obj = obj.encode(db_codec) print '', type(obj) if len(obj)0 : print ord(obj[0]) which seems to convert the unicode to a string with byte values larger than 128. Am I doing something wrong, or is this a bug ? And of course far more interesting, how do I solve this problem ? thanks, Stef Mientki
Re: [web2py] Re: is there a insert or replace for the DAL
thanks Massimo, works great ! cheers, Stef On 09-11-2010 20:12, mdipierro wrote: No but you can do db(condition).update(**d) or db.table.insert(**d) On Nov 9, 1:00 pm, Stef Mientki stef.mien...@gmail.com wrote: hello, I wonder if there is a insert or replace or another mechanism, when insert fails ? thanks, Stef Mientki
Re: [web2py] html editor app/plugin/code for the appadmin
On 09-11-2010 00:44, Eduardo wrote: The web2py admin app comes with a nice code editor for use in the browser. I wonder if anyone knows of an HTML app/code I could add to my appadmin. In my personal website app, I am adding articles to the db as HTML, but I also would like to be able to edit what I've already inserted through the browser. Well, if it's not asking too much, being able to edit the entry on my favorite text editor would be an excellent alternative! What strategy do you people recommend in case there are no such options? Thanks, Eduardo I'm not sure if this very useful, but I'm doing some experiments trying to embed QtWebKit in wxPython, and was amazed how easy you could make an wysiwyg editor with webkit. I wonder if there are browsers who have implemented the editor feature. At least it also seems possible with html5: http://arstechnica.com/open-source/guides/2009/07/how-to-build-a-desktop-wysiwyg-editor-with-webkit-and-html-5.ars cheers, Stef
[web2py] unicode problem in DAL
I'm trying to insert a record with a filed value uëLocatie and I get an error in sql.Table._insert at the last line: return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v) here the traceback File D:\Data_Python_25\support\Web2Py_DAL_support.py, line 250, in DAL_Table Description = Value[3][:-1]) File P:\Web2PY\web2py_src\web2py\gluon\sql.py, line 2035, in insert query = self._insert(**fields) File P:\Web2PY\web2py_src\web2py\gluon\sql.py, line 2028, in _insert return 'INSERT INTO %s(%s) VALUES (%s);' % (sql_t, sql_f, sql_v) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 35: ordinal not in range(128) I don't understand the problem and know what I'm doing wrong Wwith print statements I tried to narrow the problem, and in : def sql_represent(obj, fieldtype, dbname, db_codec='UTF-8'): there's is this part if isinstance(obj, unicode): print '', type(obj),obj if len(obj)0 : print ord(obj[0]) obj = obj.encode(db_codec) print '', type(obj) if len(obj)0 : print ord(obj[0]) which seems to convert the unicode to a string with byte values larger than 128. Am I doing something wrong, or is this a bug ? And of course far more interesting, how do I solve this problem ? thanks, Stef Mientki