[web2py] Re: framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Jose C
> Nope. A leaking web2py will have worried a lot of users if shows up in a 
simple app like this (i.e. if it leaks while processing this app, the 
"bases" of the web2py code are leaking somewhere and everyone would have 
noticed that)

You'd expect so... although not sure how many users have apps handling 
1,000 concurrent connections.  (As an aside it would be nice if any power 
users out there could give some feedback on their experience).   However 
the author of the article states on comp.lang.python as well as in his blog 
in response to Massimo that "... during test I have noticed huge memory 
leak."

You mentioned you'd hacked on one of the files.  Can you confirm that when 
you checked the memory usage it was the standard version of web2py 2.0.9, 
or was it using your hacked version of the code? I'd imagine the test would 
need to be run with sessions on and web2py as out-of-the-box if we're to 
have a chance of reproducing the memory leak.

Thanks.

-- 





[web2py] Return Compile error

2012-09-26 Thread Hassan Alnatour
Dear ALL,

I am trying to return a div that has a select with option from table , but 
am getting an error , and i still cant figure it out , any help please ?

return DIV(
LABEL('%s: ' % table[column].label,_for=column),
DIV(SELECT(
  #OPTION('None',_value=''),
for i in db().select(db.News.ALL):
  OPTION('%s'%(i.id),_value='%s'%(i.EnglishTitle)),
 
_name=column,_id=column),_class='input'),
  _class='clearfix')


Best Regards,

-- 





Re: [web2py] Return Compile error

2012-09-26 Thread hasan alnator
return '''

%s: 


{{for i in db().select(db.News.ALL):}}
{{i.EnglishTitle}}
{{pass}}




''' % (column,table[column].label,)







On Wed, Sep 26, 2012 at 11:30 AM, Hassan Alnatour <
halna...@gardeniatelco.com> wrote:

> Dear ALL,
>
> I am trying to return a div that has a select with option from table , but
> am getting an error , and i still cant figure it out , any help please ?
>
> return DIV(
> LABEL('%s: ' % table[column].label,_for=column),
> DIV(SELECT(
>   #OPTION('None',_value=''),
> for i in db().select(db.News.ALL):
>   OPTION('%s'%(i.id),_value='%s'%(i.EnglishTitle)),
>
> _name=column,_id=column),_class='input'),
>   _class='clearfix')
>
>
> Best Regards,
>
> --
>
>
>
>

-- 





[web2py] Re: routes_onerror

2012-09-26 Thread lyn2py
Opened an issue here: 
Issue 1034 

On Wednesday, September 26, 2012 11:16:16 AM UTC+8, Massimo Di Pierro wrote:
>
> Please open a ticket about this. 
>
> On Tuesday, 25 September 2012 21:36:57 UTC-5, lyn2py wrote:
>>
>> Can't use it in an app-specicfic routes. It works once I moved it to the 
>> main routes.py
>>
>>
>> On Sunday, September 23, 2012 9:35:11 AM UTC+8, lyn2py wrote:
>>>
>>> I have this code in the *app-specific* routes.py
>>>
>>> routes_onerror = [
>>>   ('*/*', '/myapp/static/error.html')
>>> ]
>>>
>>> I reload routes, but it still prints 
>>> invalid function (nothing/here)
>>>
>>> I am using:
>>> Version 2.0.9 (2012-09-17 21:37:10) stable
>>>
>>> May I know what I am doing wrong?
>>>
>>> Thank you.
>>>
>>

-- 





Re: [web2py] Re: Cannot login via web2py mobile admin (V 2.0.6)

2012-09-26 Thread Johann Spies
On 25 September 2012 16:37, Oli  wrote:

> I also have the same Problem with Samsung SII.
>
>
And with the Motorola Razr XT910.

I also cannot login into a normal app using the cellphone when using the
navbar.  However when going to a function that requires authentication, the
login-screen appears and from there I can login.

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] Re: Sqlite adapter date and datetime type validation

2012-09-26 Thread Alan Etkin
> El martes, 25 de septiembre de 2012 15:09:07 UTC-3, Massimo Di Pierro 
escribió:The driver should. but it does not. I guess we can > catch at the 
adapter level.

Then, I guess this not a web2py issue but a feature not implemented in the 
db engine specific interface. For solving that, there would be need to 
filter every datetime, date or time value and check if it has a compatible 
format for each sql adapter (Sqlite, MySQL, ...). Anyway, this kind of 
errors can be catched by appropiate use of validators.

-- 





Re: [web2py] How to get geo location?

2012-09-26 Thread Manuele Pesenti

Il 26/09/2012 04:38, weheh ha scritto:
I want to play around with geo location stuff. Is there a simple way 
to get the location of the user's browser when they access a 
controller/action within web2py? I'm not trying to convert an address 
to a geo location. I'm looking for lat/long info from the user's 
browser at the time they make a request. 

something like this?
http://www.browsergeolocation.com/

M.

--





Re: [web2py] Re: Problems with a validation procedure ? - a Canadian postal code !

2012-09-26 Thread Le Don X
don't be sorry for jumping in  it is appreciated ! .. and refreshing to
noticed that there are canadian folks like me on here !

to resume ... from all the responses received - the best canadian postal
code validation is actually the one submitted by Adnan :

this one :  ^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$

thank you ! ...

with just one addition : the postal code entered will need to be
capitalised before validation to avoid any issues !

This thread could help others with the same concern !

-- 





[web2py] Apache Error Please Help

2012-09-26 Thread Hassan Alnatour
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
Target WSGI script 'C:/web2py/wsgihandler.py' cannot be loaded as Python 
module.
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
Exception occurred processing WSGI script 'C:/web2py/wsgihandler.py'.
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] Traceback (most 
recent call last):
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
"C:/web2py/wsgihandler.py", line 33, in 
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] import gluon.main
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
"C:\\web2py\\gluon\\main.py", line 124, in 
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] load()
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
"C:\\web2py\\gluon\\rewrite.py", line 367, in load
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] 
load_routers(all_apps)
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
"C:\\web2py\\gluon\\rewrite.py", line 511, in load_routers
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] raise 
SyntaxError, "unknown app '%s' in domains" % app
[Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] SyntaxError: unknown 
app 'ward' in domains
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
Target WSGI script 'C:/web2py/wsgihandler.py' cannot be loaded as Python 
module.
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
Exception occurred processing WSGI script 'C:/web2py/wsgihandler.py'.
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] Traceback (most 
recent call last):
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
"C:/web2py/wsgihandler.py", line 33, in 
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] import gluon.main
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
"C:\\web2py\\gluon\\custom_import.py", line 300, in __call__
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] fromlist, level)
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
"C:\\web2py\\gluon\\custom_import.py", line 80, in __call__
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] level)
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
"C:\\web2py\\gluon\\main.py", line 124, in 
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] load()
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
"C:\\web2py\\gluon\\rewrite.py", line 367, in load
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] 
load_routers(all_apps)
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
"C:\\web2py\\gluon\\rewrite.py", line 511, in load_routers
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] raise 
SyntaxError, "unknown app '%s' in domains" % app
[Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] SyntaxError: unknown 
app 'ward' in domains




what to do ?

-- 





[web2py] Re: No module named webclient

2012-09-26 Thread weheh
I don't have login permissions on the doc any longer but I could clean up a 
few typos if you'll give access again.

On Wednesday, September 26, 2012 11:16:58 AM UTC+8, Massimo Di Pierro wrote:
>
> yes. requires 2.0.x
>
> On Tuesday, 25 September 2012 21:45:04 UTC-5, weheh wrote:
>>
>> Using web2py 1.99.4, as per doc on functional testing, I'm doing:
>>
>> from gluon.contrib.webclient import WebClient
>>
>> Is this only available in a later version of web2py? Because I'm getting a 
>> ticket:
>>
>>   File "N:\web2py\gluon\custom_import.py", line 293, in __call__
>>
>> fromlist, level)
>>   File "N:\web2py\gluon\custom_import.py", line 132, in __call__
>> raise e  # Don't hide something that went wrong
>> ImportError: No module named webclient
>>
>>

-- 





[web2py] Re: Apache Error Please Help

2012-09-26 Thread Paolo Caruccio
apache version? mod_wsgi version?


Il giorno mercoledì 26 settembre 2012 13:31:23 UTC+2, Hassan Alnatour ha 
scritto:
>
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
> Target WSGI script 'C:/web2py/wsgihandler.py' cannot be loaded as Python 
> module.
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
> Exception occurred processing WSGI script 'C:/web2py/wsgihandler.py'.
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] Traceback (most 
> recent call last):
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
> "C:/web2py/wsgihandler.py", line 33, in 
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] import gluon.main
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\main.py", line 124, in 
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] load()
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\rewrite.py", line 367, in load
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] 
> load_routers(all_apps)
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\rewrite.py", line 511, in load_routers
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] raise 
> SyntaxError, "unknown app '%s' in domains" % app
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] SyntaxError: unknown 
> app 'ward' in domains
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
> Target WSGI script 'C:/web2py/wsgihandler.py' cannot be loaded as Python 
> module.
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
> Exception occurred processing WSGI script 'C:/web2py/wsgihandler.py'.
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] Traceback (most 
> recent call last):
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:/web2py/wsgihandler.py", line 33, in 
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] import gluon.main
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\custom_import.py", line 300, in __call__
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] fromlist, level)
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\custom_import.py", line 80, in __call__
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] level)
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\main.py", line 124, in 
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] load()
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\rewrite.py", line 367, in load
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] 
> load_routers(all_apps)
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\rewrite.py", line 511, in load_routers
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] raise 
> SyntaxError, "unknown app '%s' in domains" % app
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] SyntaxError: unknown 
> app 'ward' in domains
>
>
>
>
> what to do ?
>

-- 





[web2py] Book Web2py Portuguese not work

2012-09-26 Thread Ovidio Marinho
 menu book of web2py web2py Portuguese menu is that this is not working.

http://web2py.com/books/default/chapter/37


   Ovidio Marinho Falcao Neto
Web Developer
 ovidio...@gmail.com
  ovidiomari...@itjp.net.br
 ITJP - itjp.net.br
   83   8826 9088 - Oi
   83   9334 0266 - Claro
Brasil

-- 





Re: [web2py] Book Web2py Portuguese not work

2012-09-26 Thread Bruno Rocha
Portuguese translation is a work in progress, we are doing the work on
github.com/rochacbruno

Bruno Rocha
http://rochacbruno.com.br
mobile
 Em 26/09/2012 09:27, "Ovidio Marinho"  escreveu:

>
>  menu book of web2py web2py Portuguese menu is that this is not
> working.
>
> http://web2py.com/books/default/chapter/37
>
>
>Ovidio Marinho Falcao Neto
> Web Developer
>  ovidio...@gmail.com
>   ovidiomari...@itjp.net.br
>  ITJP - itjp.net.br
>83   8826 9088 - Oi
>83   9334 0266 - Claro
> Brasil
>
>
>  --
>
>
>
>

-- 





[web2py] Re: framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Niphlod
tests are done with a simple "hello, world" app. Cases 1-3 differs from 
having session enabled or not. Case 5 is done with a "hacked" gluon/main.py 
version. So case 1 should "reproduce" the same behaviour the author 
described (standard web2py, session enabled). 
None of them showed any memory leak. A memory leak shows up generally 
growing with number of requests, not on concurrent accesses, however with 
1000 concurrent and 2 rounds of 2 millions of requests (that is 4 millions 
in total) no "evident" memory compsumtion showed up. 

Il giorno mercoledì 26 settembre 2012 09:25:54 UTC+2, Jose C ha scritto:
>
> > Nope. A leaking web2py will have worried a lot of users if shows up in a 
> simple app like this (i.e. if it leaks while processing this app, the 
> "bases" of the web2py code are leaking somewhere and everyone would have 
> noticed that)
>
> You'd expect so... although not sure how many users have apps handling 
> 1,000 concurrent connections.  (As an aside it would be nice if any power 
> users out there could give some feedback on their experience).   However 
> the author of the article states on comp.lang.python as well as in his blog 
> in response to Massimo that "... during test I have noticed huge memory 
> leak."
>
> You mentioned you'd hacked on one of the files.  Can you confirm that when 
> you checked the memory usage it was the standard version of web2py 2.0.9, 
> or was it using your hacked version of the code? I'd imagine the test would 
> need to be run with sessions on and web2py as out-of-the-box if we're to 
> have a chance of reproducing the memory leak.
>
> Thanks.
>

-- 





[web2py] Re: Return Compile error

2012-09-26 Thread Niphlod
you can't cycle db results within a tag as SELECT()

Il giorno mercoledì 26 settembre 2012 10:30:53 UTC+2, Hassan Alnatour ha 
scritto:
>
> Dear ALL,
>
> I am trying to return a div that has a select with option from table , but 
> am getting an error , and i still cant figure it out , any help please ?
>
> return DIV(
> LABEL('%s: ' % table[column].label,_for=column),
> DIV(SELECT(
>   #OPTION('None',_value=''),
> for i in db().select(db.News.ALL):
>   OPTION('%s'%(i.id),_value='%s'%(i.EnglishTitle)),
>  
> _name=column,_id=column),_class='input'),
>   _class='clearfix')
>
>
> Best Regards,
>

-- 





[web2py] How to reload a div containing a component

2012-09-26 Thread Johann Spies
I have this view:

{{extend 'layout.html'}}


{{=opskrif}}
{{=vorm}}


{{=skakel}}



 {{=LOAD('authors', 'list_chosen_authors.load', ajax=True)}}
 




{{=LOAD('authors', 'publikasievelde.load', 
ajax=True)}}

{{=LOAD('default', 'personeel.load', ajax=
True)}}
{{=LOAD('default', 'nrfdata.load', ajax=True)}}

 
 $(document).ready(function() {
$('#Button1').click(function() {
$('#herlaai_pubvelde').load('/init/authors/publikasievelde.load');
$('#herlaai_personeel').load('init/default/personeel.load');
$("#herlaai_nrf").load('init/default/nrfdata.load');

return false;
});
});




The content of the last three component depends on the content of the first 
component. All of them make use of session variables.

I want the bottom three components to reload when #Button1 is clicked.

In the past I have used location.reload but that reloads the whole page.

I have tried the above code after reading
 
http://www.sitepoint.com/forums/showthread.php?633180-Refresh-DIV-Content-Without-Reloading-Page
 
but it is not doing the job for me.

Regards
Johann

-- 





[web2py] Re: web2py 2.0.8 Firebird driver fdb error

2012-09-26 Thread Adrian Marius Popa


On Wednesday, September 12, 2012 3:43:15 PM UTC+3, Massimo Di Pierro wrote:
>
> Please open a ticket about this.
>
> On Wednesday, 12 September 2012 07:06:33 UTC-5, Alexei Vinidiktov wrote:
>>
>> I'm trying to use the new fdb driver for Firebird with web2py 2.0.8 but 
>> I'm getting this error when I load a page:
>>
>> (Transaction object is not active) 
>>
>> TRACEBACK
>>  
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>>
>> Traceback (most recent call last):
>>   File "C:\Users\alexei\Dev\web2py\vocabilis.net-2.0.8\gluon\main.py", line 
>> 538, in wsgibase
>>
>>
>> BaseAdapter.close_all_instances('commit')
>>
>>
>>   File "C:\Users\alexei\Dev\web2py\vocabilis.net-2.0.8\gluon\dal.py", line 
>> 510, in close_all_instances
>>
>>
>> getattr(instance, action)()
>>
>>
>>   File "C:\Users\alexei\Dev\web2py\vocabilis.net-2.0.8\gluon\dal.py", line 
>> 1618, in commit
>>
>>
>> return self.connection.commit()
>>
>>
>>   File "C:\Python27\lib\site-packages\fdb\fbcore.py", line 1084, in commit
>>
>>
>> self._main_transaction.commit(retaining)
>>
>>
>>   File "C:\Python27\lib\site-packages\fdb\fbcore.py", line 2385, in commit
>>
>>
>> self.__check_active()
>>
>>
>>   File "C:\Python27\lib\site-packages\fdb\fbcore.py", line 2316, in 
>> __check_active
>>
>>
>> raise ProgrammingError("Transaction object is not active")
>>
>> ProgrammingError: Transaction object is not active
>>
>>  Code listing
>>
>>
>>
>> 2311.
>> 2312.
>>
>>
>> 2313.
>> 2314.
>> 2315.
>> 2316.
>>
>> 2317.
>> 2318.
>> 2319.
>> 2320.
>>
>> self._cursors.remove(cursor_ref)
>>
>>
>> def __get_closed(self):
>>
>>
>> return self._tr_handle == None
>>
>>
>> def __check_active(self):
>>
>>
>> if self._tr_handle == None:
>>
>> raise ProgrammingError("Transaction object is not active")
>>
>>
>> def __con_in_list(self,connection):
>>
>>
>> for con in self._connections:
>>
>>
>> if con() == connection:
>>
>>
>> return True
>>
>>
>> I have Python 2.7.2 and fdb 0.8.5 on Windows 8 RC.
>>
>
It might be a fbd driver issue wait for fdb 0.8.6 version ~ next week and 
test it after that 
http://tech.groups.yahoo.com/group/firebird-python/message/573
 

>
>> -- 
>> Alexei Vinidiktov
>>  
>

-- 





[web2py] Re: How to reload a div containing a component

2012-09-26 Thread Anthony

>
> {{=LOAD('authors', 'publikasievelde.load', 
> ajax=True)}}
> {{=LOAD('default', 'personeel.load', ajax
> =True)}}
> {{=LOAD('default', 'nrfdata.load', ajax=True
> )}}
>
>  
>  $(document).ready(function() {
> $('#Button1').click(function() {
> $('#herlaai_pubvelde').load('/init/authors/publikasievelde.load');
> $('#herlaai_personeel').load('init/default/personeel.load');
> $("#herlaai_nrf").load('init/default/nrfdata.load');
>
> return false;
> });
> });
> 
>

First, your divs are identified via classes, but your jQuery selectors are 
for id's. You probably want to change the classes to id's:

{{=LOAD('authors', 'publikasievelde.load', 
ajax=True)}}

Another option, though, is to explicitly name the LOAD divs (via the 
"target" argument), and then call web2py_component() directly to refresh 
the components:

{{=LOAD('authors', 'publikasievelde.load', ajax=True, target=
'herlaai_pubvelde')}}
{{=LOAD('default', 'personeel.load', ajax=True, target='herlaai_personeel'
)}}
{{=LOAD('default', 'nrfdata.load', ajax=True, target='herlaai_nrf')}}


  $(document).ready(function() {
$('#Button1').click(function() {
  web2py_component('{{=URL('authors', 'publikasievelde.load')}}', target
='herlaai_pubvelde')
  web2py_component('{{=URL('default', 'personeel.load')}}', target=
'herlaai_personeel')
  web2py_component('{{=URL('default', 'nrfdata.load')}}', target=
'herlaai_nrf')
  return false;
});
  });


Anthony

-- 





Re: [web2py] Re: How to reload a div containing a component

2012-09-26 Thread Johann Spies
On 26 September 2012 15:37, Anthony  wrote:

First, your divs are identified via classes, but your jQuery selectors are
> for id's. You probably want to change the classes to id's:
>
> {{=LOAD('authors', 'publikasievelde.load',
> ajax=True)}}
>

Thanks Anthony.  It was stupid of me to confuse classes and id's.

Regards
Johann

-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 





[web2py] Re: Apache Error Please Help

2012-09-26 Thread Massimo Di Pierro
I think you have an invalid router configuration. Can you show it to us? It 
mentions "ward" but web2py says you do not have a "ward" app. It may be a 
typo in routes.py or a PATH issue.

On Wednesday, 26 September 2012 06:31:23 UTC-5, Hassan Alnatour wrote:
>
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
> Target WSGI script 'C:/web2py/wsgihandler.py' cannot be loaded as Python 
> module.
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
> Exception occurred processing WSGI script 'C:/web2py/wsgihandler.py'.
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] Traceback (most 
> recent call last):
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
> "C:/web2py/wsgihandler.py", line 33, in 
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] import gluon.main
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\main.py", line 124, in 
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] load()
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\rewrite.py", line 367, in load
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] 
> load_routers(all_apps)
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\rewrite.py", line 511, in load_routers
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] raise 
> SyntaxError, "unknown app '%s' in domains" % app
> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] SyntaxError: unknown 
> app 'ward' in domains
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
> Target WSGI script 'C:/web2py/wsgihandler.py' cannot be loaded as Python 
> module.
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] mod_wsgi (pid=3648): 
> Exception occurred processing WSGI script 'C:/web2py/wsgihandler.py'.
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] Traceback (most 
> recent call last):
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:/web2py/wsgihandler.py", line 33, in 
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] import gluon.main
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\custom_import.py", line 300, in __call__
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] fromlist, level)
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\custom_import.py", line 80, in __call__
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] level)
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\main.py", line 124, in 
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] load()
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\rewrite.py", line 367, in load
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] 
> load_routers(all_apps)
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File 
> "C:\\web2py\\gluon\\rewrite.py", line 511, in load_routers
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] raise 
> SyntaxError, "unknown app '%s' in domains" % app
> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] SyntaxError: unknown 
> app 'ward' in domains
>
>
>
>
> what to do ?
>

-- 





Re: [web2py] Re: How to reload a div containing a component

2012-09-26 Thread Anthony
On Wednesday, September 26, 2012 9:50:59 AM UTC-4, Johann Spies wrote:
>
> On 26 September 2012 15:37, Anthony >wrote:
>
> First, your divs are identified via classes, but your jQuery selectors are 
>> for id's. You probably want to change the classes to id's:
>>
>> {{=LOAD('authors', 'publikasievelde.load', 
>> ajax=True)}}
>>
>
> Thanks Anthony.  It was stupid of me to confuse classes and id's.
>

No problem. Anyway, you might want to consider the second option, as 
web2py_component() handles some setup specific to web2py components, such 
as trapping links and forms, displaying flash messages, etc. 

Anthony

-- 





[web2py] Re: framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Massimo Di Pierro
First of all kudos to Andriy,

He created an excellent testing code, he was very responsive, and he really 
took the time to understand some of the web2py code. Moreover he is the 
author of the excellent wheezy.web framework.

He just emailed me that he has rebuilt his testing environment and has 
updated the benchmarks:

http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html

The memory leak is gone! I am not sure about the cause but I suspect he had 
an older web2py version installed via pip that was creating problems.

We still score last but the numbers are closer to the numbers that Niphlod 
got. Anyway, this is not a concern to me because although this is a simple 
"hello world" test, web2py does more than the others (session, T, url and 
ip validation, etc.) and it is expected to be slower. The difference, as 
Niphlod sasys, washes away in real life applications. Yet we can probably 
do better with some simple tweaks and we should pursue that. Niphlod 
numbers still look better by almost a factor 2 so something else is going 
on too.

Andriy also posted template benchmarks:
http://mindref.blogspot.com/2012/07/python-fastest-template.html

So if we compare web2py with Django you see that web2py is slower on "hello 
world" but has faster templates. As you can see the time to render one 
template page dominates the time to serve "hello world". Of course 
wheezy.web smokes everybody else on both tests and that is something we 
should try understand. We should also try port gluino to wheezy.web.

Massimo

-- 





Re: [web2py] Re: Apache Error Please Help

2012-09-26 Thread hasan alnator
Dear Massimo ,

the app ward wasn't there , so that was making an error . thank you i fixed
everything now ..


Regards,



On Wed, Sep 26, 2012 at 4:53 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> I think you have an invalid router configuration. Can you show it to us?
> It mentions "ward" but web2py says you do not have a "ward" app. It may be
> a typo in routes.py or a PATH issue.
>
>
> On Wednesday, 26 September 2012 06:31:23 UTC-5, Hassan Alnatour wrote:
>>
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] mod_wsgi
>> (pid=3648): Target WSGI script 'C:/web2py/wsgihandler.py' cannot be loaded
>> as Python module.
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] mod_wsgi
>> (pid=3648): Exception occurred processing WSGI script
>> 'C:/web2py/wsgihandler.py'.
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] Traceback (most
>> recent call last):
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File
>> "C:/web2py/wsgihandler.py", line 33, in 
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] import
>> gluon.main
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File
>> "C:\\web2py\\gluon\\main.py", line 124, in 
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] load()
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File
>> "C:\\web2py\\gluon\\rewrite.**py", line 367, in load
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]
>> load_routers(all_apps)
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1]   File
>> "C:\\web2py\\gluon\\rewrite.**py", line 511, in load_routers
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] raise
>> SyntaxError, "unknown app '%s' in domains" % app
>> [Wed Sep 26 06:29:38 2012] [error] [client 127.0.0.1] SyntaxError:
>> unknown app 'ward' in domains
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] mod_wsgi
>> (pid=3648): Target WSGI script 'C:/web2py/wsgihandler.py' cannot be loaded
>> as Python module.
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] mod_wsgi
>> (pid=3648): Exception occurred processing WSGI script
>> 'C:/web2py/wsgihandler.py'.
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] Traceback (most
>> recent call last):
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File
>> "C:/web2py/wsgihandler.py", line 33, in 
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] import
>> gluon.main
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File
>> "C:\\web2py\\gluon\\custom_**import.py", line 300, in __call__
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] fromlist, level)
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File
>> "C:\\web2py\\gluon\\custom_**import.py", line 80, in __call__
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] level)
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File
>> "C:\\web2py\\gluon\\main.py", line 124, in 
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] load()
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File
>> "C:\\web2py\\gluon\\rewrite.**py", line 367, in load
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]
>> load_routers(all_apps)
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1]   File
>> "C:\\web2py\\gluon\\rewrite.**py", line 511, in load_routers
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] raise
>> SyntaxError, "unknown app '%s' in domains" % app
>> [Wed Sep 26 06:29:40 2012] [error] [client 127.0.0.1] SyntaxError:
>> unknown app 'ward' in domains
>>
>>
>>
>>
>> what to do ?
>>
>  --
>
>
>
>

-- 





[web2py] Re: Starting a simple project from scratch

2012-09-26 Thread Vixus
Hi, thanks for your reply!

What about the rest of the files? Can I make my own layout.html and 
default.py from scratch? I was struggling to find all the details on the 
auth object in the documentation and also what the gluon module is and how 
to use it. default.py doesn't seem to have any imports or anything, are 
these put in automatically by web2py?

vix

On Monday, September 24, 2012 10:24:45 PM UTC+1, Massimo Di Pierro wrote:
>
> Hello Vixus,
>
> If you want to use bootstrap, than it comes with it.
> If not, then deleted everything but web2py.css, jquery.js, and web2py.js 
> for components and grids you need those but they are small and un-intrusive.
>
> massimo
>
>
>
> On Sunday, 23 September 2012 10:05:46 UTC-5, Vixus wrote:
>>
>> So I'm reasonably experienced with python and grew up web developing with 
>> PHP. I wanted to move all my web development over to python and web2py 
>> seemed like the ideal way to get started. There's one thing I really don't 
>> like however and is giving me a lot of trouble actually learning the 
>> framework and that's all the default cruft that gets put in place when I 
>> start a new application. Also a lot of things are hidden behind the IDE 
>> (where is default.py getting all its module info from?) -- there doesn't 
>> seem to be any technical explanation of what's  going on behind the scenes.
>>
>> For instance, yes, it's very nice that a user system is put in place for 
>> me but all the other stuff like the bootstrap UI elements just gets in the 
>> way of me developing my website because I spend more time sifting through 
>> the huge CSS files trying to fix things. Basically, I'm used to building my 
>> sites from the very ground up, because then I know how everything fits 
>> together and works. With web2py I've found this really confusing. Yes, I'll 
>> read through the entire book but I'd find it a lot easier to get the 
>> examples if I had a really blank project to work with. 
>>
>> So what does everyone think? Do I just delete all the files and start 
>> from scratch (I'm scared something will break or I won't have the right 
>> initial setup) or continue trying to muddle through with the prefab setup?
>>
>> web2py feels amazingly powerful, and I want to add it to my arsenal, so 
>> any help is appreciated. Thanks!
>>
>

-- 





[web2py] Setting session vars without a form submit

2012-09-26 Thread Maya Iyengar
Hi,

I'm trying to set some defaults for the user based on their user id, which 
needs to be set at the beginning of each session. The user may or may not 
need to login (based on whether or not they've selected "Remember me for 30 
days." So where is the best place for me to put the logic that sets the 
session variables? I will need access to the user's ID in order to 
determine what tables they have permissions to.

Thanks so much,
Maya

-- 





[web2py] Re: Setting session vars without a form submit

2012-09-26 Thread Massimo Di Pierro
if auth.user and not session.defaults: session.defaults = {}

then use session.defaults as a dict

On Tuesday, 25 September 2012 18:19:11 UTC-5, Maya Iyengar wrote:
>
> Hi,
>
> I'm trying to set some defaults for the user based on their user id, which 
> needs to be set at the beginning of each session. The user may or may not 
> need to login (based on whether or not they've selected "Remember me for 30 
> days." So where is the best place for me to put the logic that sets the 
> session variables? I will need access to the user's ID in order to 
> determine what tables they have permissions to.
>
> Thanks so much,
> Maya
>

-- 





[web2py] Re: Starting a simple project from scratch

2012-09-26 Thread Massimo Di Pierro
You can delete all of web2py files in an app and make your own.

The controllers (in your case default.py) is executed in the same 
environment as the models, therefore it see all the variables defined in 
the models (in web2py that is what models are for: they build the 
environment for the controller).

The only files that you may want to retain are appadmin.py and 
appadmin.html because they implement database administration and 
jquery.js/web2py.js/calendar.js because they implement useful stuff for 
forms and web2py_components.

Massimo



On Tuesday, 25 September 2012 18:47:48 UTC-5, Vixus wrote:
>
> Hi, thanks for your reply!
>
> What about the rest of the files? Can I make my own layout.html and 
> default.py from scratch? I was struggling to find all the details on the 
> auth object in the documentation and also what the gluon module is and how 
> to use it. default.py doesn't seem to have any imports or anything, are 
> these put in automatically by web2py?
>
> vix
>
> On Monday, September 24, 2012 10:24:45 PM UTC+1, Massimo Di Pierro wrote:
>>
>> Hello Vixus,
>>
>> If you want to use bootstrap, than it comes with it.
>> If not, then deleted everything but web2py.css, jquery.js, and web2py.js 
>> for components and grids you need those but they are small and un-intrusive.
>>
>> massimo
>>
>>
>>
>> On Sunday, 23 September 2012 10:05:46 UTC-5, Vixus wrote:
>>>
>>> So I'm reasonably experienced with python and grew up web developing 
>>> with PHP. I wanted to move all my web development over to python and web2py 
>>> seemed like the ideal way to get started. There's one thing I really don't 
>>> like however and is giving me a lot of trouble actually learning the 
>>> framework and that's all the default cruft that gets put in place when I 
>>> start a new application. Also a lot of things are hidden behind the IDE 
>>> (where is default.py getting all its module info from?) -- there doesn't 
>>> seem to be any technical explanation of what's  going on behind the scenes.
>>>
>>> For instance, yes, it's very nice that a user system is put in place for 
>>> me but all the other stuff like the bootstrap UI elements just gets in the 
>>> way of me developing my website because I spend more time sifting through 
>>> the huge CSS files trying to fix things. Basically, I'm used to building my 
>>> sites from the very ground up, because then I know how everything fits 
>>> together and works. With web2py I've found this really confusing. Yes, I'll 
>>> read through the entire book but I'd find it a lot easier to get the 
>>> examples if I had a really blank project to work with. 
>>>
>>> So what does everyone think? Do I just delete all the files and start 
>>> from scratch (I'm scared something will break or I won't have the right 
>>> initial setup) or continue trying to muddle through with the prefab setup?
>>>
>>> web2py feels amazingly powerful, and I want to add it to my arsenal, so 
>>> any help is appreciated. Thanks!
>>>
>>

-- 





Re: [web2py] Re: framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Alec Taylor
On Thu, Sep 27, 2012 at 12:12 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> First of all kudos to Andriy,
>
> He created an excellent testing code, he was very responsive, and he
> really took the time to understand some of the web2py code. Moreover he is
> the author of the excellent wheezy.web framework.
>
> He just emailed me that he has rebuilt his testing environment and has
> updated the benchmarks:
>
> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
>
> The memory leak is gone! I am not sure about the cause but I suspect he
> had an older web2py version installed via pip that was creating problems.
>
> We still score last but the numbers are closer to the numbers that Niphlod
> got. Anyway, this is not a concern to me because although this is a simple
> "hello world" test, web2py does more than the others (session, T, url and
> ip validation, etc.) and it is expected to be slower. The difference, as
> Niphlod sasys, washes away in real life applications. Yet we can probably
> do better with some simple tweaks and we should pursue that. Niphlod
> numbers still look better by almost a factor 2 so something else is going
> on too.
>
> Andriy also posted template benchmarks:
> http://mindref.blogspot.com/2012/07/python-fastest-template.html
>
> So if we compare web2py with Django you see that web2py is slower on
> "hello world" but has faster templates. As you can see the time to render
> one template page dominates the time to serve "hello world". Of course
> wheezy.web smokes everybody else on both tests and that is something we
> should try understand. We should also try port gluino to wheezy.web.
>
> Massimo
>

Thanks Massimo, I saw Andriy posting on comp.lang.python and recommended he
benchmark web2py.

Would be very interested to see if web2py can catchup to the others. I
think that the performance when compared with Flask should be our main goal.

Definitely a port of gluino to wheezy.web would be amazing :)

-- 





[web2py] Version 2.09 wipes source files

2012-09-26 Thread chicks
Updated from 1.99 to 2.09 yesterday.  Everything looked fine until started 
editing via the web GUI.  Every edit overwrites the edited file with 
"undefined" when saved.  Reverting back to 1.99.  Anyone else seeing this 
issue?  Running on Solaris, Python 2.7.

-- 





Re: [web2py] Re: framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Massimo Di Pierro
We should definitively try to understand and improve these results but I am 
not convinced that matching the speed of others on "hello world" benchmarks 
should be a goal. This just says to me that others do very little for 
you beyond the web server. If you turn on sessions and templates in other 
frameworks (except wheezy perhaps) you lose most of the advantage. If one 
really need something so barebone, one should just use wsgi.

Here is an example... one month ago a user with uWSGI+web2py had a problem. 
People with iPad devices accessing the site where having their sessions 
mixed up. They would go to the site and find themselves logged in as other 
users. We tried to understand it and found that he was using a buggy 
version of uWSGI that was caching cookies. This was due to the fact that 
iPad devices has IPv6 addresses that were not properly parsed and appear as 
"unkown". uWSGI was passing to web2py cached session cookies with "unkown" 
client ip.

I order to prevent this we decided not to trust the web server and add a 
client ip validation in web2py. Other frameworks do not validate the client 
ip. Should we forfeit these checks because others do not do them and we 
want to appear faster in the benchmarks? I say no.

Massimo


On Wednesday, September 26, 2012 11:21:41 AM UTC-5, Alec Taylor wrote:
>
> On Thu, Sep 27, 2012 at 12:12 AM, Massimo Di Pierro 
> 
> > wrote:
>
>> First of all kudos to Andriy,
>>
>> He created an excellent testing code, he was very responsive, and he 
>> really took the time to understand some of the web2py code. Moreover he is 
>> the author of the excellent wheezy.web framework.
>>
>> He just emailed me that he has rebuilt his testing environment and has 
>> updated the benchmarks:
>>
>> http://mindref.blogspot.com/2012/09/python-fastest-web-framework.html
>>
>> The memory leak is gone! I am not sure about the cause but I suspect he 
>> had an older web2py version installed via pip that was creating problems.
>>
>> We still score last but the numbers are closer to the numbers that 
>> Niphlod got. Anyway, this is not a concern to me because although this is a 
>> simple "hello world" test, web2py does more than the others (session, T, 
>> url and ip validation, etc.) and it is expected to be slower. The 
>> difference, as Niphlod sasys, washes away in real life applications. Yet we 
>> can probably do better with some simple tweaks and we should pursue 
>> that. Niphlod numbers still look better by almost a factor 2 so something 
>> else is going on too.
>>
>> Andriy also posted template benchmarks:
>> http://mindref.blogspot.com/2012/07/python-fastest-template.html
>>
>> So if we compare web2py with Django you see that web2py is slower on 
>> "hello world" but has faster templates. As you can see the time to render 
>> one template page dominates the time to serve "hello world". Of course 
>> wheezy.web smokes everybody else on both tests and that is something we 
>> should try understand. We should also try port gluino to wheezy.web.
>>
>> Massimo 
>>
>
> Thanks Massimo, I saw Andriy posting on comp.lang.python and recommended 
> he benchmark web2py.
>
> Would be very interested to see if web2py can catchup to the others. I 
> think that the performance when compared with Flask should be our main goal.
>
> Definitely a port of gluino to wheezy.web would be amazing :)
>

-- 





Re: [web2py] Re: framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Bruno Rocha
>
> Should we forfeit these checks because others do not do them and we want
> to appear faster in the benchmarks? I say no.
>

+1

I completely agree with this. After some months working with another
framework I say that the speed issues is not a problem compared to the hard
way of getting things done.

With the fine-tuned uwsgi+nginx I have all the web2py advantages and also
the speed because uwsgi is taking care to respawn my problematic workers,
that is seamless to my users and the app works very well.

"Premature optimization is the root of all evil!" I recently understood
this sentence, I tried to have a "performatic" app and I've lost more time
on this than on my app core. At the end I solved performance issue on the
server deployment + web2py best practices as the use of cache,
session.forget, migrate=False and wise use of models.

-- 





Re: [web2py] Version 2.09 wipes source files

2012-09-26 Thread Richard Vézina
How do you update?

Which 1.99 version 1.99.7?

Richard

On Wed, Sep 26, 2012 at 12:29 PM, chicks  wrote:

> Updated from 1.99 to 2.09 yesterday.  Everything looked fine until started
> editing via the web GUI.  Every edit overwrites the edited file with
> "undefined" when saved.  Reverting back to 1.99.  Anyone else seeing this
> issue?  Running on Solaris, Python 2.7.
>
> --
>
>
>
>

-- 





[web2py] Re: Version 2.09 wipes source files

2012-09-26 Thread Massimo Di Pierro
Is it possible your browser was caching the old js libraries with the new 
admin?
If not, what browser are you using?

massimo




On Wednesday, 26 September 2012 11:29:50 UTC-5, chicks wrote:
>
> Updated from 1.99 to 2.09 yesterday.  Everything looked fine until started 
> editing via the web GUI.  Every edit overwrites the edited file with 
> "undefined" when saved.  Reverting back to 1.99.  Anyone else seeing this 
> issue?  Running on Solaris, Python 2.7.

-- 





[web2py] Re: Forms - MVC model

2012-09-26 Thread MichaelF
I'm still struggling with the lines of control/authority/info-sharing 
between displaying/processing the data/form. (I realize not everyone agrees 
where these lines should be drawn, and even when drawn they're not 
necessarily "sharp, bright lines.") I like the idea of having the 
controller simply (!) get appropriate data and send it (say in a dict of 
lists of rows) to the view, which displays the data appropriately (in a 
form) and lets the controller process the form results 
(adding/updating/deleting records, etc.). The controller neither knows nor 
cares about the display of the data (but *does* need to know some of the 
form structure, so it will be able to know what to do with the data). The 
view needs to know what the data is, etc.

But much of the code I see in the manual has the controller 
create/populate/process the form...and so then I wonder what the view is 
for. (I realize a page is usually more than just a form, and *that* is what 
the view is for.) I'd like for the controller not to have to create the 
form with all its fields. (This isn't a huge problem for me, but I *would* 
like to have the controller not create the form, if possible.)

If I have a SQLFORM or CRUD, then the processing part is 'inside' the form 
processing, which is fine. But if I have a 'manual' form (meaning still 
using FORM and other helpers, but a non-SQLFORM, non-CRUD form), then the 
controller should process the posted data.

As things exist now (by convention, I think), the controller creates the 
form and processes the results. Is there a prescribed way (convention, I 
guess) that would allow me to have the controller simply gather the data 
needed by a form (other than SQLFORM and CRUD), and yet be able to process 
the form but not build it?

As the controller needs to process the form it needs to have a ref to the 
form object. I assume there's no easy way for the view to actually create 
the form and somehow tell the controller about it. So I'd have to do 
something like create a form object in the controller, then return that 
object (and related data). The form object would have NO items (input, 
checkbox, etc.). The view would add those items, essentially creating the 
'stuff' that goes inside the form object. With this division of labor the 
controller still can process the form, and the view would essentially build 
it (really, update the form object the controller created). So, something 
like:

#in controller file
def my_stuff():
   form = FORM() #note: pretty much an empty form
   if form.accepts(request, session):
  ...
   elif form.errors:
  ...
   else:
  data = db...

# my_stuff.html  VIEW
{{# build the form, using the form obj created by the controller}}
{{form.append(INPUT...)}}
{{form.append(_type=SUBMIT...))}}
{{=form}}

   1. Is this possible? I suspect not, as the 'recreation' of the form in 
   the controller on submission won't match what was submitted.
   2. Is this recommended?
   3. Am I just making things too involved (and should just create the form 
   in the controller)?
   
Thanks.

On Wednesday, June 27, 2012 10:39:03 AM UTC-6, Anthony wrote:
>
> Follow the examples in the book. Most of the form handling (including 
> creation of the FORM/SQLFORM) object should be handled in the controller. 
> In the view, you can handle the display of the form, but web2py will give 
> you a default display if you just do:
>
> {{=form}}
>
> Anthony
>
> On Wednesday, June 27, 2012 7:08:19 AM UTC-4, Pedro Casalinho wrote:
>>
>> This may be a dumb question but, should forms be created in controllers 
>> and passed to the view or should they be created in the view, taking into 
>> consideration the MVC model
>
>

-- 





Re: [web2py] Re: framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Ovidio Marinho
This is a web development or a comparison with the fastest formula 1, or
rifle which has the largest capacity of distance. Comparison baseless


   Ovidio Marinho Falcao Neto
Web Developer
 ovidio...@gmail.com
  ovidiomari...@itjp.net.br
 ITJP - itjp.net.br
   83   8826 9088 - Oi
   83   9334 0266 - Claro
Brasil




2012/9/26 Bruno Rocha 

> Should we forfeit these checks because others do not do them and we want
>> to appear faster in the benchmarks? I say no.
>>
>
> +1
>
> I completely agree with this. After some months working with another
> framework I say that the speed issues is not a problem compared to the hard
> way of getting things done.
>
> With the fine-tuned uwsgi+nginx I have all the web2py advantages and also
> the speed because uwsgi is taking care to respawn my problematic workers,
> that is seamless to my users and the app works very well.
>
> "Premature optimization is the root of all evil!" I recently understood
> this sentence, I tried to have a "performatic" app and I've lost more time
> on this than on my app core. At the end I solved performance issue on the
> server deployment + web2py best practices as the use of cache,
> session.forget, migrate=False and wise use of models.
>
> --
>
>
>
>

-- 





[web2py] Re: framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Marin Pranjić
This benchmark is useless.

Why don't we make a benchmark with more complex app?

Marin

-- 





Re: [web2py] framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Massimo Di Pierro
Good point. Forwarding to the mailing list. Feel free join, even only to pitch 
in this discussion.
On the web2py list we do not mind learning more about new frameworks.

Massimo

On Sep 26, 2012, at 1:36 PM, Andriy Kornatskyy wrote:

> 
> Massimo,
> 
> Let me please add my two cents as to why simple benchmark like `hello world` 
> is important.
> 
> Before I step in, a link to live demo:
> 
> http://wheezy.pythonanywhere.com/
> 
> The home page of this application is rendered at the speed of `hello world` 
> application.
> 
> hello world - 23318 rps
> home page - 21144 rps (see 
> http://mindref.blogspot.com/2012/07/python-fastest-template.html at real 
> world example section)
> 
> With content caching:
> http://packages.python.org/wheezy.http/userguide.html#content-cache
> 
> and cache dependency:
> 
> http://packages.python.org/wheezy.caching/userguide.html#cachedependency
> 
> any of your dynamic page turns into `hello world` application performance.
> 
> Please share this with your team as you find this appropriate.
> 
> Thanks.
> 
> Andriy Kornatskyy
> 
> P.S. asserts over things like ip address are essential, but must still be 
> optional. Once bug in application server has been fixed those checks have no 
> sense. Paranoia? Why not just simply certify certain application servers to 
> be TRUSTED... there are no so much to assert to say this is bad idea.

-- 





Re: [web2py] Re: Problems with a validation procedure ? - a Canadian postal code !

2012-09-26 Thread Richard Vézina
You can may use .capitalize() before the vars get validated by validators.
I thought that there was a way to do action before the form get validated,
but I can't find in the book, something like beforevalidation, instead of
onvalidation that is provided.

I think that if beforevalidation doesn't exist it could be helpful
sometimes, but in this case you can just make your own validator that could
be base on IS_MATCH() and only .capitalize() variable before it get into
IS_MATCH()

Richard

On Wed, Sep 26, 2012 at 7:29 AM, Le Don X  wrote:

> don't be sorry for jumping in  it is appreciated ! .. and refreshing
> to noticed that there are canadian folks like me on here !
>
> to resume ... from all the responses received - the best canadian postal
> code validation is actually the one submitted by Adnan :
>
> this one :  ^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$
>
> thank you ! ...
>
> with just one addition : the postal code entered will need to be
> capitalised before validation to avoid any issues !
>
> This thread could help others with the same concern !
>
> --
>
>
>
>

-- 





Re: [web2py] Version 2.09 wipes source files

2012-09-26 Thread chicks
Updated by unzipping the source file.  Don't recall exactly which 1.99 
version, downloaded / installed on May 8.

On Wednesday, September 26, 2012 10:18:44 AM UTC-7, Richard wrote:

> How do you update? 
>
> Which 1.99 version 1.99.7?
>
> Richard
>
> On Wed, Sep 26, 2012 at 12:29 PM, chicks  >wrote:
>
>> Updated from 1.99 to 2.09 yesterday.  Everything looked fine until 
>> started editing via the web GUI.  Every edit overwrites the edited file 
>> with "undefined" when saved.  Reverting back to 1.99.  Anyone else seeing 
>> this issue?  Running on Solaris, Python 2.7. 
>>
>> -- 
>>  
>>  
>>  
>>
>
>

-- 





[web2py] Re: Version 2.09 wipes source files

2012-09-26 Thread chicks
Just restarted the browser (IE9 on Win7), cleared the cache, still wipes 
out the source files upon edit/save.  Reverting back to 1.99 for now...

On Wednesday, September 26, 2012 10:24:38 AM UTC-7, Massimo Di Pierro wrote:

> Is it possible your browser was caching the old js libraries with the new 
> admin? 
> If not, what browser are you using?
>
> massimo
>
>
>
>
> On Wednesday, 26 September 2012 11:29:50 UTC-5, chicks wrote: 
>>
>> Updated from 1.99 to 2.09 yesterday.  Everything looked fine until 
>> started editing via the web GUI.  Every edit overwrites the edited file 
>> with "undefined" when saved.  Reverting back to 1.99.  Anyone else seeing 
>> this issue?  Running on Solaris, Python 2.7.
>
>

-- 





[web2py] Re: global name 'db' is not defined

2012-09-26 Thread Роман Акимов


понедельник, 24 сентября 2012 г., 23:51:21 UTC+6 пользователь Massimo Di 
Pierro написал:
>
> db should be defined in your models/db.py
>
> db= DAL()
>
> Models are executed in alphabetical order. It will not be there for you if 
> you deleted db.py or name your model so that it is executed before db.py.
>
> Massimo
>
> On Monday, 24 September 2012 05:26:26 UTC-5, Роман Акимов wrote:
>>
>> Hello all!
>> Please help me.
>> I'm write:
>>
>> model
>> db.define_table(
>> 'document_body',
>> Field('name'),
>> Field('number'),
>> Field('created', 'datetime', default=request.now),
>> Field('start_date', 'date'),
>> Field('end_date', 'date'),
>> Field('activity', 'boolean', default=True),
>> )
>>
>> controller
>> def index():
>> form = SQLFORM(db.document_body)
>> if form.process().accepted:
>> response.flash = 'document uploaded'
>> return dict(form = form)
>>
>> And i have error in default.py:
>>  global name 'db' is not defined
>> Thanks to all. Your help is very important. There was a problem:
>>
>  def edit_doc():
doc = db.document_body(request.args(0)) or redirect(URL('docum'))
form = Crud.update(1,db.document_body, doc, next='docum')
return dict(form=form)
I catch error: 
unbound method update() must be called with Crud instance as first argument 
(got int instance instead)
But the text I wrote on the official documentation.
What am I doing wrong

-- 





[web2py] Re: Version 2.09 wipes source files

2012-09-26 Thread Massimo Di Pierro
Can anybody else reproduce this? I do not have IE9 nor Win7.

On Wednesday, 26 September 2012 12:34:18 UTC-5, chicks wrote:
>
> Just restarted the browser (IE9 on Win7), cleared the cache, still wipes 
> out the source files upon edit/save.  Reverting back to 1.99 for now...
>
> On Wednesday, September 26, 2012 10:24:38 AM UTC-7, Massimo Di Pierro 
> wrote:
>
>> Is it possible your browser was caching the old js libraries with the new 
>> admin? 
>> If not, what browser are you using?
>>
>> massimo
>>
>>
>>
>>
>> On Wednesday, 26 September 2012 11:29:50 UTC-5, chicks wrote: 
>>>
>>> Updated from 1.99 to 2.09 yesterday.  Everything looked fine until 
>>> started editing via the web GUI.  Every edit overwrites the edited file 
>>> with "undefined" when saved.  Reverting back to 1.99.  Anyone else seeing 
>>> this issue?  Running on Solaris, Python 2.7.
>>
>>

-- 





[web2py] Re: global name 'db' is not defined

2012-09-26 Thread Massimo Di Pierro
Crud.update

should be

crud.update

crud an object which belongs to class Crud.

On Wednesday, 26 September 2012 12:16:25 UTC-5, Роман Акимов wrote:
>
>
>
> понедельник, 24 сентября 2012 г., 23:51:21 UTC+6 пользователь Massimo Di 
> Pierro написал:
>>
>> db should be defined in your models/db.py
>>
>> db= DAL()
>>
>> Models are executed in alphabetical order. It will not be there for you 
>> if you deleted db.py or name your model so that it is executed before db.py.
>>
>> Massimo
>>
>> On Monday, 24 September 2012 05:26:26 UTC-5, Роман Акимов wrote:
>>>
>>> Hello all!
>>> Please help me.
>>> I'm write:
>>>
>>> model
>>> db.define_table(
>>> 'document_body',
>>> Field('name'),
>>> Field('number'),
>>> Field('created', 'datetime', default=request.now),
>>> Field('start_date', 'date'),
>>> Field('end_date', 'date'),
>>> Field('activity', 'boolean', default=True),
>>> )
>>>
>>> controller
>>> def index():
>>> form = SQLFORM(db.document_body)
>>> if form.process().accepted:
>>> response.flash = 'document uploaded'
>>> return dict(form = form)
>>>
>>> And i have error in default.py:
>>>  global name 'db' is not defined
>>> Thanks to all. Your help is very important. There was a problem:
>>>
>>  def edit_doc():
> doc = db.document_body(request.args(0)) or redirect(URL('docum'))
> form = Crud.update(1,db.document_body, doc, next='docum')
> return dict(form=form)
> I catch error: 
> unbound method update() must be called with Crud instance as first 
> argument (got int instance instead)
> But the text I wrote on the official documentation.
> What am I doing wrong
>

-- 





Re: [web2py] Re: Problems with a validation procedure ? - a Canadian postal code !

2012-09-26 Thread Massimo Di Pierro
Yes.

you can do:

import re
from gluon.validator import Validator
class CANADIAN_ZIP(Validator):
regex = re.compile('^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} 
*\d{1}[A-Z]{1}\d{1}$')
def __init__(self,error_message='invalid!):
 self.error_message = error_message
def __call__(self,value):
 value = str(value).upper()
 if self.regex.match(value): return value, None
 else: return value, self.error_message

then use requires=CANADIAN_ZIP()

On Wednesday, 26 September 2012 14:21:07 UTC-5, Richard wrote:
>
> You can may use .capitalize() before the vars get validated by validators. 
> I thought that there was a way to do action before the form get validated, 
> but I can't find in the book, something like beforevalidation, instead of 
> onvalidation that is provided.
>
> I think that if beforevalidation doesn't exist it could be helpful 
> sometimes, but in this case you can just make your own validator that could 
> be base on IS_MATCH() and only .capitalize() variable before it get into 
> IS_MATCH()
>
> Richard
>
> On Wed, Sep 26, 2012 at 7:29 AM, Le Don X 
> > wrote:
>
>> don't be sorry for jumping in  it is appreciated ! .. and refreshing 
>> to noticed that there are canadian folks like me on here ! 
>>
>> to resume ... from all the responses received - the best canadian postal 
>> code validation is actually the one submitted by Adnan :
>>
>> this one :  ^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$
>>
>> thank you ! ...
>>
>> with just one addition : the postal code entered will need to be 
>> capitalised before validation to avoid any issues !
>>
>> This thread could help others with the same concern !
>>  
>> -- 
>>  
>>  
>>  
>>
>
>  

-- 





Re: [web2py] Re: Problems with a validation procedure ? - a Canadian postal code !

2012-09-26 Thread Richard Vézina
:)

Richard

On Wed, Sep 26, 2012 at 3:25 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Yes.
>
> you can do:
>
> import re
> from gluon.validator import Validator
> class CANADIAN_ZIP(Validator):
> regex = re.compile('^[ABCEGHJKLMNPRSTVXY]{1}\d{1}**[A-Z]{1}
> *\d{1}[A-Z]{1}\d{1}$')
> def __init__(self,error_message='invalid!):
>  self.error_message = error_message
> def __call__(self,value):
>  value = str(value).upper()
>  if self.regex.match(value): return value, None
>  else: return value, self.error_message
>
> then use requires=CANADIAN_ZIP()
>
> On Wednesday, 26 September 2012 14:21:07 UTC-5, Richard wrote:
>
>> You can may use .capitalize() before the vars get validated by
>> validators. I thought that there was a way to do action before the form get
>> validated, but I can't find in the book, something like beforevalidation,
>> instead of onvalidation that is provided.
>>
>> I think that if beforevalidation doesn't exist it could be helpful
>> sometimes, but in this case you can just make your own validator that could
>> be base on IS_MATCH() and only .capitalize() variable before it get into
>> IS_MATCH()
>>
>> Richard
>>
>>
>> On Wed, Sep 26, 2012 at 7:29 AM, Le Don X  wrote:
>>
>>> don't be sorry for jumping in  it is appreciated ! .. and refreshing
>>> to noticed that there are canadian folks like me on here !
>>>
>>> to resume ... from all the responses received - the best canadian postal
>>> code validation is actually the one submitted by Adnan :
>>>
>>> this one :  ^[ABCEGHJKLMNPRSTVXY]{1}\d{1}**[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$
>>>
>>> thank you ! ...
>>>
>>> with just one addition : the postal code entered will need to be
>>> capitalised before validation to avoid any issues !
>>>
>>> This thread could help others with the same concern !
>>>
>>> --
>>>
>>>
>>>
>>>
>>
>>   --
>
>
>
>

-- 





[web2py] How to queue emails with attachments using the Scheduler?

2012-09-26 Thread Martin Weissenboeck
I want to use the Scheduler for sending emails.
Everything works fine, but I cannot use an Attachment:

I use json.dumps for the "var" field of scheduler_task, but json.dumps
cannot convert an Attachment.

Next try: pickle.dumps "hides" the attachment and json.dumps accepts this:

db.scheduler_task.insert(
status='QUEUED',
application_name='secure',
task_name='task_name',
function_name='send_email',
args='[]',
vars=json.dumps(dict(to=to, subject=subject, message=str(message),
attachments=pickle.dumps(attachments), cc=cc, bcc=bcc,
reply_to=reply_to,
encoding=encoding, headers=headers)),

enabled=True,
start_time=start_time,
stop_time=start_time+timedelta(days=1),
repeats=1,
retry_failed=retry_failed,
period=period,
timeout=120,
)

Now the scheduler_run reports an error

Traceback (most recent call last):
  File "D:\web2py\gluon\scheduler.py", line 217, in executor
vars = loads(task.vars, object_hook=_decode_dict)
  File "D:\web2py\gluon\contrib\simplejson\__init__.py", line 403, in loads
return cls(encoding=encoding, **kw).decode(s)
  File "D:\web2py\gluon\contrib\simplejson\decoder.py", line 403, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\web2py\gluon\contrib\simplejson\decoder.py", line 421, in
raw_decode
raise JSONDecodeError("No JSON object could be decoded", s, idx)
JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)

My question: is there a way to queue emails with attachments using the
Scheduler?

Regards, Martin

-- 





[web2py] Re: Starting a simple project from scratch

2012-09-26 Thread Vixus
Thanks very much! I'll make sure to read the book through as well.

On Wednesday, September 26, 2012 5:13:28 PM UTC+1, Massimo Di Pierro wrote:
>
> You can delete all of web2py files in an app and make your own.
>
> The controllers (in your case default.py) is executed in the same 
> environment as the models, therefore it see all the variables defined in 
> the models (in web2py that is what models are for: they build the 
> environment for the controller).
>
> The only files that you may want to retain are appadmin.py and 
> appadmin.html because they implement database administration and 
> jquery.js/web2py.js/calendar.js because they implement useful stuff for 
> forms and web2py_components.
>
> Massimo
>
>
>
> On Tuesday, 25 September 2012 18:47:48 UTC-5, Vixus wrote:
>>
>> Hi, thanks for your reply!
>>
>> What about the rest of the files? Can I make my own layout.html and 
>> default.py from scratch? I was struggling to find all the details on the 
>> auth object in the documentation and also what the gluon module is and how 
>> to use it. default.py doesn't seem to have any imports or anything, are 
>> these put in automatically by web2py?
>>
>> vix
>>
>> On Monday, September 24, 2012 10:24:45 PM UTC+1, Massimo Di Pierro wrote:
>>>
>>> Hello Vixus,
>>>
>>> If you want to use bootstrap, than it comes with it.
>>> If not, then deleted everything but web2py.css, jquery.js, and web2py.js 
>>> for components and grids you need those but they are small and un-intrusive.
>>>
>>> massimo
>>>
>>>
>>>
>>> On Sunday, 23 September 2012 10:05:46 UTC-5, Vixus wrote:

 So I'm reasonably experienced with python and grew up web developing 
 with PHP. I wanted to move all my web development over to python and 
 web2py 
 seemed like the ideal way to get started. There's one thing I really don't 
 like however and is giving me a lot of trouble actually learning the 
 framework and that's all the default cruft that gets put in place when I 
 start a new application. Also a lot of things are hidden behind the IDE 
 (where is default.py getting all its module info from?) -- there doesn't 
 seem to be any technical explanation of what's  going on behind the scenes.

 For instance, yes, it's very nice that a user system is put in place 
 for me but all the other stuff like the bootstrap UI elements just gets in 
 the way of me developing my website because I spend more time sifting 
 through the huge CSS files trying to fix things. Basically, I'm used to 
 building my sites from the very ground up, because then I know how 
 everything fits together and works. With web2py I've found this really 
 confusing. Yes, I'll read through the entire book but I'd find it a lot 
 easier to get the examples if I had a really blank project to work with. 

 So what does everyone think? Do I just delete all the files and start 
 from scratch (I'm scared something will break or I won't have the right 
 initial setup) or continue trying to muddle through with the prefab setup?

 web2py feels amazingly powerful, and I want to add it to my arsenal, so 
 any help is appreciated. Thanks!

>>>

-- 





[web2py] Re: Strange quirks with GAE

2012-09-26 Thread Pystar
Yes, I found that out. It works for me. Only (1) which is sending mails 
generated from the template doesnt.

On Wednesday, September 26, 2012 12:36:15 AM UTC+1, howesc wrote:
>
> i use GAE to send mail daily i have neither of these problems.  there must 
> be something amuck somewhere...
>
> re #2, GAE does require sending from a verified sender and they way they 
> do that is the sender must be an admin on the GAE console.  you can invite 
> any email address you like to be a sender - you just have to be able to 
> receive email as that user and accept the invitation to develop.  this is a 
> GAE limitation not web2py.
>
> cfh
>
> On Monday, September 24, 2012 6:15:10 PM UTC-7, Pystar wrote:
>>
>> There are some strange quirks I noticed while working extensively with 
>> Google App Engine. These include:
>> 1. You can not send HTML messages using mail.send() without doing some 
>> extensive work arounds.
>> 2. You can not send html messages from GAE from any address apart from 
>> your Gmail address, although the documentation states that you should be 
>> able to do so with any address that you can also use to login to the app 
>> engine control panel, this isnt so.
>>
>> Has anyone noticed any more?
>>
>

-- 





[web2py] Re: Forms - MVC model

2012-09-26 Thread Anthony
When you build a form object in the controller, although you may make some 
specifications that control its display, you are primarily defining a data 
model for the form. The form object itself is not merely an HTML DOM 
representation but also encapsulates the default and submitted values, 
validators, CSRF token, etc. The form itself is ultimately serialized in 
the view, and if you want something other than the default serialization, 
you would handle that in the view as well (via form.custom or manually 
created HTML markup). So, for the most part, true display-related aspects 
of the form are generally handled in the view, and the controller (and 
model for SQLFORMs) takes care of the data modeling and validation.

Anthony

On Wednesday, September 26, 2012 1:55:32 PM UTC-4, MichaelF wrote:
>
> I'm still struggling with the lines of control/authority/info-sharing 
> between displaying/processing the data/form. (I realize not everyone agrees 
> where these lines should be drawn, and even when drawn they're not 
> necessarily "sharp, bright lines.") I like the idea of having the 
> controller simply (!) get appropriate data and send it (say in a dict of 
> lists of rows) to the view, which displays the data appropriately (in a 
> form) and lets the controller process the form results 
> (adding/updating/deleting records, etc.). The controller neither knows nor 
> cares about the display of the data (but *does* need to know some of the 
> form structure, so it will be able to know what to do with the data). The 
> view needs to know what the data is, etc.
>
> But much of the code I see in the manual has the controller 
> create/populate/process the form...and so then I wonder what the view is 
> for. (I realize a page is usually more than just a form, and *that* is what 
> the view is for.) I'd like for the controller not to have to create the 
> form with all its fields. (This isn't a huge problem for me, but I *would* 
> like to have the controller not create the form, if possible.)
>
> If I have a SQLFORM or CRUD, then the processing part is 'inside' the form 
> processing, which is fine. But if I have a 'manual' form (meaning still 
> using FORM and other helpers, but a non-SQLFORM, non-CRUD form), then the 
> controller should process the posted data.
>
> As things exist now (by convention, I think), the controller creates the 
> form and processes the results. Is there a prescribed way (convention, I 
> guess) that would allow me to have the controller simply gather the data 
> needed by a form (other than SQLFORM and CRUD), and yet be able to process 
> the form but not build it?
>
> As the controller needs to process the form it needs to have a ref to the 
> form object. I assume there's no easy way for the view to actually create 
> the form and somehow tell the controller about it. So I'd have to do 
> something like create a form object in the controller, then return that 
> object (and related data). The form object would have NO items (input, 
> checkbox, etc.). The view would add those items, essentially creating the 
> 'stuff' that goes inside the form object. With this division of labor the 
> controller still can process the form, and the view would essentially build 
> it (really, update the form object the controller created). So, something 
> like:
>
> #in controller file
> def my_stuff():
>form = FORM() #note: pretty much an empty form
>if form.accepts(request, session):
>   ...
>elif form.errors:
>   ...
>else:
>   data = db...
>
> # my_stuff.html  VIEW
> {{# build the form, using the form obj created by the controller}}
> {{form.append(INPUT...)}}
> {{form.append(_type=SUBMIT...))}}
> {{=form}}
>
>1. Is this possible? I suspect not, as the 'recreation' of the form in 
>the controller on submission won't match what was submitted.
>2. Is this recommended?
>3. Am I just making things too involved (and should just create the 
>form in the controller)?
>
> Thanks.
>
> On Wednesday, June 27, 2012 10:39:03 AM UTC-6, Anthony wrote:
>>
>> Follow the examples in the book. Most of the form handling (including 
>> creation of the FORM/SQLFORM) object should be handled in the controller. 
>> In the view, you can handle the display of the form, but web2py will give 
>> you a default display if you just do:
>>
>> {{=form}}
>>
>> Anthony
>>
>> On Wednesday, June 27, 2012 7:08:19 AM UTC-4, Pedro Casalinho wrote:
>>>
>>> This may be a dumb question but, should forms be created in controllers 
>>> and passed to the view or should they be created in the view, taking into 
>>> consideration the MVC model
>>
>>

-- 





[web2py] Re: How to queue emails with attachments using the Scheduler?

2012-09-26 Thread Niphlod
everything going to scheduler must be "jsonifiable". Can you use the 
attachment parameters pointing to a physical file (as 
'/yourapp/private/something.png') and in your "send_mail" function retrieve 
the path and initialize an attachment ? A string is definitely 
jsonifiable 
e.g. 
def send_mail(to, subject='None', message='None', attachment=None):
  attachment = Mail.Attachment(attachment)
  mail.send(.., attachment)


-- 





[web2py] Re: Version 2.09 wipes source files

2012-09-26 Thread LightDot
I just did a quick test using IE9 on Windows 7 and I can't reproduce. I was 
editing the source on Scientific Linux 6.3 / Apache, I don't have a Solaris 
machine available. I did not do an upgrade from 1.99.x to 2.x.x, though, 
I'm using the latest trunk.

@chicks: could you perhaps make a separate, clean 2.0.9 install on the same 
Solaris server and try to reproduce? I'm guessing the editing side (win7, 
IE9) doesn't really matter here, but it's a bit early to say... Are you 
using the embedded Rocket server to run web2py, or perhaps Apache, or...?

Regards,
Ales


On Wednesday, September 26, 2012 9:27:28 PM UTC+2, Massimo Di Pierro wrote:
>
> Can anybody else reproduce this? I do not have IE9 nor Win7.
>
> On Wednesday, 26 September 2012 12:34:18 UTC-5, chicks wrote:
>>
>> Just restarted the browser (IE9 on Win7), cleared the cache, still wipes 
>> out the source files upon edit/save.  Reverting back to 1.99 for now...
>>
>> On Wednesday, September 26, 2012 10:24:38 AM UTC-7, Massimo Di Pierro 
>> wrote:
>>
>>> Is it possible your browser was caching the old js libraries with the 
>>> new admin? 
>>> If not, what browser are you using?
>>>
>>> massimo
>>>
>>>
>>>
>>>
>>> On Wednesday, 26 September 2012 11:29:50 UTC-5, chicks wrote: 

 Updated from 1.99 to 2.09 yesterday.  Everything looked fine until 
 started editing via the web GUI.  Every edit overwrites the edited file 
 with "undefined" when saved.  Reverting back to 1.99.  Anyone else seeing 
 this issue?  Running on Solaris, Python 2.7.
>>>
>>>

-- 





[web2py] Re: Version 2.09 wipes source files

2012-09-26 Thread Massimo Di Pierro
I am pretty sure this has nothing to do with the server. This is a JS 
issue. "undefined" is a JS keyword.

On Wednesday, 26 September 2012 15:22:26 UTC-5, LightDot wrote:
>
> I just did a quick test using IE9 on Windows 7 and I can't reproduce. I 
> was editing the source on Scientific Linux 6.3 / Apache, I don't have a 
> Solaris machine available. I did not do an upgrade from 1.99.x to 2.x.x, 
> though, I'm using the latest trunk.
>
> @chicks: could you perhaps make a separate, clean 2.0.9 install on the 
> same Solaris server and try to reproduce? I'm guessing the editing side 
> (win7, IE9) doesn't really matter here, but it's a bit early to say... Are 
> you using the embedded Rocket server to run web2py, or perhaps Apache, 
> or...?
>
> Regards,
> Ales
>
>
> On Wednesday, September 26, 2012 9:27:28 PM UTC+2, Massimo Di Pierro wrote:
>>
>> Can anybody else reproduce this? I do not have IE9 nor Win7.
>>
>> On Wednesday, 26 September 2012 12:34:18 UTC-5, chicks wrote:
>>>
>>> Just restarted the browser (IE9 on Win7), cleared the cache, still wipes 
>>> out the source files upon edit/save.  Reverting back to 1.99 for now...
>>>
>>> On Wednesday, September 26, 2012 10:24:38 AM UTC-7, Massimo Di Pierro 
>>> wrote:
>>>
 Is it possible your browser was caching the old js libraries with the 
 new admin? 
 If not, what browser are you using?

 massimo




 On Wednesday, 26 September 2012 11:29:50 UTC-5, chicks wrote: 
>
> Updated from 1.99 to 2.09 yesterday.  Everything looked fine until 
> started editing via the web GUI.  Every edit overwrites the edited file 
> with "undefined" when saved.  Reverting back to 1.99.  Anyone else seeing 
> this issue?  Running on Solaris, Python 2.7.



-- 





[web2py] Re: Forms - MVC model

2012-09-26 Thread MichaelF
That makes sense; thanks. I guess I never looked at it that way.

On Wednesday, September 26, 2012 2:02:41 PM UTC-6, Anthony wrote:
>
> When you build a form object in the controller, although you may make some 
> specifications that control its display, you are primarily defining a data 
> model for the form. The form object itself is not merely an HTML DOM 
> representation but also encapsulates the default and submitted values, 
> validators, CSRF token, etc. The form itself is ultimately serialized in 
> the view, and if you want something other than the default serialization, 
> you would handle that in the view as well (via form.custom or manually 
> created HTML markup). So, for the most part, true display-related aspects 
> of the form are generally handled in the view, and the controller (and 
> model for SQLFORMs) takes care of the data modeling and validation.
>
> Anthony
>
> On Wednesday, September 26, 2012 1:55:32 PM UTC-4, MichaelF wrote:
>>
>> I'm still struggling with the lines of control/authority/info-sharing 
>> between displaying/processing the data/form. (I realize not everyone agrees 
>> where these lines should be drawn, and even when drawn they're not 
>> necessarily "sharp, bright lines.") I like the idea of having the 
>> controller simply (!) get appropriate data and send it (say in a dict of 
>> lists of rows) to the view, which displays the data appropriately (in a 
>> form) and lets the controller process the form results 
>> (adding/updating/deleting records, etc.). The controller neither knows nor 
>> cares about the display of the data (but *does* need to know some of the 
>> form structure, so it will be able to know what to do with the data). The 
>> view needs to know what the data is, etc.
>>
>> But much of the code I see in the manual has the controller 
>> create/populate/process the form...and so then I wonder what the view is 
>> for. (I realize a page is usually more than just a form, and *that* is what 
>> the view is for.) I'd like for the controller not to have to create the 
>> form with all its fields. (This isn't a huge problem for me, but I *would* 
>> like to have the controller not create the form, if possible.)
>>
>> If I have a SQLFORM or CRUD, then the processing part is 'inside' the 
>> form processing, which is fine. But if I have a 'manual' form (meaning 
>> still using FORM and other helpers, but a non-SQLFORM, non-CRUD form), then 
>> the controller should process the posted data.
>>
>> As things exist now (by convention, I think), the controller creates the 
>> form and processes the results. Is there a prescribed way (convention, I 
>> guess) that would allow me to have the controller simply gather the data 
>> needed by a form (other than SQLFORM and CRUD), and yet be able to process 
>> the form but not build it?
>>
>> As the controller needs to process the form it needs to have a ref to the 
>> form object. I assume there's no easy way for the view to actually create 
>> the form and somehow tell the controller about it. So I'd have to do 
>> something like create a form object in the controller, then return that 
>> object (and related data). The form object would have NO items (input, 
>> checkbox, etc.). The view would add those items, essentially creating the 
>> 'stuff' that goes inside the form object. With this division of labor the 
>> controller still can process the form, and the view would essentially build 
>> it (really, update the form object the controller created). So, something 
>> like:
>>
>> #in controller file
>> def my_stuff():
>>form = FORM() #note: pretty much an empty form
>>if form.accepts(request, session):
>>   ...
>>elif form.errors:
>>   ...
>>else:
>>   data = db...
>>
>> # my_stuff.html  VIEW
>> {{# build the form, using the form obj created by the controller}}
>> {{form.append(INPUT...)}}
>> {{form.append(_type=SUBMIT...))}}
>> {{=form}}
>>
>>1. Is this possible? I suspect not, as the 'recreation' of the form 
>>in the controller on submission won't match what was submitted.
>>2. Is this recommended?
>>3. Am I just making things too involved (and should just create the 
>>form in the controller)?
>>
>> Thanks.
>>
>> On Wednesday, June 27, 2012 10:39:03 AM UTC-6, Anthony wrote:
>>>
>>> Follow the examples in the book. Most of the form handling (including 
>>> creation of the FORM/SQLFORM) object should be handled in the controller. 
>>> In the view, you can handle the display of the form, but web2py will give 
>>> you a default display if you just do:
>>>
>>> {{=form}}
>>>
>>> Anthony
>>>
>>> On Wednesday, June 27, 2012 7:08:19 AM UTC-4, Pedro Casalinho wrote:

 This may be a dumb question but, should forms be created in controllers 
 and passed to the view or should they be created in the view, taking into 
 consideration the MVC model
>>>
>>>

-- 





[web2py] Re: Version 2.09 wipes source files

2012-09-26 Thread chicks
I'm using the embedded Rocket server.  Will try another clean install and 
see what happens.  Thanks for the super quick responses on this!  Amazing...

On Wednesday, September 26, 2012 1:22:26 PM UTC-7, LightDot wrote:

> I just did a quick test using IE9 on Windows 7 and I can't reproduce. I 
> was editing the source on Scientific Linux 6.3 / Apache, I don't have a 
> Solaris machine available. I did not do an upgrade from 1.99.x to 2.x.x, 
> though, I'm using the latest trunk.
>
> @chicks: could you perhaps make a separate, clean 2.0.9 install on the 
> same Solaris server and try to reproduce? I'm guessing the editing side 
> (win7, IE9) doesn't really matter here, but it's a bit early to say... Are 
> you using the embedded Rocket server to run web2py, or perhaps Apache, 
> or...?
>
> Regards,
> Ales
>
>
> On Wednesday, September 26, 2012 9:27:28 PM UTC+2, Massimo Di Pierro 
> wrote: 
>>
>> Can anybody else reproduce this? I do not have IE9 nor Win7.
>>
>> On Wednesday, 26 September 2012 12:34:18 UTC-5, chicks wrote: 
>>>
>>> Just restarted the browser (IE9 on Win7), cleared the cache, still wipes 
>>> out the source files upon edit/save.  Reverting back to 1.99 for now...
>>>
>>> On Wednesday, September 26, 2012 10:24:38 AM UTC-7, Massimo Di Pierro 
>>> wrote:
>>>
 Is it possible your browser was caching the old js libraries with the 
 new admin? 
 If not, what browser are you using?

 massimo




 On Wednesday, 26 September 2012 11:29:50 UTC-5, chicks wrote: 
>
> Updated from 1.99 to 2.09 yesterday.  Everything looked fine until 
> started editing via the web GUI.  Every edit overwrites the edited file 
> with "undefined" when saved.  Reverting back to 1.99.  Anyone else seeing 
> this issue?  Running on Solaris, Python 2.7.



-- 





[web2py] Re: Version 2.09 wipes source files

2012-09-26 Thread Massimo Di Pierro
When you click save the the function doClickSave 
in applications/admin/static/js/ajax_editor.js is called. Is loads the data 
(text to be saved) and make an ajax POST to save it. The text is computed 
in line 29 in the function getData(). I suspect this function is returning 
"undefined". 

Perhaps you can help us understand why by inserting some alert(...); 
statements.

On Wednesday, 26 September 2012 15:47:58 UTC-5, chicks wrote:
>
> I'm using the embedded Rocket server.  Will try another clean install and 
> see what happens.  Thanks for the super quick responses on this!  Amazing...
>
> On Wednesday, September 26, 2012 1:22:26 PM UTC-7, LightDot wrote:
>
>> I just did a quick test using IE9 on Windows 7 and I can't reproduce. I 
>> was editing the source on Scientific Linux 6.3 / Apache, I don't have a 
>> Solaris machine available. I did not do an upgrade from 1.99.x to 2.x.x, 
>> though, I'm using the latest trunk.
>>
>> @chicks: could you perhaps make a separate, clean 2.0.9 install on the 
>> same Solaris server and try to reproduce? I'm guessing the editing side 
>> (win7, IE9) doesn't really matter here, but it's a bit early to say... Are 
>> you using the embedded Rocket server to run web2py, or perhaps Apache, 
>> or...?
>>
>> Regards,
>> Ales
>>
>>
>> On Wednesday, September 26, 2012 9:27:28 PM UTC+2, Massimo Di Pierro 
>> wrote: 
>>>
>>> Can anybody else reproduce this? I do not have IE9 nor Win7.
>>>
>>> On Wednesday, 26 September 2012 12:34:18 UTC-5, chicks wrote: 

 Just restarted the browser (IE9 on Win7), cleared the cache, still 
 wipes out the source files upon edit/save.  Reverting back to 1.99 for 
 now...

 On Wednesday, September 26, 2012 10:24:38 AM UTC-7, Massimo Di Pierro 
 wrote:

> Is it possible your browser was caching the old js libraries with the 
> new admin? 
> If not, what browser are you using?
>
> massimo
>
>
>
>
> On Wednesday, 26 September 2012 11:29:50 UTC-5, chicks wrote: 
>>
>> Updated from 1.99 to 2.09 yesterday.  Everything looked fine until 
>> started editing via the web GUI.  Every edit overwrites the edited file 
>> with "undefined" when saved.  Reverting back to 1.99.  Anyone else 
>> seeing 
>> this issue?  Running on Solaris, Python 2.7.
>
>

-- 





[web2py] Re: TNS error on Oracle

2012-09-26 Thread Bill Thayer
Just spent 2 days on this error. Using instant client I needed to point 
ORACLE_HOME and TNS_ADMIN to the instanclient folder and make sure the 
tnsnames.ora file was inside.

On Tuesday, March 6, 2012 8:21:52 AM UTC-6, rochacbruno wrote:
>
> Does anybody knows something about this?
>
> it connects with cx_oracle and raw queries, but gives this error on DAL.
>
>
>
>1.  Traceback (most recent call last):
>2.File "", line 1, in 
>3. db = DAL("oracle://ricardo/ricardo@10.10.1.84:1521/XE")
>4.   File "C:\Python27\lib\site-packages\gluon\dal.py", line 5968, in 
>__init__
>5. raise RuntimeError, "Failure to connect, tried %d times:\n%s" % 
>(attempts, tb)
>6. RuntimeError: Failure to connect, tried 5 times:
>7.  Traceback (most recent call last):
>8.File "C:\Python27\lib\site-packages\gluon\dal.py", line 5955, in 
>__init__
>9. self._adapter = ADAPTERS[self._dbname](*args)
>10.   File "C:\Python27\lib\site-packages\gluon\dal.py", line 2185, in 
>__init__
>11. self.pool_connection(connect)
>12.   File "C:\Python27\lib\site-packages\gluon\dal.py", line 465, in
> pool_connection
>13. self.connection = f()
>14.   File "C:\Python27\lib\site-packages\gluon\dal.py", line 2184, in
> connect
>15. return self.driver.connect(uri,**driver_args)
>16. DatabaseError: ORA-12514: TNS:listener does not currently know of 
>service requested in connect descriptor
>
>
>
> -- 
>
> Bruno Rocha
> [http://rochacbruno.com.br]
>
>

-- 





[web2py] scheduler cannot detect correct application name

2012-09-26 Thread Vincenzo Ampolo
Hi,

I've deployed my application in a server, in the meantime I also changed
the application name.

To do so I installed web2py, then created a new application using the
admin interface and then I copied the content of the directory of the
project in the newly created directory.
For the db I did a dump and restored on the new server.

Everything work smooth except the scheduler. When a worker picks up a
job it dies with this error:

Traceback (most recent call last):
  File "/var/www/milo-reloaded/web2py/gluon/scheduler.py", line 203, in
executor
_env = env(a=a,c=c,import_models=True)
  File "/var/www/milo-reloaded/web2py/gluon/shell.py", line 127, in env
environment = build_environment(request, response, session)
  File "/var/www/milo-reloaded/web2py/gluon/compileapp.py", line 375, in
build_environment
t = environment['T'] = translator(request)
  File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 437, in
__init__
self.set_current_languages()
  File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 492, in
set_current_languages
pl_info = self.get_possible_languages_info('default')
  File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 471, in
get_possible_languages_info
info = read_possible_languages(self.folder)
  File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 250, in
read_possible_languages
lambda: read_possible_languages_aux(langdir))
  File "/var/www/milo-reloaded/web2py/gluon/cfs.py", line 40, in getcfs
return filter() if callable(filter) else ''
  File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 250, in

lambda: read_possible_languages_aux(langdir))
  File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 215, in
read_possible_languages_aux
flist = oslistdir(langdir)
OSError: [Errno 2] No such file or directory: 'applications/milo/languages'


the application was named milo, now it's named movish. Any clue?

I'm fixing it easily with a syslink for now.
-- 
Vincenzo Ampolo
http://vincenzo-ampolo.net
http://goshawknest.wordpress.com

-- 





[web2py] Re: scheduler cannot detect correct application name

2012-09-26 Thread Niphlod
it seems a "bug" within languages, not scheduler. 
However - just to be sure - when you restored the db, if there was any 
scheduled_task there? 
If there was, the column "application_name" of the table scheduler_task 
needs to be updated to the new name.

On Thursday, September 27, 2012 12:08:59 AM UTC+2, Vincenzo Ampolo wrote:
>
> Hi, 
>
> I've deployed my application in a server, in the meantime I also changed 
> the application name. 
>
> To do so I installed web2py, then created a new application using the 
> admin interface and then I copied the content of the directory of the 
> project in the newly created directory. 
> For the db I did a dump and restored on the new server. 
>
> Everything work smooth except the scheduler. When a worker picks up a 
> job it dies with this error: 
>
> Traceback (most recent call last): 
>   File "/var/www/milo-reloaded/web2py/gluon/scheduler.py", line 203, in 
> executor 
> _env = env(a=a,c=c,import_models=True) 
>   File "/var/www/milo-reloaded/web2py/gluon/shell.py", line 127, in env 
> environment = build_environment(request, response, session) 
>   File "/var/www/milo-reloaded/web2py/gluon/compileapp.py", line 375, in 
> build_environment 
> t = environment['T'] = translator(request) 
>   File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 437, in 
> __init__ 
> self.set_current_languages() 
>   File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 492, in 
> set_current_languages 
> pl_info = self.get_possible_languages_info('default') 
>   File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 471, in 
> get_possible_languages_info 
> info = read_possible_languages(self.folder) 
>   File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 250, in 
> read_possible_languages 
> lambda: read_possible_languages_aux(langdir)) 
>   File "/var/www/milo-reloaded/web2py/gluon/cfs.py", line 40, in getcfs 
> return filter() if callable(filter) else '' 
>   File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 250, in 
>  
> lambda: read_possible_languages_aux(langdir)) 
>   File "/var/www/milo-reloaded/web2py/gluon/languages.py", line 215, in 
> read_possible_languages_aux 
> flist = oslistdir(langdir) 
> OSError: [Errno 2] No such file or directory: 
> 'applications/milo/languages' 
>
>
> the application was named milo, now it's named movish. Any clue? 
>
> I'm fixing it easily with a syslink for now. 
> -- 
> Vincenzo Ampolo 
> http://vincenzo-ampolo.net 
> http://goshawknest.wordpress.com 
>

-- 





Re: [web2py] framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Niphlod

On Thursday, September 27, 2012 12:20:03 AM UTC+2, Massimo Di Pierro wrote:
>
> Are you telling us that under heavy load, trying to generate a new 
> session_id at every request using the os entropy generator (/dev/urandom), 
> results in too many files open, causes tickets, and this produces the 
> apparent slow down? 
>
> What do you suggest?
>
>  
this is not the case within uwsgino errors show up. For production 
sites handling a lot concurrent requests rocket is not recommended.

Commenting out the part generating request.uuid on main.py was part of "the 
hack" for case 5). Just commenting that turned out in a ~50 reqs/sec more 
capability. The big "speed bump" (~400 reqs/sec more) is removing all the 
session logic.
 

-- 





Re: [web2py] Re: scheduler cannot detect correct application name

2012-09-26 Thread Vincenzo Ampolo
On 09/26/2012 03:29 PM, Niphlod wrote:
> it seems a "bug" within languages, not scheduler.
> However - just to be sure - when you restored the db, if there was any
> scheduled_task there?
> If there was, the column "application_name" of the table scheduler_task
> needs to be updated to the new name.

No, there weren't.

This happens on newly scheduled tasks. It seems that the name of the
application is stored somewhere and I cannot figure it out...



-- 
Vincenzo Ampolo
http://vincenzo-ampolo.net
http://goshawknest.wordpress.com

-- 





Re: [web2py] framework benchmarks - web2py surprisingly slow?

2012-09-26 Thread Michele Comitini
I confirm that is a rocket issue.  After a while it starts leaving CLOSE
WAIT sockets around until consuming all available file handles.

mic

2012/9/27 Niphlod 

>
> On Thursday, September 27, 2012 12:20:03 AM UTC+2, Massimo Di Pierro wrote:
>>
>> Are you telling us that under heavy load, trying to generate a new
>> session_id at every request using the os entropy generator (/dev/urandom),
>> results in too many files open, causes tickets, and this produces the
>> apparent slow down?
>>
>> What do you suggest?
>>
>>
> this is not the case within uwsgino errors show up. For production
> sites handling a lot concurrent requests rocket is not recommended.
>
> Commenting out the part generating request.uuid on main.py was part of
> "the hack" for case 5). Just commenting that turned out in a ~50 reqs/sec
> more capability. The big "speed bump" (~400 reqs/sec more) is removing all
> the session logic.
>
>
> --
>
>
>
>

-- 





[web2py] potential problem w db.executesql(sql) not updating table when done during onvalidation process

2012-09-26 Thread Adi

My apology if a description of the problem is not concise enough. I am 
updating record during onvalidaiton process, and this worked until Sep 17. 
Anything is possible, but I don't remember changing any code in this area.

When I run the same SQL statement manually, or from a test procedure, 
everything works fine, but not when it's executed through SQLFORM 
onvalidation process. I tried adding db.commit() and that didn't help, 
either. 

Finally, I added following query at the end, and then record got updated: 
row = db(Order.id==session.order_id).select().first()

My problem seems to be solved for now, but not sure what is a real cause of 
the problem, and if something needs correction in executesql? 

Simplified code:

def db_encrypt_cc(tbl=None, cc=None, id=None):
TOKEN='cd7358801fd5db53d74b038b7b97a6c4'
sql = "UPDATE %s SET CCnr_secure = AES_ENCRYPT('%s', '%s') WHERE id=%s" 
% (tbl, cc, TOKEN, session.order_id)
# when executed, this statement is correct, but no value gets updated 
in the table: UPDATE order SET CCnr_secure = 
AES_ENCRYPT('4111', 'cd7358801fd5db53d74b038b7b97a6c4') 
WHERE id=10423
db.executesql(sql)
# added code bellow and only then record got updated
row = db(Order.id==session.order_id).select().first()
return

def cc_validation(form):
form.vars.CCnr_secure = db_encrypt_cc("order", form.vars.CCnr)
return

def checkout_cc():
form=SQLFORM(Order, record=record, fields=fields, keepvalues=True,showid
=False,
formstyle='divs', submit_button=T('Continue'))

if form.process(keepvalues=True, onvalidation=cc_validation).accepted:
response.flash = T('Payment Information accepted')




-- 





[web2py] Re: potential problem w db.executesql(sql) not updating table when done during onvalidation process

2012-09-26 Thread Adi
forgot to mention db & ver of w2p: 
MySQL + Version 2.0.9 (2012-09-13 23:51:30) stable


On Wednesday, September 26, 2012 8:09:50 PM UTC-4, Adi wrote:
>
>
> My apology if a description of the problem is not concise enough. I am 
> updating record during onvalidaiton process, and this worked until Sep 17. 
> Anything is possible, but I don't remember changing any code in this area.
>
> When I run the same SQL statement manually, or from a test procedure, 
> everything works fine, but not when it's executed through SQLFORM 
> onvalidation process. I tried adding db.commit() and that didn't help, 
> either. 
>
> Finally, I added following query at the end, and then record got updated: 
> row = db(Order.id==session.order_id).select().first()
>
> My problem seems to be solved for now, but not sure what is a real cause 
> of the problem, and if something needs correction in executesql? 
>
> Simplified code:
>
> def db_encrypt_cc(tbl=None, cc=None, id=None):
> TOKEN='cd7358801fd5db53d74b038b7b97a6c4'
> sql = "UPDATE %s SET CCnr_secure = AES_ENCRYPT('%s', '%s') WHERE 
> id=%s" % (tbl, cc, TOKEN, session.order_id)
> # when executed, this statement is correct, but no value gets updated 
> in the table: UPDATE order SET CCnr_secure = 
> AES_ENCRYPT('4111', 'cd7358801fd5db53d74b038b7b97a6c4') 
> WHERE id=10423
> db.executesql(sql)
> # added code bellow and only then record got updated
> row = db(Order.id==session.order_id).select().first()
> return
>
> def cc_validation(form):
> form.vars.CCnr_secure = db_encrypt_cc("order", form.vars.CCnr)
> return
> 
> def checkout_cc():
> form=SQLFORM(Order, record=record, fields=fields, keepvalues=True,showid
> =False,
> formstyle='divs', submit_button=T('Continue'))
>
> if form.process(keepvalues=True, onvalidation=cc_validation).accepted:
> response.flash = T('Payment Information accepted')
>
>
>
>
>

-- 





Re: [web2py] Re: scheduler cannot detect correct application name

2012-09-26 Thread Vincenzo Ampolo
On 09/26/2012 03:29 PM, Niphlod wrote:
> If there was, the column "application_name" of the table scheduler_task
> needs to be updated to the new name.


Curious that new tasks still have the old application_name in
scheduler_task even if I create them like:

db_scheduler.scheduler_task._validate_and_insert(
function_name='import_popular_movies',
args=json.dumps(args),
vars=json.dumps(kwargs),
timeout = 3600,
)
db_scheduler.commit()


-- 
Vincenzo Ampolo
http://vincenzo-ampolo.net
http://goshawknest.wordpress.com

-- 





[web2py] How do you I use geo-spatial types in Web2py DAL?

2012-09-26 Thread Calvin
Hi

I am a big fan of Web2py and would like to use the DAL for capturing 
location specific information. I use MySQL as a back-end and would like to 
understand how I could define a table with MySQL's Spatial Extension data 
types into the DAL and hopefully be able to access this with SQLFORM. For 
instance, how could I get the DAL  to define a field as a WKT point?

Many thanks
Calvin

-- 





[web2py] Manually send confirmation email

2012-09-26 Thread Bruno Codeman
Hi!

I'm creating a custom registration form (my registration form have more 
than one table on db) , but I need to ask the user to confirm by email the 
registration, clicking on a link. I would like to use the web2py native 
feature of sending the email and just let the user log in after click the 
confirmation link. There's any way to do it?


Sorry for my bad english, it's 1:20AM here in Brazil.


Thanks!

-- 





Re: [web2py] Re: How to queue emails with attachments using the Scheduler?

2012-09-26 Thread Martin Weissenboeck
Good idea! I am sorry that I did not find it myself.

2012/9/26 Niphlod 

> everything going to scheduler must be "jsonifiable". Can you use the
> attachment parameters pointing to a physical file (as
> '/yourapp/private/something.png') and in your "send_mail" function retrieve
> the path and initialize an attachment ? A string is definitely
> jsonifiable
> e.g.
> def send_mail(to, subject='None', message='None', attachment=None):
>   attachment = Mail.Attachment(attachment)
>   mail.send(.., attachment)
>
>
>
>

-- 





[web2py] how to avoid an overhead

2012-09-26 Thread Martin Weissenboeck
I have a fundamental question. Let's say I have a function like

def mypage():
form = a_lot_of_calculations_and_db_accesses()
if form.process().accepted:
do_something()
return dict(form=form)

The part a_lot_of_calculations_and_db_accesses() runs twice: first time to
prepare the page and a second time to handle the responses. Is there any
way to avoid these double call of a_lot_of_calculations_and_db_accesses()?

Regards, Martin

--