[web2py] View To Controller, HTML componets

2016-01-05 Thread Carlo Ghilardi
Dear all,
I'm trying to learn Web2py, but I'm having hard time to play with Forms, 
link HTML components like checkbox for instance. I'm not getting how can I 
get from the view to controller the information on the checkbox or Textbox 
or radio button, so in controller I can work with them and generate an 
answer.

So What I'm asking is a tutorial, how web2py can pass from the view to 
controller, and vice-versa. A trivial one.

I've tried to look on google, but people only show sample collecting and 
storing data from the DB.

What I've being looking for, is a view containing some radio buttons and 
depending on witch one is selected I do an action.

A checkbot selected I do an action.

A Textbox, I can seve its value and do something in controller ...



Well sorry for this dumb question, hope you can help me.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: feedback da default.py a web2py

2014-04-18 Thread Carlo DOnofrio
Grazie per il feedback.
Vorrei sapere in cosa sbaglio.
Ho sostituito 

ajax_page('POST', 
'{{=URL('AllegaNuovoFile')}}',['txtIdCarico','pathCompleto'],'target')

al posto di

ajax('{{=URL('AllegaNuovoFile')}}',['txtIdCarico','pathCompleto'],'target')

e in default.py all'interno di
def AllegaNuovoFile():

ho inserito  semplicemente 

response.flash = "Word done!"
ma non sembra più effettuare alcuna operazione.

In cosa sbaglio?




Il giorno lunedì 7 aprile 2014 18:08:04 UTC+2, Massimo Di Pierro ha scritto:

> Si!
>
> Invece di:
> ajax('{{=URL('AllegaNuovoFile')}}',['txtIdCarico','pathCompleto'],'target')
> usa:
> ajax_page('POST', '{{=URL('AllegaNuovoFile')}}',['txtIdCarico','
> pathCompleto'],'target')
>
> and from:
>
> def AllegaNuovoFile():
>...
>response.flash = "Word done!"
># or response.js = "jquery code to be executed upon return. ... 
> "
>return dict()
>
> On Monday, 7 April 2014 04:16:47 UTC-5, Carlo DOnofrio wrote:
>>
>> Salve a tutti,
>>
>> vorrei sapere se è possibile avere un feedback di fine esecuzione 
>> istruzioni della funzione richiamata in default.py. 
>>
>> Mi spiego meglio. Ho creato tutta una serie di pagine html in cui, per 
>> esempio, ho necessità di salvare degli allegati in un database creato in 
>> mysql.
>>
>> All'interno della pagina ho queste istruzioni:
>>
>> 
>> 
>> 
>>  Allega Nuovo File:
>>  
>> > onchange="this.form.pathCompleto.value=this.value.substr(12);">
>>  
>> 
>>
>> > onclick="ControllaNuovoFile(); 
>> ajax('{{=URL('AllegaNuovoFile')}}',['txtIdCarico','pathCompleto'],'target')"/>
>>  
>> 
>>
>>
>>
>> 
>>
>>
>> Che richimano la funzione AllegaNuovoFile presente in default.py:
>>
>> def AllegaNuovoFile():
>> directory = "C:\Upload\\"
>> nomefile = request.vars.pathCompleto
>> riferimentoIdCarico= request.vars.txtIdCarico
>> if (nomefile <> '') :
>> filepercorso = directory + nomefile
>> stream = open(filepercorso,'rb')
>> db.tabella_files.insert(nome_file=nomefile,dati_file=db.tabella_files.dati_file.store(stream,filepercorso),
>>  
>> riferimento_id=riferimentoIdCarico,riferimento_tabella="Carico")
>> db.commit()
>> return dict()
>>
>>
>> C' è un modo per avere un feedback da default.py per avere certezza di 
>> esecuzione funzione?
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: feedback da default.py a web2py

2014-04-18 Thread Carlo DOnofrio
Grazie per la risposta.
Penso di sbagliare nell'esecuzione della procedura consigliata.
Ho provato ad inserire 
ajax_page('POST', '{{=URL('AllegaNuovoFile')}}',['txtIdCarico','
pathCompleto'],'target')
al posto di
ajax('{{=URL('AllegaNuovoFile')}}',['txtIdCarico','pathCompleto'],'target')
 e in  default.py all'interno di def AllegaNuovoFile() ho semplicemente 
aggiunto
response.flash = "Word done!"

Ma sembra non effettuare più alcuna operazione.
In cosa sbaglio?

Grazie per feedback


Il giorno lunedì 7 aprile 2014 11:16:47 UTC+2, Carlo DOnofrio ha scritto:

> Salve a tutti,
>
> vorrei sapere se è possibile avere un feedback di fine esecuzione 
> istruzioni della funzione richiamata in default.py. 
>
> Mi spiego meglio. Ho creato tutta una serie di pagine html in cui, per 
> esempio, ho necessità di salvare degli allegati in un database creato in 
> mysql.
>
> All'interno della pagina ho queste istruzioni:
>
> 
> 
> 
>  Allega Nuovo File:
>  
>  onchange="this.form.pathCompleto.value=this.value.substr(12);">
>  
> 
>
>  onclick="ControllaNuovoFile(); 
> ajax('{{=URL('AllegaNuovoFile')}}',['txtIdCarico','pathCompleto'],'target')"/>
>  
> 
>
>
>
> 
>
>
> Che richimano la funzione AllegaNuovoFile presente in default.py:
>
> def AllegaNuovoFile():
> directory = "C:\Upload\\"
> nomefile = request.vars.pathCompleto
> riferimentoIdCarico= request.vars.txtIdCarico
> if (nomefile <> '') :
> filepercorso = directory + nomefile
> stream = open(filepercorso,'rb')
> db.tabella_files.insert(nome_file=nomefile,dati_file=db.tabella_files.dati_file.store(stream,filepercorso),
>  
> riferimento_id=riferimentoIdCarico,riferimento_tabella="Carico")
> db.commit()
> return dict()
>
>
> C' è un modo per avere un feedback da default.py per avere certezza di 
> esecuzione funzione?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] feedback da default.py a web2py

2014-04-07 Thread Carlo DOnofrio


Salve a tutti,

vorrei sapere se è possibile avere un feedback di fine esecuzione 
istruzioni della funzione richiamata in default.py. 

Mi spiego meglio. Ho creato tutta una serie di pagine html in cui, per 
esempio, ho necessità di salvare degli allegati in un database creato in 
mysql.

All'interno della pagina ho queste istruzioni:




 Allega Nuovo File:
 

 



 







Che richimano la funzione AllegaNuovoFile presente in default.py:

def AllegaNuovoFile():
directory = "C:\Upload\\"
nomefile = request.vars.pathCompleto
riferimentoIdCarico= request.vars.txtIdCarico
if (nomefile <> '') :
filepercorso = directory + nomefile
stream = open(filepercorso,'rb')
db.tabella_files.insert(nome_file=nomefile,dati_file=db.tabella_files.dati_file.store(stream,filepercorso),
 
riferimento_id=riferimentoIdCarico,riferimento_tabella="Carico")
db.commit()
return dict()


C' è un modo per avere un feedback da default.py per avere certezza di 
esecuzione funzione?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Not working for versions >2.2.1

2013-04-28 Thread Carlo Bazzo

thank you Antony, now everything makes sense.

carlo


Il 28/04/2013 20.43, Anthony ha scritto:
Actually, it only appeared to be working prior to 2.2.1. What happened 
with prior versions is that you inadvertently turned off your CSRF 
protection. In earlier versions, session.clear() would completely 
clear the session, so you ended up passing an empty session to 
form.accepts(). Because the session was empty, it skipped the _formkey 
check altogether (just as if you hadn't passed the session in at all).


More recently, the session object was changed so it always includes a 
_session_hash, even after you call session.clear(). So, now if you do 
session.clear() right before calling form.accepts(), it will no longer 
skip the _formkey check, and instead you'll get a failure to pass the 
check (because the _formkey has been removed from the session).


Anthony

On Saturday, April 27, 2013 4:48:44 AM UTC-4, carlo wrote:

Thank you Anthony,

never spotted that error because as I said until version 2.2.1 it
was working anyway, maybe session.clear() did not behave as expected?

Carlo

Il 26/04/2013 18:41, Anthony ha scritto:

At the beginning of the function you clear the session, yet the
form's _formkey is stored in the session. If you pass the session
to form.accepts(), it checks for the _formkey and will not accept
the form if it is not found. This code would not have worked in
any prior version of web2py. Note, you need the session and
_formkey to protect against CSRF attacks (and double submission).

Anthony

On Friday, April 26, 2013 12:26:29 PM UTC-4, carlo wrote:

Hi, a strange problem with the latest version and Python 2.5

This action works fine in version 2.2.1 and before.

Now hitting Submit there is no redirection, the page just
reloads, no errors.

What is the problem? Thank you.




def creanuovo_1():
import datetime
session.clear()

now=datetime.date.today()
now=now.strftime("%d-%m-%Y")

form = SQLFORM(db.preventivi,fields =

['id_clienti','id_agente','compil','data_prev','id_tipo','descriz_est','descriz_br','copie_nom','note'],\
   col3 = {'id_clienti':SPAN("a chi andrà
intestata l'offerta",_style='color:grey'),'compil':SPAN('nome
di chi
compila',_style='color:grey'),'id_tipo':SPAN('descrizione
generica del
prodotto',_style='color:gray'),'descriz_est':SPAN('descrizione per
il cliente',_style='color:gray'),'note':SPAN('eventuali note
aggiuntive',_style='color:gray'),'descriz_br':SPAN('descrizione
per i reparti',_style='color:grey')},submit_button='Avanti')

if form.accepts(request.vars, session, dbio=False):
session.anagrafica=dict(form.vars)
cliente=db(db.clienti.id

<http://db.clienti.id>==session.anagrafica['id_clienti']).select(db.clienti.ragsoc)[0]['ragsoc']
tipo=db(db.tipo_prodotto.id

<http://db.tipo_prodotto.id>==session.anagrafica['id_tipo']).select(db.tipo_prodotto.descriz)[0]['descriz']
session['anagrafica']['cliente']=cliente
session['anagrafica']['tipo']=tipo
session.no_copie_alt=True
redirect(URL('creanuovo_2'))


return dict(form=form)

-- 


---
You received this message because you are subscribed to a topic
in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/web2py/7Qgl-bUBXx4/unsubscribe?hl=en
<https://groups.google.com/d/topic/web2py/7Qgl-bUBXx4/unsubscribe?hl=en>.
To unsubscribe from this group and all its topics, send an email
to web2py+un...@googlegroups.com .
For more options, visit https://groups.google.com/groups/opt_out
<https://groups.google.com/groups/opt_out>.




--

---
You received this message because you are subscribed to a topic in the 
Google Groups "web2py-users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/web2py/7Qgl-bUBXx4/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to 
web2py+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--

--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Not working for versions >2.2.1

2013-04-27 Thread Carlo Bazzo

Thank you Anthony,

never spotted that error because as I said until version 2.2.1 it was 
working anyway, maybe session.clear() did not behave as expected?


Carlo

Il 26/04/2013 18:41, Anthony ha scritto:
At the beginning of the function you clear the session, yet the form's 
_formkey is stored in the session. If you pass the session to 
form.accepts(), it checks for the _formkey and will not accept the 
form if it is not found. This code would not have worked in any prior 
version of web2py. Note, you need the session and _formkey to protect 
against CSRF attacks (and double submission).


Anthony

On Friday, April 26, 2013 12:26:29 PM UTC-4, carlo wrote:

Hi, a strange problem with the latest version and Python 2.5

This action works fine in version 2.2.1 and before.

Now hitting Submit there is no redirection, the page just reloads,
no errors.

What is the problem? Thank you.




def creanuovo_1():
import datetime
session.clear()

now=datetime.date.today()
now=now.strftime("%d-%m-%Y")

form = SQLFORM(db.preventivi,fields =

['id_clienti','id_agente','compil','data_prev','id_tipo','descriz_est','descriz_br','copie_nom','note'],\
   col3 = {'id_clienti':SPAN("a chi andrà
intestata l'offerta",_style='color:grey'),'compil':SPAN('nome di
chi compila',_style='color:grey'),'id_tipo':SPAN('descrizione
generica del
prodotto',_style='color:gray'),'descriz_est':SPAN('descrizione per
il cliente',_style='color:gray'),'note':SPAN('eventuali note
aggiuntive',_style='color:gray'),'descriz_br':SPAN('descrizione
per i reparti',_style='color:grey')},submit_button='Avanti')

if form.accepts(request.vars, session, dbio=False):
session.anagrafica=dict(form.vars)
cliente=db(db.clienti.id

<http://db.clienti.id>==session.anagrafica['id_clienti']).select(db.clienti.ragsoc)[0]['ragsoc']
tipo=db(db.tipo_prodotto.id

<http://db.tipo_prodotto.id>==session.anagrafica['id_tipo']).select(db.tipo_prodotto.descriz)[0]['descriz']
session['anagrafica']['cliente']=cliente
session['anagrafica']['tipo']=tipo
session.no_copie_alt=True
redirect(URL('creanuovo_2'))


return dict(form=form)

--

---
You received this message because you are subscribed to a topic in the 
Google Groups "web2py-users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/web2py/7Qgl-bUBXx4/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to 
web2py+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--

--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Not working for versions >2.2.1

2013-04-26 Thread carlo
Hi, a strange problem with the latest version and Python 2.5

This action works fine in version 2.2.1 and before.

Now hitting Submit there is no redirection, the page just reloads, no 
errors.

What is the problem? Thank you.




def creanuovo_1():
import datetime
session.clear()

now=datetime.date.today()
now=now.strftime("%d-%m-%Y")

form = SQLFORM(db.preventivi,fields = 
['id_clienti','id_agente','compil','data_prev','id_tipo','descriz_est','descriz_br','copie_nom','note'],\
   col3 = {'id_clienti':SPAN("a chi andrà intestata 
l'offerta",_style='color:grey'),'compil':SPAN('nome di chi 
compila',_style='color:grey'),'id_tipo':SPAN('descrizione generica del 
prodotto',_style='color:gray'),'descriz_est':SPAN('descrizione per il 
cliente',_style='color:gray'),'note':SPAN('eventuali note 
aggiuntive',_style='color:gray'),'descriz_br':SPAN('descrizione per i 
reparti',_style='color:grey')},submit_button='Avanti')

if form.accepts(request.vars, session, dbio=False):
session.anagrafica=dict(form.vars)

cliente=db(db.clienti.id==session.anagrafica['id_clienti']).select(db.clienti.ragsoc)[0]['ragsoc']

tipo=db(db.tipo_prodotto.id==session.anagrafica['id_tipo']).select(db.tipo_prodotto.descriz)[0]['descriz']
session['anagrafica']['cliente']=cliente
session['anagrafica']['tipo']=tipo
session.no_copie_alt=True
redirect(URL('creanuovo_2'))
   

return dict(form=form)

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] SQLFORM labels

2013-03-20 Thread Carlo Bazzo

Thank you Anthony,

very interesting solution, not aware of the formstyle parameter which 
looks very powerful.


carlo


Il 20/03/2013 19:46, Anthony ha scritto:
You might consider creating a custom formstyle function, modeled after 
this one 
<https://code.google.com/p/web2py/source/browse/gluon/sqlhtml.py#718>, 
but without including the labels. You could then do SQLFORM(..., 
formstyle=myformstyle), or if you want it to apply to all forms in the 
app, somewhere in a model you could do SQLFORM.formstyles.table3cols = 
myformstyle. The table3cols formstyle is the default, so by changing 
the function associated with it, you will change the default.


Anthony

On Wednesday, March 20, 2013 10:30:44 AM UTC-4, carlo wrote:

Thank you Richard,

I am not sure it is a good idea to render automatic labels in
forms: especially with text areas they are annoying. I would maybe
have preferred to get them the other way round, no labels unless
explicitly declared. But that is just my personal preference,
definitely not a big problem.



Il giorno martedě 19 marzo 2013 23:49:51 UTC+1, Richard ha scritto:

The simpler is what you mention in model :

db.define_talbe(...
Field(..., label=''),
...

You use this snippet to iterrate over your fields :
[ db[request.args(0)][field].label = '' for field in
db[request.args(0)].fields ]

The other solution I see is custom form :

http://web2py.com/books/default/chapter/29/07#Custom-forms
<http://web2py.com/books/default/chapter/29/07#Custom-forms>

And it much more work and not pratical when you modify your
app frequently during developpement because you have to think
about modifying your custom form each time...

Hops it helps




On Tue, Mar 19, 2013 at 1:13 PM, carlo  wrote:

How can I get SQLFORM not showing any label?

I remembered labels=None but it's not working: only way I
found is passing a labels dict with mykey='', not very
practical.

By the way I am replicating the mywiki code from the
manual: it coulf be upgraded because "page" and
"document", from the error I got,  are now reserved keywords.

Carlo
-- 


---
You received this message because you are subscribed to
the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails
from it, send an email to web2py+un...@googlegroups.com.
For more options, visit
https://groups.google.com/groups/opt_out
<https://groups.google.com/groups/opt_out>.



--

---
You received this message because you are subscribed to a topic in the 
Google Groups "web2py-users" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/web2py/WhRSjPn__g0/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to 
web2py+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--

--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] SQLFORM labels

2013-03-20 Thread carlo
Thank you Richard,

I am not sure it is a good idea to render automatic labels in forms: 
especially with text areas they are annoying. I would maybe have preferred 
to get them the other way round, no labels unless explicitly declared. But 
that is just my personal preference, definitely not a big problem.



Il giorno martedì 19 marzo 2013 23:49:51 UTC+1, Richard ha scritto:
>
> The simpler is what you mention in model :
>
> db.define_talbe(...
> Field(..., label=''),
> ...
>
> You use this snippet to iterrate over your fields :
> [ db[request.args(0)][field].label = '' for field in 
> db[request.args(0)].fields ]
>
> The other solution I see is custom form :
>
> http://web2py.com/books/default/chapter/29/07#Custom-forms
>
> And it much more work and not pratical when you modify your app frequently 
> during developpement because you have to think about modifying your custom 
> form each time...
>
> Hops it helps
>
>
>
>
> On Tue, Mar 19, 2013 at 1:13 PM, carlo >wrote:
>
>> How can I get SQLFORM not showing any label?
>>
>> I remembered labels=None but it's not working: only way I found is 
>> passing a labels dict with mykey='', not very practical.
>>
>> By the way I am replicating the mywiki code from the manual: it coulf be 
>> upgraded because "page" and "document", from the error I got,  are now 
>> reserved keywords.
>>
>> Carlo
>>
>> -- 
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] SQLFORM labels

2013-03-19 Thread carlo
How can I get SQLFORM not showing any label?

I remembered labels=None but it's not working: only way I found is passing 
a labels dict with mykey='', not very practical.

By the way I am replicating the mywiki code from the manual: it coulf be 
upgraded because "page" and "document", from the error I got,  are now 
reserved keywords.

Carlo

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Fpdf error with python 2.6 and web2py 2.2.1

2012-11-29 Thread carlo
Found: it seems a problem with 32 bit png files. When converted to 24 bit, 
pdf rendering was ok. Thank you.

Il giorno giovedì 29 novembre 2012 13:45:08 UTC+1, José Luis Redrejo 
Rodríguez ha scritto:
>
> Hi Carlo
> I'm using fpdf without any problem, so I guess the reason is in some of 
> the data you're passing to fpdf.
> The code of the controller would be needed to can lend you a hand.
>
> Regards
>
>
> 2012/11/29 carlo >
>
>> No error with web2py 1.9.4.
>>
>> With 2.2.1 I got this with Python 2.5 and Python 2.6
>>
>>
>> Traceback (most recent call last):
>>   File "C:\Python25\web2py\gluon\restricted.py", line 212, in restricted
>>
>>
>> exec ccode in environment
>>   File "C:/Python25/web2py/applications/Hcontrol/controllers/default.py" 
>> <http://127.0.0.1:8000/admin/default/edit/Hcontrol/controllers/default.py>, 
>> line 1000, in 
>>
>>
>>   File "C:\Python25\web2py\gluon\globals.py", line 188, in 
>>
>>
>> self._caller = lambda f: f()
>>
>>
>>   File "C:/Python25/web2py/applications/Hcontrol/controllers/default.py" 
>> <http://127.0.0.1:8000/admin/default/edit/Hcontrol/controllers/default.py>, 
>> line 558, in pdf_prev
>>
>>
>> pdf.add_page()
>>   File "C:\Python25\web2py\gluon\contrib\fpdf\fpdf.py", line 284, in add_page
>>
>>
>> self.header()
>>   File "C:/Python25/web2py/applications/Hcontrol/controllers/default.py" 
>> <http://127.0.0.1:8000/admin/default/edit/Hcontrol/controllers/default.py>, 
>> line 540, in header
>>
>>
>> self.image(logo,10,8,50)
>>
>>
>>   File "C:\Python25\web2py\gluon\contrib\fpdf\fpdf.py", line 896, in image
>>
>>
>> info=self._parsepng(name)
>>
>>
>>   File "C:\Python25\web2py\gluon\contrib\fpdf\fpdf.py", line 1749, in 
>> _parsepng
>>
>>
>> color += re.sub('(.{3}).',lambda m: m.group(1),line, flags=re.DOTALL)
>>
>> TypeError: sub() got an unexpected keyword argument 'flags'
>>
>>  -- 
>>  
>>  
>>  
>>
>
>

-- 





Re: [web2py] Fpdf error with python 2.6 and web2py 2.2.1

2012-11-29 Thread carlo
Thank you José, this is strange because with 1.9.4 I have no problem.
This is the core part of the function: in the html view I have a link to 
generate the pdf.

## Before I create a table for html rendering
if request.extension=="pdf":
import os
from gluon.contrib.pyfpdf import FPDF, HTMLMixin

# create a custom class with the required functionalities 
class MyFPDF(FPDF, HTMLMixin):

def header(self): 
"hook to draw custom page header"

#logo=os.path.join(request.env.web2py_path,"applications","digitalcosting_3","static","images","g3001.png")

logo=os.path.join(request.env.web2py_path,request.folder,"static","images","g3001.png")
self.image(logo,10,8,50)
self.set_font('Arial','',12)
self.cell(5) # padding
#self.cell(60,10,"Rif. Preventivo n.12",0,0)
self.ln(20)

def footer(self):
"hook to draw custom page header (printing page numbers)"
self.set_y(-15)
self.set_font('Helvetica','I',8)
txt = 'Pagina %s of %s' % (self.page_no(), 
self.alias_nb_pages())
self.cell(0,10,txt,0,0,'C')

pdf=MyFPDF()
pdf.set_top_margin(30)
pdf.set_right_margin(10)
pdf.set_font('times','',12)
# create a page and serialize/render HTML objects
pdf.add_page()
txt="Rif. Preventivo n.%s"%(idprev,)
txt_ana=mypdf[0].daticli
txt_ana2=mycli[0].ragsoc
txt_ana3=mycli[0].indirizzo
txt_ana4=mycli[0].cap+" "+mycli[0].citta
txt_data="Rasai, %s"%(myprev[0].data_prev.strftime("%d-%m-%Y"))
txt_oggetto="Oggetto: "+ mypdf[0].oggetto
txt_testo1=mypdf[0].testo1
txt_testo2=mypdf[0].testo2
txt_testo3=mypdf[0].testo3
txt_testo4=mypdf[0].testo4
consegna=mypdf[0].consegna
pagamento=mypdf[0].pagamento+" "+pagam
foot=mypdf[0].footer
firma=mypdf[0].firma
firma2=mypdf[0].firma2
descrizione=unicode(myprev[0].descriz_est,'utf-8')
descrizione=descrizione.encode('iso-8859-1')
copie=myprev[0].copie_nom
pr1="eur "+splitThousands(mylastprev[0].prezzo_off1)
pr1t="eur "+splitThousands(mylastprev[0].pr_tot)
#copie2=myprev[0].copie_nom2
#pr2="eur "+splitThousands(mylastprev[0].prezzo_off2)
#pr2t="eur "+splitThousands(mylastprev[0].pr_tot2)
#copie3=myprev[0].copie_nom3
#pr3="eur "+splitThousands(mylastprev[0].prezzo_off3)
#pr3t="eur "+splitThousands(mylastprev[0].pr_tot3)
pdf.cell(190,10,txt,0,1)
pdf.cell(190,5,txt_ana,0,1,align="R")
pdf.cell(190,5,txt_ana2,0,1,align="R")
pdf.cell(190,5,txt_ana3,0,1,align="R")
pdf.cell(190,5,txt_ana4,0,1,align="R")
pdf.cell(190,10,txt_data,0,1,align="L")
pdf.cell(190,10,txt_oggetto,0,1,align="L")
pdf.ln(10)
pdf.multi_cell(190,10,txt_testo1,0,align="L")
pdf.ln(5)
pdf.cell(100,10,"Descrizione",1,0,align="C")
pdf.cell(30,10,"Qt Copie",1,0,align="C")
pdf.cell(30,10,"Euro/Copia",1,0,align="C")
pdf.cell(30,10,"Euro Totale",1,2,align="C")
pdf.set_x(110)
pdf.set_font_size(10)
pdf.cell(30,10,copie,0,0,align="C")
pdf.cell(30,10,pr1,0,0,align="C")
pdf.cell(30,10,pr1t,0,1,align="R")
if session.no_copie_alt !=True:
pdf.set_x(110)
pdf.cell(30,10,copie2,0,0,align="C")
pdf.cell(30,10,pr2,0,0,align="C")
pdf.cell(30,10,pr2t,0,1,align="R")
pdf.set_x(110)
pdf.cell(30,10,copie3,0,0,align="C")
pdf.cell(30,10,pr3,0,0,align="C")
pdf.cell(30,10,pr3t,0,1,align="R")
pdf.set_xy(10,145)
pdf.multi_cell(100,10,descrizione,0,align="L")
pdf.set_xy(10,175)
pdf.set_font('times','B',12)
pdf.cell(190,5,txt_testo2,0,1,align="C")
pdf.cell(190,5,txt_testo3,0,1,align="C")
pdf.cell(190,5,txt_testo4,0,1,align="C")
pdf.ln(5)
pdf.set_font('times','',12)
pdf.cell(190,10,consegna,0,1,align="L")
pdf.cell(190,10,pagamento,0,1,align="L")
pdf.multi_cell(190,1

[web2py] Fpdf error with python 2.6 and web2py 2.2.1

2012-11-29 Thread carlo


No error with web2py 1.9.4.

With 2.2.1 I got this with Python 2.5 and Python 2.6

Traceback (most recent call last):
  File "C:\Python25\web2py\gluon\restricted.py", line 212, in restricted
exec ccode in environment
  File "C:/Python25/web2py/applications/Hcontrol/controllers/default.py" 
, 
line 1000, in 
  File "C:\Python25\web2py\gluon\globals.py", line 188, in 
self._caller = lambda f: f()
  File "C:/Python25/web2py/applications/Hcontrol/controllers/default.py" 
, 
line 558, in pdf_prev
pdf.add_page()
  File "C:\Python25\web2py\gluon\contrib\fpdf\fpdf.py", line 284, in add_page
self.header()
  File "C:/Python25/web2py/applications/Hcontrol/controllers/default.py" 
, 
line 540, in header
self.image(logo,10,8,50)
  File "C:\Python25\web2py\gluon\contrib\fpdf\fpdf.py", line 896, in image
info=self._parsepng(name)
  File "C:\Python25\web2py\gluon\contrib\fpdf\fpdf.py", line 1749, in _parsepng
color += re.sub('(.{3}).',lambda m: m.group(1),line, flags=re.DOTALL)
TypeError: sub() got an unexpected keyword argument 'flags'

-- 





[web2py] fpdf error?

2012-11-28 Thread carlo
I got:


Traceback (most recent call last):
  File "C:\Python26\web2py\gluon\restricted.py", line 212, in restricted
exec ccode in environment
  File "c:/Python26/web2py/applications/Hcontrol/controllers/default.py" 
, 
line 1000, in 
  File "C:\Python26\web2py\gluon\globals.py", line 188, in 
self._caller = lambda f: f()
  File "c:/Python26/web2py/applications/Hcontrol/controllers/default.py" 
, 
line 558, in pdf_prev
pdf.add_page()
  File "C:\Python26\web2py\gluon\contrib\fpdf\fpdf.py", line 284, in add_page
self.header()
  File "c:/Python26/web2py/applications/Hcontrol/controllers/default.py" 
, 
line 540, in header
self.image(logo,10,8,50)
  File "C:\Python26\web2py\gluon\contrib\fpdf\fpdf.py", line 896, in image
info=self._parsepng(name)
  File "C:\Python26\web2py\gluon\contrib\fpdf\fpdf.py", line 1749, in _parsepng
color += re.sub('(.{3}).',lambda m: m.group(1),line, flags=re.DOTALL)
TypeError: sub() got an unexpected keyword argument 'flags'


Does fpdf require Python >2.6 ?  Until web2py 1.94.5 the same code worked.

-- 





[web2py] error in Book: Setting up email

2012-05-17 Thread carlo
Maybe someone else already posted about it but where the Book says:

"You need to replace the mail.settings with the proper parameters for your 
SMTP server. Set mail.settings.login=False if the SMTP server does not 
require authentication."

I think it should be: mail.settings.login=None, because if set to False you 
get the error:

WARNING:web2py:Mail.send failure:'bool' object has no attribute 'split'

carlo


[web2py] Re: Web Development Introduction Based On Web2py

2011-12-21 Thread carlo
this is remarkable! I hope  to see next chapters very soon..thank you


[web2py] Re: book 4th edition in PDF

2011-12-19 Thread carlo
Is the pdf the same as the printed Lulu version?
Interested with the epub version for my ereader though, thank you Massimo


[web2py] Re: Web2py - the "one-man-band" of all python frameworks :)

2011-05-12 Thread carlo
..and btw Unbit is one of the best hosting solution for web2py
players!

carlo

On 12 Mag, 15:40, Massimo Di Pierro 
wrote:
> There is always something to learn here. :-)
>
> On May 12, 12:09 am, "Roberto De Ioris"  wrote:
>
>
>
>
>
>
>
> > > On Thu, May 12, 2011 at 2:00 AM, Roberto De Ioris 
> > > wrote:
>
> > >> You have to read it in the rock/heavy metal way, where Web2Py is the
> > >> talented player that can manage every intrument,
>
> > >http://en.wikipedia.org/wiki/Ayreon
>
> > Exactly :)
>
> > --
> > Roberto De Iorishttp://unbit.it


[web2py] Re: some new cool stuff in trunk under testing

2011-05-05 Thread carlo
what a great work!

I just want to thank all developers for this wonderful framework which
is improving weekly: I can not understand why big media publishers are
still ignoring web2py and not aware about its growing user base.

carlo

On May 4, 11:09 pm, Massimo Di Pierro  wrote:
> Hello everybody
>
> Jonathan and I have been working on an internal web2py rewrite that while 
> keeping everything backward compatible will allow you to do this
>
>  modules/mymodule.py
> from gluon import *
> def f(): return DIV(A(current.request.function,_href=URL()))
>  end
>
>  default/controller.py
> def index():
>     from mymodule import f
>     return dict(div=f())
>  end
>
> Thanks to Pierre we can now import modules from the app local folder without 
> local_import and thanks to Jonathan those modules only need to do "from gluon 
> import *" to see everything web2py has to offer. This should make life easier 
> for Eclipse users too.
>
> In models/db.py you no longer need to pass globals() to Auth
>
>    auth=Auth(globals(),db)
> or
>    auth=Auth(db)
>
> both work.
>
> Also error messages in validators (including default error messages) should 
> not be by T(...) by default.
>
> This is now in trunk but we are still working on it. This means trunk may not 
> very stable for the next day or two.
> Meanwhile help us test it. In particular help us test if we are breaking your 
> apps.
>
> Massimo


[web2py] Re: component and jquery lightbox

2011-04-07 Thread carlo
as I said, reading the download method code I realized what you are
meaning.
Never heard of the retrieve method before and you said it is a FAQ:
shame on me!

As you stated, if not in the FAQ this should definitely go in the
Book!

Thank you again!
carlo

On 7 Apr, 14:48, selecta  wrote:
> i am also not sure what you exactly mean, but guessing from the fact
> that you have a table with an upload field the code above would work
> for that
> here is a more complete example
>
> db.define_table('mytable', Field('myfield','upload'))
> db.mytable.insert(myfield = db.mytable.myfield.store(open('/etc/
> issue'), 'issue file'))
> #this is done somewhere in the background when a form is processed so
> 'issue file' would be the original file name in that case
>
> record = db.mytable[1]
> filename, file = db.mytable.myfile.retrieve(record.myfile)
> print A(filename, _href = URL(request.application, 'default',
> 'download', args = record.myfile))
>
> it returns
> issue file
>
> so you have the original file name and the name under which it is
> stored? what other original file name would you need?
>
> On Apr 7, 1:53 pm, carlo  wrote:
>
> > mmh, thank you Selecta but I think I did not understand that.
> > Could you point me to one of the past posts?
> > I do not want to store the original filename in my table, just to get
> > the decoded original filename (the one used by the download function
> > to set the disposition header).
> > I do not think your solution addresses that but maybe I am wrong
> > sorry.
>
> > On 7 Apr, 13:24, selecta  wrote:
>
> > > record = db.mytable[1]
> > > filename, file = db.mytable.myfile.retrieve(record.myfile)
> > > A('%s'%filename, _href = URL(request.application, 'default',
> > > 'download', args = record.myfile))
>
> > > i read the answer on this mailing list and i provided it to others
> > > like 50 times, this should go into the FAQ of web2py
>
>


[web2py] Re: component and jquery lightbox

2011-04-07 Thread carlo
after skipping through the download method code I grasped your
suggestion! Thank you

On 7 Apr, 13:53, carlo  wrote:
> mmh, thank you Selecta but I think I did not understand that.
> Could you point me to one of the past posts?
> I do not want to store the original filename in my table, just to get
> the decoded original filename (the one used by the download function
> to set the disposition header).
> I do not think your solution addresses that but maybe I am wrong
> sorry.
>
> On 7 Apr, 13:24, selecta  wrote:
>
> > record = db.mytable[1]
> > filename, file = db.mytable.myfile.retrieve(record.myfile)
> > A('%s'%filename, _href = URL(request.application, 'default',
> > 'download', args = record.myfile))
>
> > i read the answer on this mailing list and i provided it to others
> > like 50 times, this should go into the FAQ of web2py
>
>


[web2py] Re: component and jquery lightbox

2011-04-07 Thread carlo
mmh, thank you Selecta but I think I did not understand that.
Could you point me to one of the past posts?
I do not want to store the original filename in my table, just to get
the decoded original filename (the one used by the download function
to set the disposition header).
I do not think your solution addresses that but maybe I am wrong
sorry.

On 7 Apr, 13:24, selecta  wrote:
> record = db.mytable[1]
> filename, file = db.mytable.myfile.retrieve(record.myfile)
> A('%s'%filename, _href = URL(request.application, 'default',
> 'download', args = record.myfile))
>
> i read the answer on this mailing list and i provided it to others
> like 50 times, this should go into the FAQ of web2py


[web2py] component and jquery lightbox

2011-04-07 Thread carlo
I have images in a component where I applied a lightbox jquery effect,
images paths are stored in a table.

No problem here, in my load view I put:

{{=A(IMG(_src=URL('download',args=mysession.image),_width="400px"),\
_href=URL('download',args=mysession.image)) }}

and in my callback function I have:

response.js="$('a').lightBox()"

But I would like to have the lightbox box caption set to the original
image file name and not the names you retrieve from the uploads
folder. I would find impractical to store the original image file name
in the database table just for this trivial purpose.

How can I retrieve the image original name as decoded ( I supposed) by
response.download?

thank you
carlo


[web2py] Re: components and sessions

2011-03-29 Thread carlo
wow! I would never have thought about the missing space while the
extra curly brace was a typo in my post, thank you!

On 29 Mar, 16:48, Massimo Di Pierro 
wrote:
> The problem is that
>
> {{session.mysession={}}}
> {{session.mysession['mylabel']=comment.body}}}
>
> should be
>
> {{session.mysession={} }} # missing space
> {{session.mysession['mylabel']=comment.body}} # too many }
>
> On Mar 29, 3:11 am, carlo  wrote:
>
> > Massimo, I omitted a test case because it seems occurring in any of my
> > components and it can easily reproduced.
>
> > Here using the component example in the Book (modified a bit):
>
> > model:
>
> > db.define_table('comment',
> >    Field('body','text',label='Your comment'),
> >    Field('posted_on','datetime',default=request.now))
> > db.comment.posted_on.writable=db.comment.posted_on.readable=False
>
> > controller:
>
> > def index():
>
> >     return dict()
>
> > def post():
> >     return dict(form=crud.create(db.comment),
> >                 comments=db(db.comment.id>0).select())
>
> > views:
> > default/post.load:
>
> > {{for comment in comments:}}
> > 
> >   on {{=comment.posted_on}}
> >   says {{=comment.body}}
> > 
> > {{pass}}
> > {{session.mysession={}}}
> > {{session.mysession['mylabel']=comment.body}}}
> > {{=form}}
>
> > default/index.html:
>
> > {{extend 'layout.html'}}
> > {{=LOAD('default','post.load',ajax=True)}}
>
> > This is part of the ticket:
>
> > Traceback (most recent call last):
> >   File "E:\Python26\web2py\gluon\restricted.py", line 186, in
> > restricted
> >     ccode = compile2(code,layer)
> >   File "E:\Python26\web2py\gluon\restricted.py", line 173, in compile2
> >     return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
> > 'exec')
> >   File "E:\Python26\web2py\applications\test/views\default/post.load",
> > line 11
> >     session.mysession['mylabel']=comment.body
> >           ^
> > SyntaxError: invalid syntax
>
> > But if you change the component post.load as:
>
> > {{for comment in comments:}}
> > 
> >   on {{=comment.posted_on}}
> >   says {{=comment.body}}
> > 
> > {{pass}}
> > {{session.mysession=""}}
> > {{session.mysession=comment.body}}
> > {{=form}}
>
> > This is working.
>
> > carlo
>
> > On 29 Mar, 01:22, Massimo Di Pierro 
> > wrote:
>
> > > what do you mean by "fails" can you provide a test case?
>
> > > On Mar 28, 5:15 pm, carlo  wrote:
>
> > > > I have a behaviour I can not explain.
>
> > > > In a controller this is a regular syntax:
>
> > > > session.mysession={}
> > > > session.mysession['myfield']=myvalue
>
> > > > but in a .load component the same fails.
>
> > > > On the other side:
>
> > > > session.simplevalue=myvalue
>
> > > > works with no problem even in components.
>
> > > > Does anyone has an explanation?
>
> > > > carlo
>
>


[web2py] Re: components and sessions

2011-03-29 Thread carlo
Massimo, I omitted a test case because it seems occurring in any of my
components and it can easily reproduced.

Here using the component example in the Book (modified a bit):

model:

db.define_table('comment',
   Field('body','text',label='Your comment'),
   Field('posted_on','datetime',default=request.now))
db.comment.posted_on.writable=db.comment.posted_on.readable=False

controller:

def index():

return dict()

def post():
return dict(form=crud.create(db.comment),
comments=db(db.comment.id>0).select())

views:
default/post.load:

{{for comment in comments:}}

  on {{=comment.posted_on}}
  says {{=comment.body}}

{{pass}}
{{session.mysession={}}}
{{session.mysession['mylabel']=comment.body}}}
{{=form}}

default/index.html:

{{extend 'layout.html'}}
{{=LOAD('default','post.load',ajax=True)}}

This is part of the ticket:

Traceback (most recent call last):
  File "E:\Python26\web2py\gluon\restricted.py", line 186, in
restricted
ccode = compile2(code,layer)
  File "E:\Python26\web2py\gluon\restricted.py", line 173, in compile2
return compile(code.rstrip().replace('\r\n','\n')+'\n', layer,
'exec')
  File "E:\Python26\web2py\applications\test/views\default/post.load",
line 11
session.mysession['mylabel']=comment.body
  ^
SyntaxError: invalid syntax


But if you change the component post.load as:

{{for comment in comments:}}

  on {{=comment.posted_on}}
  says {{=comment.body}}

{{pass}}
{{session.mysession=""}}
{{session.mysession=comment.body}}
{{=form}}

This is working.

carlo




On 29 Mar, 01:22, Massimo Di Pierro 
wrote:
> what do you mean by "fails" can you provide a test case?
>
> On Mar 28, 5:15 pm, carlo  wrote:
>
> > I have a behaviour I can not explain.
>
> > In a controller this is a regular syntax:
>
> > session.mysession={}
> > session.mysession['myfield']=myvalue
>
> > but in a .load component the same fails.
>
> > On the other side:
>
> > session.simplevalue=myvalue
>
> > works with no problem even in components.
>
> > Does anyone has an explanation?
>
> > carlo
>
>


[web2py] components and sessions

2011-03-28 Thread carlo
I have a behaviour I can not explain.

In a controller this is a regular syntax:

session.mysession={}
session.mysession['myfield']=myvalue

but in a .load component the same fails.

On the other side:

session.simplevalue=myvalue

works with no problem even in components.

Does anyone has an explanation?

carlo


[web2py] Re: Is it possible to update or insert object to database in one command?

2011-03-25 Thread carlo
This is the kind of thing I would love to find in a handy Web2py
Cookbook!

carlo

On 24 Mar, 14:27, Massimo Di Pierro 
wrote:
> You can do it without if as well:
>
> db(query).update(...) or db.mytable.insert(...)
>
> On Mar 24, 8:26 am, Massimo Di Pierro 
> wrote:
>
> > To know if it exist or not you must have condition in the form of a
> > query. You can do
>
> > if not db(query).update(...): db.mytable.insert(...)
>
> > where ... is the field='value' list.
>
> > On Mar 24, 4:46 am, Sergey Ozhigin  wrote:
>
> > > Hello,
>
> > > Is it possible in web2py to update or insert object (if doesn't exist)
> > > to database in one command?
>
> > > Does anybody know an answer?
>
> > > wbr
>
>


[web2py] Re: Components and session: forbidden?

2011-03-10 Thread carlo
sorry my fault.

You can have:
session.mysession=total

you can not have:
session.mysession=tot1+tot2+tot3



On 10 Mar, 15:42, carlo  wrote:
> I tried to set a session in a component "post.load" and I receive a
> "RestrictedError" Ticket.
>
> Why you can not have a new session set in a component?
>
> Thank you
>
> carlo


[web2py] Components and session: forbidden?

2011-03-10 Thread carlo
I tried to set a session in a component "post.load" and I receive a
"RestrictedError" Ticket.

Why you can not have a new session set in a component?

Thank you

carlo


[web2py] represent and compute examples?

2011-03-06 Thread carlo
Working with web2py again after some time, I got acknowledged of the
"represent" and "compute" attributes in DAL. They both seem very
attractive to me but I would like to see some more examples of their
usage because of the spare description in the book. Anyone could help?

btw, I found out the great utility of components, brilliant!

carlo


[web2py] EuroPython in Florence

2011-02-07 Thread carlo
Massimo, any plans to attend?


[web2py] Re: web2py on free hosting with no shell or httpd.conf access

2011-01-28 Thread carlo
In general if you have wsgi, you need just to set wsgihandler.py
(without extension in some implementations) as your startup script,
supposed you have Python 2.5 or 2.6 of course.
But you should look into your hosting instructions about configuring a
wsgi application in their environment.

On 28 Gen, 08:54, Leon  wrote:
> Hi, I got interested in web2py after seeing the no install/
> configuration comment on the web2py homepage. Is it possible to copy
> the web2py folder to a free hosting account and somehow get up and
> running?
> The account I currently have has python (but only able to execute
> python files with .cgi extension) and mod_wsgi. My account doesn't
> have shell access or access to httpd.conf though.
>
> So is this possible to do?
>
> Thanks.


[web2py] Re: TAG name and XML: maybe a solution?

2011-01-17 Thread carlo
Massimo, it works. I will post a link to my web2py app which converts
Excel worksheets in xml files as soon as published.

Now I am just curious to look into your changes in html.py..Thanks

carlo

On 17 Gen, 17:33, Massimo Di Pierro 
wrote:
> check trunk, please. I did it but a little differently.
>
> On Jan 17, 9:39 am, carlo  wrote:
>
> > As in my previous post, TAG with its xml serializer fails when both
> > tag Name and Contents are unicode strings with non ascii chars.
>
> > What about this trivial solution in html.py?
>
> > def xml(self):
> >         """
> >         generates the xml for this component.
> >         """
>
> >         (fa, co) = self._xml()
>
> >         if not self.tag:
> >             return co
>
> >         if self.tag[-1:] == '/':
> >             # 
> >             #should encode this as well
> >             return '<%s%s />' % (self.tag[:-1], fa)
>
> >         # else:   inner components xml 
> >         #explicitly encoding self.tag
> >         return '<%s%s>%s' % ((self.tag).encode('utf-8'), fa, co,
> > (self.tag).encode('utf-8'))
>
> > In my test code this is ok but I do not know if it breaks something
> > else.
>
> > Another thing I noticed is that even HTML attributes like
> > u'some_non_ascii_chars'  breaks _validate()..but this is a story much
> > more complex than the TAG problem.
>
>


[web2py] TAG name and XML: maybe a solution?

2011-01-17 Thread carlo
As in my previous post, TAG with its xml serializer fails when both
tag Name and Contents are unicode strings with non ascii chars.

What about this trivial solution in html.py?

def xml(self):
"""
generates the xml for this component.
"""

(fa, co) = self._xml()

if not self.tag:
return co

if self.tag[-1:] == '/':
# 
#should encode this as well
return '<%s%s />' % (self.tag[:-1], fa)

# else:   inner components xml 
#explicitly encoding self.tag
return '<%s%s>%s' % ((self.tag).encode('utf-8'), fa, co,
(self.tag).encode('utf-8'))

In my test code this is ok but I do not know if it breaks something
else.

Another thing I noticed is that even HTML attributes like
u'some_non_ascii_chars'  breaks _validate()..but this is a story much
more complex than the TAG problem.


[web2py] TAG and xml

2011-01-17 Thread carlo
I am trying to relaunch a question implicit in one of my previous
posts. As I said TAG with its xml() serializer fails in generating
valid xml when both name and value are unicode strings with non ascii
chars (in my test it succeeds when either name or value is unicode
string with non ascii chars).

Reading the code I was not able to figure out what is the real problem
with this issue: I would ask some more involved web2py developers to
point this out and highlight which would be the issues in tackling
with this limitation.

 Thank you


[web2py] Re: issue with TAG and unicode

2011-01-16 Thread carlo
I am with you and I think would be useful, TAG would be so useful with
XML. Actually skimming the code I could not find where the quirk is.
Additionally I see that unicode TAG names are indeed supported some
way:

>>> name=u'là'
>>> value='plain'
>>> TAG[name](value).xml()
u'plain'

Even value can be unicode but only with ASCII chars:

>>> name=u'là'
>>> value=u'plain'
>>> TAG[name](value).xml()
u'plain'

Problems arise when both name and values are not ascii chars:

>>> name=u'là'
>>> value=u'parà'
>>> TAG[name](value).xml()
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python26\web2py\gluon\html.py", line 790, in xml
return '<%s%s>%s' % (self.tag, fa, co, self.tag)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
3: ordinal
not in range(128)


On 16 Gen, 23:30, Jonathan Lundell  wrote:
> On Jan 16, 2011, at 2:00 PM, carlo wrote:
>
>
>
> >> Leave the tag itself a plain string.
>
> > don't you think this is a hard constraint?
> > Personally I do.
>
> > TAG promised to be such a handy tool to generate XML from Excel data,
> > which is the purpose of my app, but unfortunately this will not be
> > true.
>
> I suspect that TAG (and pretty much all of the stuff in gluon.html) was 
> intended for html rather than xml. I wouldn't think it'd be too hard to 
> support unicode tags, maybe with an option argument.


[web2py] Re: issue with TAG and unicode

2011-01-16 Thread carlo
> Leave the tag itself a plain string.

don't you think this is a hard constraint?
Personally I do.

TAG promised to be such a handy tool to generate XML from Excel data,
which is the purpose of my app, but unfortunately this will not be
true.


[web2py] Re: issue with TAG and unicode

2011-01-16 Thread carlo
> Leave the tag itself a plain string.

don't you think this is a hard constraint?
Personally I do.

I thought TAG was a great tool to generate xml easily from Excel data
replacing the "oversized" ElementTree but unfortunately this will not
be possible.


[web2py] Re: issue with TAG and unicode

2011-01-16 Thread carlo
>>> r=TAG['pippo'](u'plutò')
>>> str(r)
'plut\xc3\xb2'
>>> r=TAG[u'pippo'](u'plutò')
>>> str(r)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python26\web2py\gluon\html.py", line 797, in __str__
return self.xml()
  File "C:\Python26\web2py\gluon\html.py", line 790, in xml
return '<%s%s>%s' % (self.tag, fa, co, self.tag)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
4: ordinal
not in range(128)




[web2py] Re: issue with TAG and unicode

2011-01-15 Thread carlo
ok narrowed down the problem, this IS working:

def index():
response.headers['Content-Type']='application/xml'
rows=[['6.0', u'pap\xe0', u'kloiuy', '1995.0']]
return export_xml(rows)


def export_xml(rows):
colnames=['prima','seconda','terza','quarta']
idx=range(len(colnames))
records=[]
for row in rows: records.append(TAG['record'](*[TAG[colnames[i]]
(row[i]) for i in idx]))
return str(TAG['records'](*records))

but this IS NOT working with Unicode error etc etc:

def index():
response.headers['Content-Type']='application/xml'
rows=[['6.0', u'pap\xe0', u'kloiuy', '1995.0']]
return export_xml(rows)


def export_xml(rows):
colnames=[u'prima',u'seconda',u'terza',u'quarta']
idx=range(len(colnames))
records=[]
for row in rows: records.append(TAG['record'](*[TAG[colnames[i]]
(row[i]) for i in idx]))
return str(TAG['records'](*records))


so the problem is with tag names..I will try to have a look at html.py
but your opinion is welcome.

carlo


[web2py] Re: issue with TAG and unicode

2011-01-15 Thread carlo
Another example, same strange error:

File "C:\Python25\web2py\gluon\html.py", line 790, in xml
return '<%s%s>%s' % (self.tag, fa, co, self.tag)

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
3: ordinal not in range(128)

Variables
fa  ''
self
self.tagu'titolo'
co  'pap\xc3\xa0'



[web2py] issue with TAG and unicode

2011-01-15 Thread carlo
I have this code:

myrows=[]
for r in range(riga+1,nrows):
myrow=[]
for c in range(ncols):
cell=mysheet.cell_value(r,c) ##reading some text, cell is
unicode object
myrow.append(cell)

myrows.append(myrow)

idx=range(len(colnames))  ##colnames=['label1','label2','label3']
colnames=[item.replace('.','_') for item in colnames]
records=[]

for row in myrows: records.append(TAG['item'](*[TAG[colnames[i]]
(row[i]) for i in idx]))
response.headers['Content-Type']='application/xml'
return str(TAG['root'](*records))


As commented above cell is unicode object so myrows is a list of lists
of unicode objects.

If cell is an ascii char everything is ok; if it is not I get:

Traceback (most recent call last):
  File "C:\Python26\web2py\gluon\restricted.py", line 188, in
restricted
exec ccode in environment
  File "c:/Python26/web2py/applications/xcel2xml/controllers/
default.py", line 334, in 
  File "C:\Python26\web2py\gluon\globals.py", line 95, in 
self._caller = lambda f: f()
  File "c:/Python26/web2py/applications/xcel2xml/controllers/
default.py", line 255, in step44
return gen_xml(nomefile,riga,images)
  File "c:/Python26/web2py/applications/xcel2xml/controllers/
default.py", line 296, in gen_xml
return str(TAG['root'](*records))
  File "C:\Python26\web2py\gluon\html.py", line 797, in __str__
return self.xml()
  File "C:\Python26\web2py\gluon\html.py", line 780, in xml
(fa, co) = self._xml()
  File "C:\Python26\web2py\gluon\html.py", line 771, in _xml
self.components])
  File "C:\Python26\web2py\gluon\html.py", line 110, in xmlescape
return data.xml()
  File "C:\Python26\web2py\gluon\html.py", line 780, in xml
(fa, co) = self._xml()
  File "C:\Python26\web2py\gluon\html.py", line 771, in _xml
self.components])
  File "C:\Python26\web2py\gluon\html.py", line 110, in xmlescape
return data.xml()
  File "C:\Python26\web2py\gluon\html.py", line 790, in xml
return '<%s%s>%s' % (self.tag, fa, co, self.tag)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
5: ordinal not in range(128)

>From Inspect Attributes:
args=   ('ascii', 'label\xc3\xa0', 5, 6, 'ordinal not in range(128)')

And from Variables:

Variables
fa  ''
self
self.tagu'label'
co  'label\xc3\xa0'
args('ascii', 'label\xc3\xa0', 5, 6, 'ordinal not in range(128)')

the string raising the error is "labelà" and I see from Variables that
it was encoded in utf-8 by xml I think.

The original string was "label\xe0" (as I said a unicode string).

Any suggestion? This is driving me crazy..thank you

carlo


[web2py] Storing the Original Filename in the official web2py book

2011-01-12 Thread carlo
def display_form():
record = db.person(request.args(0)) or redirect(URL('index'))
url = URL('download')
form = SQLFORM(db.person, record, deletable=True,
   upload=url, fields=['name', 'image'])
if request.vars.image!=None:
form.vars.image_filename = request.vars.image.filename
if form.accepts(request.vars, session):
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)

I think:

if request.vars.image!=None ## always True

should be

if request.vars.image


carlo


[web2py] Re: new features and new book sections/chapters

2010-09-10 Thread carlo
Hi Massimo,

I bought the new edition and you made the usual great job. Just one
thing: I can not find the "uploadfolder" parameter in the Field specs
while it is present in the online edition..thanks

On 16 Ago, 06:11, mdipierro  wrote:
> Or this:
>
> http://stores.lulu.com/web2py
>
> On 16 Ago, 06:10, mdipierro  wrote:
>
> > There is a problem from lulu. It seems that it does not show the same
> > items to different users. For example now I am using somebody else
> > computer from Italy and no web2py book is listed at all.
>
> > If you look for the item directly it is there:
>
> >http://www.lulu.com/product/a-copertina-morbida/web2py-%283rd-edition...
>
> > On 6 Ago, 20:29, olifante  wrote:
>
> > > Web2py is getting more impressive by the day, and it's great that the
> > > documentation is even better now. Unfortunately, the PDF on sale at
> > > Lulu.com is apparently still the old 2nd edition. Is there any way to
> > > get or buy a PDF of the current draft of the 3rd edition?
>
> > > The tech book industry is increasingly making draft versions of books
> > > available for comment and for purchase as soon as possible, e.g.
>
> > > PragProg Beta 
> > > Books:http://pragprog.com/frequently-asked-questions/beta-books
> > > O'Reilly Open Feedback Publishing System:http://labs.oreilly.com/ofps.html
> > > Manning Early Access Program:http://www.manning.com/about/meap.html
>
> > > Why not do the same with the web2py book, instead of forcing eager
> > > buyers to wait until the final version of the 3rd edition is
> > > finished?
>
> > > Also, many people now prefer to do all their technical reading in
> > > ebook format, so making the book available in .mobi and .epub formats
> > > as well as in pdf would be a smart move.
>
> > > Finally, even though I personally can see the value of paying $12.50
> > > for the current version of the web2py book (if it was available, which
> > > is not the case), many people can't or won't. I really feel that the
> > > fact that the PDF version of the book isn't available for free hampers
> > > adoption of web2py. Good as web2py is, the truth is that Django
> > > dominates in terms of users and mindshare in the Python community. If
> > > you want to change that, giving the book away couldn't hurt.
>
> > > Web2py is obviously a labour of love, and I can't imagine that you get
> > > more than meager earnings from the PDF sales at Lulu.com. Obviously,
> > > everybody has to pay the bills, but you can probably earn more from
> > > consulting work if web2py became more popular than you ever will from
> > > the PDF sales.
>
> > > Thanks for all your hard work on web2py!
>
> > > Regards,
>
> > > --Tiago Henriques
>
> > > PS: you might want to hire a top-notch web designer to turn the web2py
> > > pages into something a bit trendier and sexier. Your web design skills
> > > are clearly superior to mine, but sometimes you just gotta hand it to
> > > the pros.- Nascondi testo citato
>
> > - Mostra testo citato -
>
>


[web2py] Re: form=auth and error 404

2010-04-13 Thread carlo
Hi,
did you decorate the index action the way it is explained in the book?
Are you sure the Auth class is instantiated correctly in your model?

carlo

On 13 Apr, 09:40, aure  wrote:
> Hi everyone,
>
> I already posted that at the end of a discussion ("How to by-pass user/
> login page for authentication"). But I have no clue why it does behave
> this way, sorry.
>
> If I put in  my index controller:
>
> return dict(form=auth())
>
> then I get error 404 when I try to access my index view.
>
> Yet I have no problem accessing the login page which uses the same
> "procedure"...
>
> Has someone any idea what the problem could be?
>
> Thank again,
>
> Aurelien


-- 
To unsubscribe, reply using "remove me" as the subject.


[web2py] Re: auth.settings.actions_disabled.append('register')

2010-04-09 Thread carlo
you meant to avoid 404 page? mmh, It does not seem to work..maybe I
misunderstood.

carlo

On 9 Apr, 17:07, mdipierro  wrote:
> You can set
>
> auth.settings.on_failed_authorization = URL(...)


-- 
To unsubscribe, reply using "remove me" as the subject.


[web2py] Re: auth.settings.actions_disabled.append('register')

2010-04-09 Thread carlo
thank you, I knew all you said but I did not focus enough on the
"double" model issue oops!

About the 404 error page your link is broken but browsing the manual I
think you pointed me to the routes_onerror solution.

Thank you for bridging the execution stream  clearly,

carlo

On 9 Apr, 14:02, Yarko Tymciurak  wrote:
> On Apr 9, 6:07 am, carlo  wrote:
>
> > I think I have found the problem:
>
> :-)  Yes, you did!
>
>
>
> > in the models folder I had 3 files: db.py, lastdb.py, menu.py.
> > Lastdb.py was an old copy of db.py but, as far as I remeber, there was
> > no "auth.settings.actions_disabled.append('register')" in it.
>
> > After I deleted lastdb.py it worked as expected: I think that
> > lastdb.py was executed after db.py, Auth tables (re)created and set
> > auth.settings.actions_disabled=[]. Does it make sense to you?
>
> Maybe if you thought of this all as being in one "file" - or better,
> one execution stream, this would start making sense:
>
> For a running web2py, a request gets routed to an application /
> controller / function by gluon/main.py --
> To set up the environment for that call, gluon (web2py core)  runs all
> the model files, and then calls the function in your controller.
>
> Here's what that means:
>
> In your application's models folder, all the *.py files are read (in
> alphabetical order - this is your "file" processing stream).
> Once the data associations, and database connections are in place,
> then your controller is ready for a call.
>
> In your case, the model-stream that was setup was:  db.py, then
> lastbd.py, then menu.py.
>
> If you say something like "auth=Auth()" you are creating a new
> instance of an object, and using Auth (the class) to initialize that
> instance.
> If you have another assignment to the variable "auth", the first
> "reference" to the created object is released, and auth is pointed to
> the new, initialized object.
>
> In your case, lastdb.py   created the second Auth() instance, and re-
> assigned auth to point to this new object.   The new object's default
> setting was to NOT have registration disabled.
>
> If this is making sense, then you will know that when you do
> development experiments like this, you will want to rename your "last"
> file at the tail-end, e.g.
>
> rename db.py to db.py.last  is a better choice - since it is then no
> longer a python file, and will not get read.
>
> You'll find  for references to 404 in  www.web2py.com/book...
>
> Have lots of fun!
> - Yarko
>
>
>
> > Another small question:
>
> > what do you suggest as the best way to show the user a kind page
> > instead of "404 NOT FOUND" after he tried registration?
> > thank you
> > carlo
>
> > On 9 Apr, 12:48, carlo  wrote:
>
> > > thank you all.
>
> > > Thadeus:
> > > in my model below the place Auth tables are created;
>
> > > Massimo:
> > > no I do not have my register action, everything is web2py Auth out of
> > > the box.
>
> > > Yarko:
> > > Definitely not routes fault: I commented my routes but I still can
> > > access the registration page.
> > > I am down at debugging, later I will post more results.
>
> > > carlo
>
> > > On 9 Apr, 00:45, Yarko Tymciurak  wrote:
>
> > > > On Apr 8, 4:43 pm, carlo  wrote:
>
> > > > > thank you Yarko for replying. Well it is really a strange behaviour, I
> > > > > am trying to isolate the problem.
>
> > > > Try with just a fresh app first - just a clone of "welcome" with auth
> > > > enabled, auth.requires_login()  set for default/index, and not more.
>
> > > > Then try appending the actions_disabled - no routes, nothing:  just
> > > > get to this point first.
> > > > THEN --- if you think you are having problems with routes, add routes
> > > > to _just that minimal test_.
>
> > > > You can use your favorite debugger, and set it to ~ line 270 in gluon/
> > > > tools.py, to this:
>
> > > >     elif args[0] in self.settings.actions_disabled:
> > > >             raise HTTP(404)
>
> > > > and  confirm that  auth.__call__ is happening, that your setting is
> > > > there.
>
> > > > If you want to add your routes changes, and debug those, I'd start
> > > > with using the "canned" generic.html view, where you can see all the
> > > > request vars - this will help you also.
>
> &g

[web2py] Re: auth.settings.actions_disabled.append('register')

2010-04-09 Thread carlo
I think I have found the problem:

in the models folder I had 3 files: db.py, lastdb.py, menu.py.
Lastdb.py was an old copy of db.py but, as far as I remeber, there was
no "auth.settings.actions_disabled.append('register')" in it.

After I deleted lastdb.py it worked as expected: I think that
lastdb.py was executed after db.py, Auth tables (re)created and set
auth.settings.actions_disabled=[]. Does it make sense to you?

Another small question:

what do you suggest as the best way to show the user a kind page
instead of "404 NOT FOUND" after he tried registration?
thank you
carlo





On 9 Apr, 12:48, carlo  wrote:
> thank you all.
>
> Thadeus:
> in my model below the place Auth tables are created;
>
> Massimo:
> no I do not have my register action, everything is web2py Auth out of
> the box.
>
> Yarko:
> Definitely not routes fault: I commented my routes but I still can
> access the registration page.
> I am down at debugging, later I will post more results.
>
> carlo
>
> On 9 Apr, 00:45, Yarko Tymciurak  wrote:
>
> > On Apr 8, 4:43 pm, carlo  wrote:
>
> > > thank you Yarko for replying. Well it is really a strange behaviour, I
> > > am trying to isolate the problem.
>
> > Try with just a fresh app first - just a clone of "welcome" with auth
> > enabled, auth.requires_login()  set for default/index, and not more.
>
> > Then try appending the actions_disabled - no routes, nothing:  just
> > get to this point first.
> > THEN --- if you think you are having problems with routes, add routes
> > to _just that minimal test_.
>
> > You can use your favorite debugger, and set it to ~ line 270 in gluon/
> > tools.py, to this:
>
> >     elif args[0] in self.settings.actions_disabled:
> >             raise HTTP(404)
>
> > and  confirm that  auth.__call__ is happening, that your setting is
> > there.
>
> > If you want to add your routes changes, and debug those, I'd start
> > with using the "canned" generic.html view, where you can see all the
> > request vars - this will help you also.
>
> > Anyway, the point is: separate it to "one problem" at a time.
> > Otherwise it _will_ seem hard to "make sense" of things, separate out
> > what is going on.
>
> > Hope this is helpful.
> > - Yarko
>
> > > For now I have the feeling that my problem ha something to do with
> > > routes.py, this is my routing rule:
>
> > > routes_in = (('/$f', '/init/default/$f'),)
>
> > > routes_out = (('/init/default/$f', '/$f'),)
>
> > > In fact the login page, where you are redirected after you call an
> > > auth-decorated function, breaks the above rule:
>
> > >http://www.mysite.com/init/default/user/login?_next=/add
>
> > > Do you think this make any sense? Could this in any way affect the
> > > 'register' page so that it is not disabled?
>
> > > carlo
>
> > > On 8 Apr, 19:27, Yarko Tymciurak  wrote:
>
> > > > I've just tried this in both trunk, and 1.76.5, and in each I get a
> > > > "404 NOT FOUND"  when I hit "register"...
>
> > > > Perhaps say more about what you are doing that you think this does not
> > > > work...
>
> > > > On Apr 8, 10:05 am, carlo  wrote:
>
> > > > > Following the manual I put this statement in my model file but it
> > > > > seems I can still access the register page and register a new user:
> > > > > did I miss something?
>
> > > > > carlo
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "web2py-users" group.
> > > To post to this group, send email to web...@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > web2py+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/web2py?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.


-- 
To unsubscribe, reply using "remove me" as the subject.


[web2py] Re: auth.settings.actions_disabled.append('register')

2010-04-09 Thread carlo
thank you all.

Thadeus:
in my model below the place Auth tables are created;

Massimo:
no I do not have my register action, everything is web2py Auth out of
the box.

Yarko:
Definitely not routes fault: I commented my routes but I still can
access the registration page.
I am down at debugging, later I will post more results.

carlo

On 9 Apr, 00:45, Yarko Tymciurak  wrote:
> On Apr 8, 4:43 pm, carlo  wrote:
>
> > thank you Yarko for replying. Well it is really a strange behaviour, I
> > am trying to isolate the problem.
>
> Try with just a fresh app first - just a clone of "welcome" with auth
> enabled, auth.requires_login()  set for default/index, and not more.
>
> Then try appending the actions_disabled - no routes, nothing:  just
> get to this point first.
> THEN --- if you think you are having problems with routes, add routes
> to _just that minimal test_.
>
> You can use your favorite debugger, and set it to ~ line 270 in gluon/
> tools.py, to this:
>
>     elif args[0] in self.settings.actions_disabled:
>             raise HTTP(404)
>
> and  confirm that  auth.__call__ is happening, that your setting is
> there.
>
> If you want to add your routes changes, and debug those, I'd start
> with using the "canned" generic.html view, where you can see all the
> request vars - this will help you also.
>
> Anyway, the point is: separate it to "one problem" at a time.
> Otherwise it _will_ seem hard to "make sense" of things, separate out
> what is going on.
>
> Hope this is helpful.
> - Yarko
>
>
>
>
>
> > For now I have the feeling that my problem ha something to do with
> > routes.py, this is my routing rule:
>
> > routes_in = (('/$f', '/init/default/$f'),)
>
> > routes_out = (('/init/default/$f', '/$f'),)
>
> > In fact the login page, where you are redirected after you call an
> > auth-decorated function, breaks the above rule:
>
> >http://www.mysite.com/init/default/user/login?_next=/add
>
> > Do you think this make any sense? Could this in any way affect the
> > 'register' page so that it is not disabled?
>
> > carlo
>
> > On 8 Apr, 19:27, Yarko Tymciurak  wrote:
>
> > > I've just tried this in both trunk, and 1.76.5, and in each I get a
> > > "404 NOT FOUND"  when I hit "register"...
>
> > > Perhaps say more about what you are doing that you think this does not
> > > work...
>
> > > On Apr 8, 10:05 am, carlo  wrote:
>
> > > > Following the manual I put this statement in my model file but it
> > > > seems I can still access the register page and register a new user:
> > > > did I miss something?
>
> > > > carlo
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com.
> To unsubscribe from this group, send email to 
> web2py+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/web2py?hl=en.


-- 
To unsubscribe, reply using "remove me" as the subject.


[web2py] Re: auth.settings.actions_disabled.append('register')

2010-04-08 Thread carlo
thank you Yarko for replying. Well it is really a strange behaviour, I
am trying to isolate the problem.

For now I have the feeling that my problem ha something to do with
routes.py, this is my routing rule:

routes_in = (('/$f', '/init/default/$f'),)

routes_out = (('/init/default/$f', '/$f'),)

In fact the login page, where you are redirected after you call an
auth-decorated function, breaks the above rule:

http://www.mysite.com/init/default/user/login?_next=/add

Do you think this make any sense? Could this in any way affect the
'register' page so that it is not disabled?

carlo

On 8 Apr, 19:27, Yarko Tymciurak  wrote:
> I've just tried this in both trunk, and 1.76.5, and in each I get a
> "404 NOT FOUND"  when I hit "register"...
>
> Perhaps say more about what you are doing that you think this does not
> work...
>
> On Apr 8, 10:05 am, carlo  wrote:
>
> > Following the manual I put this statement in my model file but it
> > seems I can still access the register page and register a new user:
> > did I miss something?
>
> > carlo

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] auth.settings.actions_disabled.append('register')

2010-04-08 Thread carlo
Following the manual I put this statement in my model file but it
seems I can still access the register page and register a new user:
did I miss something?

carlo

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Validation per object

2010-04-02 Thread carlo
To Yarko latest post I did not read:

> in either way you are doing this (db field type, or FORM-INPUT), the
> way is similar:

totally agree.

One thing: I think it is never underlined enough that you do not
necessarily have to pass the form to the view so that having FORM +
"requires" helpers in the controller is mandatory only if you want
web2py validation in charge but it has nothing to do with the form
actually rendered.

rgds
carlo

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Validation per object

2010-04-02 Thread carlo
thank you Yarko for your always informative answers and for your
natural attitude to understand there are different point of views (I
wish I had someone like you in my company :-).

Just to come close to something I will show an example (though not
particularly smart):

my controller:

form=FORM(INPUT(_name='contact_email',requires=IS_EMAIL(error_message='Wrong
Address')),\
 
INPUT(_name='contact_company',requires=IS_NOT_EMPTY(error_message='Can
not be empty!')))
errors=form.errors
if form.accepts(request.vars,session=None,formname='contacts'):
  redirect(URL(r=request, f='index'))
elif form.errors:
  return dict(errors=form.errors)
return dict(errors=errors)

my view:



Company

{{if errors.contact_company:}}
{{=errors['contact_company']}} {{pass}}


E-mail

{{if errors.contact_email:}}
{{=errors['contact_email']}} {{pass}}



...other inputs you do not need to validate..

 

Well this uses FORM and leaves me free to have HTML the way I like:
but if you want to use FORM and for whatever reason you do not want
SQLFORM you have to go through something like that. My purpose: a
contact form without persistence because I do not need it and because
contacts requests are sent to me by email (or I am on a public hosting
with no db or whatever); I want to use web2py embedded validation; I
want to use HTML because my designer has already coded my web
pages..Though I put down some reasons with no particular care I think
this is, in general, not such a remote choice.

As you said:

>>But ultimately, you need to know "I want to do this - how?  what are my 
>>choices?"
>>Web2py offers you FORM, SQLFORM, and SQLFORM.factory.

My example is poor and maybe it is irrealistic there is not a model
but it works with FORM,

rgds
carlo



On 2 Apr, 16:09, Yarko Tymciurak  wrote:
> Hello Carlo -
>
> Know, there is no right or wrong - but I am trying to understand...
>
> On Apr 2, 3:38 am, carlo  wrote:
>
> > Thank you Yarko for accepting my "challenge" and I am looking forward
> > to get your answer.
>
> > > When I need to do this, I do it with making a memory-based table, and
> > > SQLFORM or SQLFORM.factory, and do whatevervalidationI need.
>
> > I do not want to discuss your solution though personally I do not like
> > any solution based on SQLFORM:
> > - I do not like to have to create a table just to validate my html
> > form server side: so the manual solution "SQLFORM in HTML" is not for
> > me;
>
> Then you can use the FORM pattern, as shown 
> onhttp://www.web2py.com/book/default/section/7/1
>
> I have not used this, so I do not think of it often, but there it is.
>
> > - I do not like the SQLFORM.factory either because this simply shifts
> > the problem and create a "fake" table in the controller;
>
> Of course, you are free to have your preferences.     But in this case
> you state it "shifts the problem" - but I am not sure what "the
> problem" is...
>
> That web2py is push-style mvc, and that the first thing that happens
> on a request is that data context is setup in preparation for a
> response (i.e. models are run, then controller)  it is (by it's
> nature) table centric.   IT is not so structured that it is object
> (e.g. business+engineering logic) centric, but if DAL were replaced by
> an ORM, then you would have your first focus on attention on the
> business-objects (and the persistence would be part of the mechanism
> the ORM would manage).
>
> ...and so on...
>
> My point is that there is always of view of the problem inherent, and
> you pick how you like to look at the problem (i.e. how you are
> comfortable at working)...
>
> > - I do not like Custom Forms particularly because, apart from the fact
> > I find the widgets a little tricky and "magic", they are based on a
> > table as well.
>
> Custom forms are no more than a way to do in forms the equivalent of a
> "join" on data (you can literally do this) and non-persisted items.
> You can almost think of them as SQLFORM.join(FORM)[.join(SQLFORM)]  -
> where the brackets mean optional (in the "man page" sense - nothing
> about python lists).
>
>
>
> > As I said, maybe I am totally wrong with my above thinking and I do
> > not want to criticize anyone but I prefer the "there is only one way
> > to make things" philosophy, which is very pythonic btw, over what I
> > read sometimes in this forum (and the book) "You can do that in
> > thousands of ways" or "It is easy to validate pure html forms" etc etc
> > ( which reminds me of the "Turbogears way" to make th

[web2py] Re: Validation per object

2010-04-02 Thread carlo
Thank you Yarko for accepting my "challenge" and I am looking forward
to get your answer.

> When I need to do this, I do it with making a memory-based table, and
> SQLFORM or SQLFORM.factory, and do whatevervalidationI need.

I do not want to discuss your solution though personally I do not like
any solution based on SQLFORM:
- I do not like to have to create a table just to validate my html
form server side: so the manual solution "SQLFORM in HTML" is not for
me;
- I do not like the SQLFORM.factory either because this simply shifts
the problem and create a "fake" table in the controller;
- I do not like Custom Forms particularly because, apart from the fact
I find the widgets a little tricky and "magic", they are based on a
table as well.

As I said, maybe I am totally wrong with my above thinking and I do
not want to criticize anyone but I prefer the "there is only one way
to make things" philosophy, which is very pythonic btw, over what I
read sometimes in this forum (and the book) "You can do that in
thousands of ways" or "It is easy to validate pure html forms" etc etc
( which reminds me of the "Turbogears way" to make things).

So I will take that your answer to "What is the best way to keep
validation and pure html forms?" is "doing a memory-based table and
SQLFORM/SQLFORM.factory"

> There is a fundamental "fuzziness" around this:   If you have manual
> forms without data persistence, what are you validating?  (and what
> can you not do by building up a simpel memory-db model, and validating
> transient data against that?)

your the first question is retoric of course, I can validate
everything I want even how many capital letters a user chose for his
password. The second is a serious one but, apart from philosofic
questions against "persistency at all costs", you pose me the answer
later, suppose I fear heavy server load or I have to be spare about
server memory resources..

>
> Second - if it is _really_ transient data that you arevalidation,
> then even memory db, per request, could get pretty "heavy" in terms of
> server load - why not do client-sidevalidation?

Of course you can if you have JS enabled.
So your answer here would be "if your data are really transient go
with client side validation".

> Either way, this begs the question:   why exactly this form of
> question?

My answer would have simply been a pure html Contact Form you see in
any web site but I now read a Thadeous' post where he gives his form
example.

Thank you Yarko for following me in these apparently futile arguments
but I would just like that people beginning with Web2py do not have to
read, like in many other python frameworks docs, "it is easy to get
this thing done" but they can never grasp that "easy way".

carlo

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: Validation per object

2010-04-01 Thread carlo
sorry for this "out of sync" answer but though I managed some "tricks"
to tackle the (problem of) validation in pure html forms during these
years, I would be curious about an answer to Mengu's request of
"showing how to make validation with manual forms".

Sorry DenesL but you did not answer the question as you supposed a
model in place, so I would really appreciate a simple html form which
preserves validation. Thank you

carlo

On 15 Mar, 21:09, DenesL  wrote:
> On Mar 15, 6:28 am, Mengu  wrote:
>
> > > First of all, I am not sure what is the problem you are trying to
> > > solve. Even if you havecustomformsand you build all the form html
> > > manually you can still use the existing validation mechanism.
>
> > I don't want to use crud or sqlform or any html helper. i build my
> >formsmanually. and actually if you show me how to make validation
> > with manualforms, it would be good.
>
> You could set the error messages in the requires
>
> db.users.name.requires = IS_NOT_EMPTY(error_message = "Please enter
> your name")
> db.users.email.requires = [
>   IS_EMAIL(error_message="Given e-mail is not a valid one."),
>   IS_NOT_IN_DB(db,'users.email',error_message="Sorry, this e-mail
> already exists in our database")
> ]
>
> create your form with the same field names and to check them do
>
> for n,v in request.vars.items():
>   rr=db.users[n].requires
>   if isinstance(rr,list):
>     t,e=v,None
>     for r in rr:
>       t,e=r(t)
>       if e: break
>   else:
>     t,e=rr(v)
>   if e:
>     form.errors[n]=e
>
> # here do whatever you need to do with form.errors
>
> Denes

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: rows.response

2010-02-03 Thread carlo
thank you,

carlo

On 3 Feb, 00:46, mdipierro  wrote:
> Try this:
>
> {{db[table].id.represent=lambda id: A(id,_href=URL(r=request,
> c='default',f='data_clienti',args=id,vars={'table':table})}))
> {{=SQLTABLE(rows,_class='sortable',headers=dict([(rows.colnames[i],c)
> for (i,c) in enumerate(colonne)]))}}
>
> On Feb 2, 11:13 am, carlo  wrote:
>
> > thank you Massimo, this is my code snippet:
>
> > 
> > 
> > {{for c in colonne:}}
> > {{=c}}{{pass}}
> > 
> > {{for r in rows.response:}}
> > 
> > {{for k in range(len(r)):}}
> > {{if k==0:}}
> > {{=r[k]}}
> > {{else:}}
> > {{=r[k]}}
> > {{pass}}
> > {{pass}}
> > 
> > {{pass}}
> > 
>
> > On 2 Feb, 16:53, mdipierro  wrote:
>
> > > There is no more rows.response. That was an internal variable. It is
> > > gone long ago.
> > > If you show us how you were using we can point to a simple fix.
>
> > > On Feb 2, 9:43 am, carlo  wrote:
>
> > > > I must have missed something lately, so forgive my question if it is a
> > > > faq.
>
> > > > I have an application where I used rows.response in a view: it was ok
> > > > until version 1.6.xx but it fails in the latest version, what is
> > > > changed?
>
> > > > thank you
> > > > carlo

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] Re: rows.response

2010-02-02 Thread carlo
thank you Massimo, this is my code snippet:



{{for c in colonne:}}
{{=c}}{{pass}}

{{for r in rows.response:}}

{{for k in range(len(r)):}}
{{if k==0:}}
{{=r[k]}}
{{else:}}
{{=r[k]}}
{{pass}}
{{pass}}

{{pass}}


On 2 Feb, 16:53, mdipierro  wrote:
> There is no more rows.response. That was an internal variable. It is
> gone long ago.
> If you show us how you were using we can point to a simple fix.
>
> On Feb 2, 9:43 am, carlo  wrote:
>
> > I must have missed something lately, so forgive my question if it is a
> > faq.
>
> > I have an application where I used rows.response in a view: it was ok
> > until version 1.6.xx but it fails in the latest version, what is
> > changed?
>
> > thank you
> > carlo

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py] rows.response

2010-02-02 Thread carlo
I must have missed something lately, so forgive my question if it is a
faq.

I have an application where I used rows.response in a view: it was ok
until version 1.6.xx but it fails in the latest version, what is
changed?

thank you
carlo

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.



[web2py:33808] Re: Web2py concerns

2009-10-27 Thread carlo

seldom I use the web editor myself, but I admit it is a facility when
you are at customers and you have to make a change on the fly.

As other said, there is a lot of magic in web2py but fortunately you
can tweek the environment the way you like.

carlo

On 24 Ott, 18:50, Doxaliber  wrote:
> Hi Carlo,
>
> I must say that another thing I don't like about web2py is the web
> editor and the web shell... :-) Yes, after all we can consider those
> features a pros and fortunately we can still edit our web2py apps
> using our preferred editor. Probably in the future, also for me, it
> will be an advantage to edit my webapp via browser, but I really love
> VI editor and, for now, I will continue to edit my apps using it! :-)
> About console I think that web2py console  is similar to the Django
> one. You can call django console with: python manage.py shell.
>
> On 24 Ott, 16:15, carlo  wrote:
>
> > about your ORM remarks, Massimo already pointed out this: I prefer a
> > more powerful tool but maybe (little) less immediate than the other
> > way round, but I think that this is ultimately just a matter of
> > taste.
>
> > I am not a Django expert but I used it in the past: what really got me
> > to adopt web2py was his template language, the more pythonic I have
> > ever seen and that's really a thing you will appreciate.
>
> > About docs, you are right but web2py is improving..about admin, I do
> > not have a deep practice with Django administration, but I have to say
> > I never had the feeling that web2py lack something important in his
> > admin interface. I would add that the admin web2py console where you
> > can test your query from the command line is also a great thing you
> > should try.
>
> > carlo
>
> > On 23 Ott, 20:27, mdipierro  wrote:
>
> > > > authors = models.ManyToManyField(Author)
>
> > > This hides the actual database implementation. It is fine is the link
> > > table does not carry additional information but limiting otherwise.
> > > Web2py we choose not abstract the databse too much, only the syntax to
> > > access it, more like RoR does it.
> > > We allow complex joins in the queries which (in my opinion)
> > > compensates for the lack of a syntax like the one you propose).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:33571] Re: Web2py concerns

2009-10-24 Thread carlo

about your ORM remarks, Massimo already pointed out this: I prefer a
more powerful tool but maybe (little) less immediate than the other
way round, but I think that this is ultimately just a matter of
taste.

I am not a Django expert but I used it in the past: what really got me
to adopt web2py was his template language, the more pythonic I have
ever seen and that's really a thing you will appreciate.

About docs, you are right but web2py is improving..about admin, I do
not have a deep practice with Django administration, but I have to say
I never had the feeling that web2py lack something important in his
admin interface. I would add that the admin web2py console where you
can test your query from the command line is also a great thing you
should try.

carlo

On 23 Ott, 20:27, mdipierro  wrote:
> > authors = models.ManyToManyField(Author)
>
> This hides the actual database implementation. It is fine is the link
> table does not carry additional information but limiting otherwise.
> Web2py we choose not abstract the databse too much, only the syntax to
> access it, more like RoR does it.
> We allow complex joins in the queries which (in my opinion)
> compensates for the lack of a syntax like the one you propose).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:33538] Re: running from source on Vista requires pywin32

2009-10-23 Thread carlo

well after some investigation I would say:

- python has no cross platform module to lock files
- on unix like systems there are no problems because of the fcntl
native python module
- web2py uses the classic portalocker, a cross platform module to
control file locking in a posix environment
- portalocker works on windows only by Mark Hammond's python
extensions

So my conclusion is:

if you install web2py on windows, I would say any Windows family os,
and you need file locking (of course you do), you have to install
win32 extensions.

The reason why I ovelooked this thing in the past is that you often
have win32 extensions installed though you are not aware of it.

Massimo or other experts here can comment on my conclusion?

carlo

On 23 Ott, 00:50, stefaan  wrote:
> > do you mind posting again what kind of error you get?
>
> Sorry I see now that there's room for confusion.
> I was talking about the lack of file locking message:
>
> WARNING:root:no file locking
>
> Best regards,
> Stefaan.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:33408] Re: running from source on Vista requires pywin32

2009-10-22 Thread carlo

do you mind posting again what kind of error you get?
thank you

carlo

On 22 Ott, 13:02, stefaan  wrote:
> Hello,
>
> This problem occurred for me on windows xp professional version 2002
> service pack 3 on an intel pentium 4 cpu 3ghz with 504 MB of RAM (an
> industrial rack).
>
> Python version 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310
> 32 bit (Intel)] on win32
>
> Web2py version 1.66.1 (2009-08-18 00:07:57)
>
> Best regards,
> Stefaan.
>
> On Oct 21, 3:03 pm, carlo  wrote:
>
> > never had that problem on tens of win installations: which web2py
> > version? I am going to test newer versions on fresh xp installations.
>
> > carlo
>
> > On 21 Ott, 11:15, stefaan  wrote:
>
> > > Hello all,
>
> > > I guess my contribution was lost in the noise,
> > > but I have the same problem on windows xp.
>
> > > Installing pywin32 also solved the problem for me.
>
> > > pywin32 probably should be documented as explicit
> > > dependency for running web2py from source on windows platforms.
>
> > > Best regards,
> > > Stefaan.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:33323] Re: running from source on Vista requires pywin32

2009-10-21 Thread carlo

could anyone post some technical issues about that? What's the problem
with Vista? Is that a python issue or web2py? I am sure no problem
with win 2003 server.

thank you

carlo

On 21 Ott, 17:16, Jason Brower  wrote:
> +1 to that feature. :P
>
> On Wed, 2009-10-21 at 08:00 -0700, mdipierro wrote:
> > I think they call it a feature
>
> > On Oct 21, 9:50 am, Thadeus Burgess  wrote:
> > > Works fine on xp, this is a vista/windows 7 issue.
>
> > > I had the same problem on my windows 7 virtual machine, installing pywin32
> > > fixed it, until windows update ran, then I had to reinstall pywin32 to 
> > > fix,
> > > very annoying bug with windows.
>
> > > -Thadeus
>
> > > On Wed, Oct 21, 2009 at 8:03 AM, carlo  wrote:
>
> > > > never had that problem on tens of win installations: which web2py
> > > > version? I am going to test newer versions on fresh xp installations.
>
> > > > carlo
>
> > > > On 21 Ott, 11:15, stefaan  wrote:
> > > > > Hello all,
>
> > > > > I guess my contribution was lost in the noise,
> > > > > but I have the same problem on windows xp.
>
> > > > > Installing pywin32 also solved the problem for me.
>
> > > > > pywin32 probably should be documented as explicit
> > > > > dependency for running web2py from source on windows platforms.
>
> > > > > Best regards,
> > > > > Stefaan.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:33294] Re: running from source on Vista requires pywin32

2009-10-21 Thread carlo

never had that problem on tens of win installations: which web2py
version? I am going to test newer versions on fresh xp installations.

carlo

On 21 Ott, 11:15, stefaan  wrote:
> Hello all,
>
> I guess my contribution was lost in the noise,
> but I have the same problem on windows xp.
>
> Installing pywin32 also solved the problem for me.
>
> pywin32 probably should be documented as explicit
> dependency for running web2py from source on windows platforms.
>
> Best regards,
> Stefaan.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:32738] security bug in Django, what about web2py?

2009-10-12 Thread carlo

This is the reported bug:

http://code.djangoproject.com/changeset/11603

do you think web2py is also affected?

carlo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:31904] Re: Watch this Youtube video!

2009-09-30 Thread carlo

I think it is showing just known things: clear passwords over unsecure
channels can be easily sniffed. Or did I miss something?

carlo

On 30 Set, 12:20, Pynthon  wrote:
> Hello everyone
>
> I am ill and I was lying in bed with my iPod Touch. However I searched
> on Youtube for some stuff until I saw this 
> video:http://www.youtube.com/watch?v=5ZLmRMLo6HI
>
> That guys uses Web2py right? First I thought it was Massimo but
> Massimo only uploads videos with his real name. Does this mean there
> is a vulnerability in Web2py?
>
> Sorry for spreading bad rumor if this isn't true but I thought better
> safe than sorry.
>
> Regards,
> Pynthon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:31405] Re: FORM, SQLForm - what should I use?

2009-09-21 Thread carlo

mika, I do not understand your needs. If you want a first form where
the machine is selected and then you want some static content be
presented (information and details about that particular machine) I
think you need an ajax function which returns the html content you
need to show the details associated (other choices are also available
to get the same result). I have examples if you need that.

About example 33, I think you are right, code is about two input text
fields but it shows 2 select instead.

carlo

On 21 Set, 12:01, mika  wrote:
> Thanks for your replies, they gave me some light..
> I have a question to example 33 - How it is working?? :)
> I mean how the values from db are put into SELECT, in code there's
> only
> declaration of form, and the fields are INPUTS (not SELECT)?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:29409] Re: web2py book, 2nd Ed

2009-08-26 Thread carlo

In fact I tried the same but what you get is the first edition,

carlo

On 26 Ago, 14:42, Benigno  wrote:
> Actually, my bad...  I have just checked the downloaded copy is 1st
> edition, not second, I had not checked the downloaded file.
>
> Thanks Rev for pointing that out.
>
> On Aug 26, 1:51 pm, Jason Brower  wrote:
>
> > Well dang... that sucks.  I guess I will give a copy to my friend. :D
> > Regards,
> > Jason Brower
>
> > On Wed, 2009-08-26 at 04:30 -0700, mdipierro wrote:
> > > Thanks for the clarification.
>
> > > On Aug 26, 6:19 am, Benigno  wrote:
> > > > I got it with a free download from LuLu.
>
> > > > What I did to get it was:
>
> > > > - Login LuLu with same user I created to buy first version.
> > > > - Go to my order history, and get the order I purchased it from
> > > > initially.
> > > > - From there, there is a drop down thats a bit confusing as it says:
> > > > Need help?.. select Where can I download my order.
> > > > - It takes you to the place where you can download it, and it IS the
> > > > second version.
>
> > > > Well, at least, that has worked for me alright.
>
> > > > Cheers, and thanks Massimo for the book. It will really help
> > > > developing.
>
> > > > Benigno.
>
> > > > On Aug 26, 12:57 pm, carlo  wrote:
>
> > > > > Missing those categories I bought this at the bargain price of 9.69
> > > > > euros !
>
> > > > > btw, great work Massimo!
>
> > > > > carlo
>
> > > > > On 26 Ago, 12:37, mdipierro  wrote:
>
> > > > > > I cannot reimburse people but I am happy to give it for free to high
> > > > > > school students and people who live in countries with an average
> > > > > > annual income below $8000 or are prevented from download because of
> > > > > > government restrictions.
>
> > > > > > Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:29391] Re: web2py book, 2nd Ed

2009-08-26 Thread carlo

Missing those categories I bought this at the bargain price of 9.69
euros !

btw, great work Massimo!

carlo

On 26 Ago, 12:37, mdipierro  wrote:
> I cannot reimburse people but I am happy to give it for free to high
> school students and people who live in countries with an average
> annual income below $8000 or are prevented from download because of
> government restrictions.
>
> Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:29380] Re: web2py book, 2nd Ed

2009-08-26 Thread carlo

> Same price as before ($12.5) and same ID (which means if you bought
> the old one you should be able to get the new one for free).

Are you sure about that? Though I bought the first edition I do not
see any way to get the second for free, thank you

carlo

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27706] Re: silly question: embedding flash files in views

2009-07-31 Thread carlo

thank you all for replying.
It is definitely not a matter of syntax but of my poor knowledge of
Flash I suppose.
I found no way to get my mp4 imported in Flash converted in a "valid"
swf for playing: the proof of my wrong approach is the dimension of
the swf file obtained from Flash: 60KB against 6MB of the original mp4
file.
Maybe I will learn to use Flash the right way one day..

As soon as I used another tool to convert my mp4 video into swf (into
flv actually as you can read below) everything was ok and my original
syntax worked.

At present I chose to use the SWFObject approach which, among other
things, lets you play your movies as flv files and customized player
(I used the classic JW player), but even the classic  tag is
fine.

For the curious this is the code:



var flashvars = {};
flashvars.file = 
"{{=URL(r=request,c='static',f='xcel2xml.flv')}}";
var params = {};
params.play = "false";
params.loop = "false";
params.menu = "true";
params.quality = "best";
params.scale = "showall";
params.wmode = "window";
params.swliveconnect = "true";
params.allowfullscreen = "true";
params.allowscriptaccess = "always";
params.allownetworking = "all";
var attributes = {};
attributes.id = "container";

swfobject.embedSWF("{{=URL(r=request,c='static',f='player.swf')}}",
"myAlternativeContent", "640", "480", "9.0.0", false, flashvars,
params, attributes);


where player.swf= the JW Flash player and xcel2xml.flv=my video

In the body section of your view just put (shown only if the user does
not have Flash player installed):


http://www.adobe.com/go/getflashplayer";>
http://www.adobe.com/images/shared/download_buttons/
get_flash_player.gif" alt="Get Adobe Flash player" />



Everything about swfobject at http://code.google.com/p/swfobject/

carlo


On 31 Lug, 02:31, Jonathan Lundell  wrote:
> On Jul 30, 2009, at 5:21 PM, Miguel Lopes wrote:
>
>
>
>
>
> > On Thu, Jul 30, 2009 at 4:58 PM, Jonathan  
> > Lundell wrote:
>
> >> On Jul 30, 2009, at 7:47 AM, Jonathan Lundell wrote:
>
> >>> On Jul 30, 2009, at 7:42 AM, Miguel Lopes wrote:
>
> >>>> If its in swf, it should work.
>
> >>>> Although, I notice an error in the original snippet you posted
> >>>> (besides the missing ' ):
> >>>> {{url=URL(r=request,c='static',f='somefilename.swf)}}
>
> >>>> Should be):
> >>>> url={{URL(r=request,c='static',f='somefilename.swf')}}
>
> >>> Or maybe:
>
> >>> url={{=URL(r=request,c='static',f='somefilename.swf')}}
>
> >> Never mind. I see from a later post that the {{url=...}} was correct.
>
> > Forgive me. Actually I meant:
> > href="{{=URL(r=request,c='static',f='somefilename.swf')}}"
>
> > it is also true that:
> > {{url=URL(r=request,c='static',f='somefilename.swf')}}
>
> > is also correct. But the only thing it does is assign the url to a
> > variable, that is only available in the template. So if you are using
> > this to populate a href tag (like I assumed), you'll get an empty tag.
>
> What I meant was that Carlo's original question had this code:
>
> {{url=URL(r=request, c='static', f='somefilename.swf' )}}
> 
> 
> 
> 
> 
>
> ...where the treatment of url look fine to me.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27603] Re: silly question: embedding flash files in views

2009-07-30 Thread carlo

Thank you Miguel but I found out that the problem is with my swf file.
It is originally an mp4 file, I tried to convert it with Flash CS4 but
any options I choose seems not working when I call the file form my
web2py view.

When I right click the swf exported by Flash and choose open with
Firefox (the same with IE6) Flash Player starts ok and I can see the
movie. When form inside Flash I try Publish Preview I can see the
movie in my browser. But if I call the file from a web2py view or I
manually call the /static/myfile.swf form the browser nothin happens I
can see nothing.

When I tried to export the original mp4 file to swf with another
software everything is ok (but I have an awful compression rate).

Do you have any experience with Flash swf conversion? Or can you
suggest a better format for online tutorials (flv ?)..thank you

On 28 Lug, 19:28, Miguel Lopes  wrote:
> On Tue, Jul 28, 2009 at 4:48 PM, carlo wrote:
>
> > After several tries I have to ask: are any particular issues with
> > embedding flash objects in views?
>
> > I put the usual in my view:
>
> > {{url=URL(r=request,c='static',f='somefilename.swf)}}
> > 
> > 
> > 
> > 
> > 
>
> > what's bad here? Thank you
> > carlo
>
> Instead try:
>
>                  data="{{=URL(r=request,c='static',f='somefilename.swf')}}">
>              name="allowfullscreen" value="true" />
>              value="{{=URL(r=request,c='static',f='somefilename.swf')}}" />
> 
>
> Miguel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27509] Re: silly question: embedding flash files in views

2009-07-28 Thread carlo

no, I mistyped but I have the same :
{{url=URL(r=request, c='static', f='somefilename.swf' )}}

I can see the the "box" on the html page but no flash player
starting.

On 28 Lug, 18:38, Fran  wrote:
> On Jul 28, 4:48 pm, carlo  wrote:
>
> > {{url=URL(r=request,c='static',f='somefilename.swf)}}
>
> {{url=URL(r=request, c='static', f='somefilename.swf')}}
>
> F
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:27502] silly question: embedding flash files in views

2009-07-28 Thread carlo

After several tries I have to ask: are any particular issues with
embedding flash objects in views?

I put the usual in my view:

{{url=URL(r=request,c='static',f='somefilename.swf)}}






what's bad here? Thank you
carlo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:26410] Re: code & book v2

2009-07-13 Thread carlo

from my first view to the new chapters of v2 book I would add:

- some more examples for using widgets
- more documentation about html forms: how preserving validation,
keepvalues, what you must/should declare in the controller. What I
think missing is a practical comparison among the different form
implementation and the  best practice to follow.

just a thought..

carlo

On 13 Lug, 13:51, gluegl  wrote:
> When will the book be released?
> I purchased 3 weeks ago the old book online.  :-(
> -G
>
> On Jul 12, 3:00 pm, Tim Michelsen  wrote:
>
> > Hello Massimo,
> > as you are announcing a update of the book:
> > Would you please make the code snippets from the book available as zip?
> > Copy&past from the PDF is not always easy.
>
> > Thanks in advance,
> > Timmie
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24625] Re: web2py with mysql

2009-06-21 Thread carlo

you always have to set a user in mysql: if you never set a user before
I suppose you always accessed as 'root' and a blank password but these
have yet to be present in the connection string (not a web2py issue
here).

carlo

On 21 Giu, 07:00, weheh  wrote:
> I had to do some mucking around with setting up user accounts and
> passwords in mysql. Something I'd never gotten around to doing before.
> So now that that's settled and working, I'm running up against this
> problem with date and datetime fields:
>
> http://groups.google.com/group/web2py/browse_thread/thread/15803e02e5...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24624] Re: Difficulty with mysql migration

2009-06-21 Thread carlo

maybe I am not fully up to date with the latest web2py releases so
chech this out:

db structure: if you have an existing mysql db with the same structure
as the sqlite db, it is just a matter of changing the connect string
in the model

db data: I think web2py does not care for migrating data from one db
to another (and it should not do), I think you have to do some
scripting or use some external mysql utility to convert data.

carlo

On 21 Giu, 03:09, weheh  wrote:
> Now 100% certain about causing reserved keyword conflict with mysql.
> Thanks again for the reminder.
>
> I successfully migrated the data to mysql from sqlite, but did it 1
> table at a time. Is there a convenient way to move all the data from
> all tables at once? I figured tar and detar just brings back the
> sqlite db, so I didn't try it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24622] Re: How using free id in db

2009-06-21 Thread carlo

here you can find some details about autoincrement in SQLIte:

http://www.sqlite.org/autoinc.html

as you can see ROWID is a 64 bit signed number and my conclusion is
you never should worry about the 'id gaps'.

carlo

On 21 Giu, 00:01, Fauché JM  wrote:
> Annet ,has clearly explain the "problem"...
> Thank you for you answers...
> Jean-Marc
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24548] Re: web2py with mysql

2009-06-20 Thread carlo

when you launch web2py check if it reports MySQL installed from the
console. In addition I think that although you have no password in
mysql you should set 'user' and 'password' in the connection string.

carlo

On 20 Giu, 16:13, weheh  wrote:
> I'd like to test web2py with mysql on my development platform. My
> mysql installation does not have a password set. How do I connect with
> mysql from within web2py? I've tried many variants of this:
>
> db = SQLDB('mysql:::3306/test')
>
> but none seem to work. I consistently get the error message:
>
> File "gluon/sql.py", line 954, in __init__
> SyntaxError: database type not supported
>
> Anybody have a helpful suggestion?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24547] Re: Having an 'upgrade' distribution?

2009-06-20 Thread carlo

..and did you consider the source distribution? Once you have Python
installed it is lighter and faster to download.

carlo

On 20 Giu, 01:43, Eddie Eyles  wrote:
> I like the pace of new releases of web2py, but it is a pain to
> download each one (the Windows distribution takes an hour on my
> connection if I am lucky).  Given that each new release has normally
> changed only a few files, would it be realistic to provide a small
> 'upgrade' distribution from the previous version?  Or at least to
> separate out the more static parts of the distribution, such as Tcl/
> Tk, the python DLL and the standard applications.  This needs to be
> balanced against the extra work it would entail at Massimo's end.
>
> Eddie
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24543] Re: Can't get the server to work online...

2009-06-20 Thread carlo

Sincerely I miss the point of -i 0.0.0.0: what is your purpose here?

carlo

On 20 Giu, 14:29, Jason Brower  wrote:
> I start web2py with this...
> python web2py.py -i 0.0.0.0
> And it seem to run fine on that server... but when I try to go to the IP
> address from online it doesn't work.
> I know it's not my firewall as I have apache running on this computer
> too.
> I turned off apache before trying this.
> Regards,
> Jason Brower
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24541] Re: Coming from grails world

2009-06-20 Thread carlo

Anyway I would be surprised to see CherryPy+SQLite performing slower
than Apache+anything else at least under moderate load.

carlo

On 19 Giu, 20:18, Fran  wrote:
> On 19 June, 16:01, Daniel Guryca  wrote:
>
> > I can see that performance coming from a default integrated server is
> > somewhat poor.
>
> 'integrated server' = CherryPy/SQLite, right?
>
> > What other deployment possibilities could I test ?
>
> ApacheWSGI/PostgreSQL would be a better comparator.
>
> F
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24540] Re: How using free id in db

2009-06-20 Thread carlo

I think I do not grasp your point: if you delete one row you do not
have empty id although it increments so there is no lost time when
reading the db and you do not even heve th chance to access the
"deleted" id.
Or maybe I misunderstood your case..

carlo

On 20 Giu, 13:57, Fauché JM  wrote:
> Hello,
> I my application ,I have a db in which some row are frequently
> deleted, so if for each new data I  save it in db  (automatiquely
> incremented) I will have a lot of data and a lot of id "empty".
> I think that in this situation when reading data , the program loose
> time ..?
> So I imagine a piece of code where first I seach for free places for
> using the fist one for new data:
>
>                 libre=(db.somedata.value==0)
>                 if len(db(libre).select())>0:           # On free
> place
>                     le_libre = db(libre).select()[0]
>                     db(db.somedata.id==le_libre.id).update
> (value=newvalue)
>                 else:                                   # On new
> place
>                     somedata_id=db.somedata.insert(value=newvalue)
>
> May be there is a simple way ? (for exemple a
> function ...insert_onfree...)
>
> Thank for your comments
> Jean-Marc
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24384] Re: forms validation

2009-06-17 Thread carlo

>  {{=INPUT(_name='test',_class='...')}}

so that I can mix html  with helpers, yes I was aware of this.

> or (latest trunk)
> {{=form.custom.begin}}
> {{=form.custom.widget.test}}
> {{=form.custom.submit}}
> {{=form.custom.end}}

this is totally new to me: did you document this somewhere? Maybe in
the new slides (that still I can not download from Scribd)..

thank you
carlo


>
> Massimo
>
> On Jun 17, 10:47 am, carlo  wrote:
>
> > sorry Massimo to insist upon this but I would like to get it clear.
> > I understand this: if you want to validate one field you have to put
> > that field in the FORM() of the controller, this duplication is the
> > trade off to get validation.
>
> > So this is the way to preserve validation:
>
> > Controller:
>
> > def index():
> >     form=FORM(INPUT(_name='test', requires=IS_NOT_EMPTY()))
> >     if form.accepts(request.vars,session=None,formname='test'):
> >         response.flash='form accepted'
> >     elif form.errors:
> >         response.flash='form has errors'
> >     else:
> >         response.flash='please fill the form'
> >     return dict()
>
> > View:
>
> > 
> > 
> > 
> > 
> > 
>
> > thanks
> > carlo
>
> > On 17 Giu, 17:07, mdipierro  wrote:
>
> > > in your code, the form that accepts is form=FORM() and it contains no
> > > fields. No variable is transferred from request.vars to form.vars.
> > > There are no errors because there are no fields.
>
> > > The {{=INPUT()}} is the view get serialized when the form is
> > > displayed but it is not used by accept because it is not part of the
> > > form.
>
> > > While you can use this syntax to build custom forms, you cannot use
> > > this syntax to process forms.
>
> > > Massimo
>
> > > On Jun 17, 5:22 am, carlo  wrote:
>
> > > > From the manual there is no reason this should not work, but the form
> > > > is accepted even with the empty field. Why? Thank you
>
> > > > carlo
>
> > > > controller:
>
> > > > def index():
> > > >     form=FORM()
> > > >     if form.accepts(request.vars,session,formname='test'):
> > > >         response.flash='form accepted'
> > > >     elif form.errors:
> > > >         response.flash='form has errors'
> > > >     else:
> > > >         response.flash='please fill the form'
> > > >     return dict()
>
> > > > view:
>
> > > > {{extend 'layout.html'}}
> > > > 
> > > > 
> > > > {{=INPUT(_name='prova',_type='text',requires=IS_NOT_EMPTY())}}
> > > > 
> > > > 
> > > > 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24369] Re: forms validation

2009-06-17 Thread carlo

sorry Massimo to insist upon this but I would like to get it clear.
I understand this: if you want to validate one field you have to put
that field in the FORM() of the controller, this duplication is the
trade off to get validation.

So this is the way to preserve validation:

Controller:

def index():
form=FORM(INPUT(_name='test', requires=IS_NOT_EMPTY()))
if form.accepts(request.vars,session=None,formname='test'):
response.flash='form accepted'
elif form.errors:
response.flash='form has errors'
else:
response.flash='please fill the form'
return dict()

View:








thanks
carlo


On 17 Giu, 17:07, mdipierro  wrote:
> in your code, the form that accepts is form=FORM() and it contains no
> fields. No variable is transferred from request.vars to form.vars.
> There are no errors because there are no fields.
>
> The {{=INPUT()}} is the view get serialized when the form is
> displayed but it is not used by accept because it is not part of the
> form.
>
> While you can use this syntax to build custom forms, you cannot use
> this syntax to process forms.
>
> Massimo
>
> On Jun 17, 5:22 am, carlo  wrote:
>
> > From the manual there is no reason this should not work, but the form
> > is accepted even with the empty field. Why? Thank you
>
> > carlo
>
> > controller:
>
> > def index():
> >     form=FORM()
> >     if form.accepts(request.vars,session,formname='test'):
> >         response.flash='form accepted'
> >     elif form.errors:
> >         response.flash='form has errors'
> >     else:
> >         response.flash='please fill the form'
> >     return dict()
>
> > view:
>
> > {{extend 'layout.html'}}
> > 
> > 
> > {{=INPUT(_name='prova',_type='text',requires=IS_NOT_EMPTY())}}
> > 
> > 
> > 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24359] Re: Web2Py Virtual Machine

2009-06-17 Thread carlo

could be great to download this VM and test, I think you made a great
work.

carlo

On 17 Giu, 16:08, JohnMc  wrote:
> samwyse,
>
> The primary reason I picked Ubuntu was to avoid any licensing issues.
> Offering something like this up to anyone who wants it,  means you
> don't have any control over its use/deployment. RHEL, OEL & SLES all
> require licenses.  I could do a VM for Fedora or Suse CE. But I don't
> think either of those would get past your data center manager's
> objections however.
>
> AsianUX I am not familiar with, but I scanned the licensing and it
> appears no rules are broken for personal use. I would leave any issues
> to your employer and their supplier as to any corporate use. But
> AsianUX intrigues me. I don't mind creating the VM and providing it to
> you. But for 'take it, its free' I prefer to stick with Ubuntu for the
> reasons above.
>
> On Jun 17, 5:07 am, samwyse  wrote:
>
> > Since everyone is suggesting changes, how about using one of these
> > instead of Ubuntu: SLES 9 SP4, SLES10 SP2, RHEL5 U2, RHEL5 U1, RHEL5,
> > RHEL4.7, AsianUX 2.0, AsianUX 3.0, and OEL 5.1.  While everyone I know
> > has Ubuntu on their desks and laptops, those are the only distros that
> > my company will support inside the data center.
>
> > On Jun 16, 6:35 pm, JohnMc  wrote:
>
> > > Built a Virtual Box VM for Web2Py. Its a Ubuntu guest OS. Components
> > > --
>
> > > * Web2py server 1.64.1 on Python 2.6.2.
> > > * Firefox in launcher directed to the server.
> > > * Public domain docs of Web2Py.
>
> > > Somebody who might want to trial the software can do so as a VM
> > > instance. Downside is its about 900mb in size.
>
> > >http://web2pyzip.onodot.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24358] Re: forms validation

2009-06-17 Thread carlo

thank you for suggestions but..

Fran: agree maybe is not good MVC having requires in a view, but what
about having forms in the controller/model ? Do you think that good
MVC? Personally I hate throwing html (even helpers) in a controller.
But I know this is an old debate..

DenesL: I thought there was a custom way (somewhere in the manual) to
get your forms in views just setting a form=FORM() in the controller
without passing it to the view so preserving the chance to validate
inputs. I think I misunderstood that point but I do not grasp then the
point to get the form=FORM() statement in the controller..

maybe you can clarify this point?

carlo

On 17 Giu, 15:41, DenesL  wrote:
> carlo,
> the INPUT in the view is not part of the form, the form has no fields.
> When form.accepts runs it does not have any field to check against
> request.vars .
>
> You will have to stick to Fran's suggestion.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24348] forms validation

2009-06-17 Thread carlo

>From the manual there is no reason this should not work, but the form
is accepted even with the empty field. Why? Thank you

carlo

controller:

def index():
form=FORM()
if form.accepts(request.vars,session,formname='test'):
response.flash='form accepted'
elif form.errors:
response.flash='form has errors'
else:
response.flash='please fill the form'
return dict()

view:

{{extend 'layout.html'}}


{{=INPUT(_name='prova',_type='text',requires=IS_NOT_EMPTY())}}



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24346] Re: new slides

2009-06-17 Thread carlo

it is impossible to download from Scribd, it just launches an endless
Loading..

carlo

On 17 Giu, 08:21, mdipierro  wrote:
> sorry. fixed.
>
> On Jun 17, 1:12 am, "Francois (Jersey)"
>
>  wrote:
> > can not access as well, and have an Invalid function.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:24290] adding vars to request.vars ?

2009-06-16 Thread carlo

I have one form and when submitted I find in request.vars the value of
the form controls. Now I would like to find in request.vars some more
values: of course I could insert some input type='hidden' in the form
but I am wondering if some alternative way exist to add some extra
values to request.vars .

carlo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23687] Re: how to prevent deletion of referenced records

2009-06-09 Thread carlo

Foreign key constraints are not implemented in Sqlite (although it
parses the command).

See: http://www.sqlite.org/omitted.html

but you can use triggers.

carlo

On 9 Giu, 15:46, annet  wrote:
> Marco,
>
> Did you test this in Sqlite:
>
> db.define_table('table',
>     db.Field('field',...,ondelete='RESTRICT'),
>     migrate='table.table')
>
> It does set the ON DELETE to RESTRICT in the foreign key constraint in
> Postres.
>
> Annet.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23685] Re: how to prevent deletion of referenced records

2009-06-09 Thread carlo

Hi Marco,
if you mean at db level, it depends on your db engine. To my
knowledge, in Sqlite you can not get foreign key constraints ("on
delete=cascade" or similar is not effective) but you have to use
Triggers to achieve the same result. Foreign keys constraints though
can be enforced in most of other rdbms.
Of course sort of referential integrity can be assured via software
checking in every table which has a reference to the record you want
to delete.

carlo

On 9 Giu, 13:51, Marco Prosperi  wrote:
> hi all, is there a validator or an easy way to prevent a user to
> delete a record if there are other records referencing it? Just to
> make an example: consider the 'images' application in cookbook2.pdf. I
> would like that the user cannot delete an image if there are comments
> referred to it (it would be useful to get a warning message specifying
> that the user has to delete the comments first)
>
> thanks in advance,
>
> Marco
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23498] Re: slides again

2009-06-07 Thread carlo

any place to download without registering to scribd ?

carlo

On 6 Giu, 17:20, mdipierro  wrote:
> I posted a new version of the slides with typos fixed, and a couples
> slides added.
>
> http://www.scribd.com/doc/16085263/web2py-slides-version-163
>
> BTW 3000 viewers so far (the first 900 are not counted by scribd.com
> because the doc was not hosted there originally when posted).
>
> Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23184] Re: more slides - must read

2009-06-03 Thread carlo

suppose .html is there just to show you can access the extension with
request.extension

carlo

On 3 Giu, 11:03, dlypka  wrote:
> On page 24, why does it include the '.html' ?
>
> In your original cookbook, there is no '.html' here:
>
> "A URL likehttp://hostname/cookbook/default/index/bla/bla/bla?variable=value
> will result in a call to function index() in controller default.py in
> applicaiton cookbook.
> “bla”, “bla” and “bla” will be passed as request.args[0:3] while
> “value” will be stored in
> request.vars.variable."
>
> On Jun 2, 11:52 pm, mdipierro  wrote:
>
> >http://www.web2py.com/examples/static/cookbook2.pdf
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23025] Re: if you care about web2py...

2009-06-01 Thread carlo

added.
carlo (aka sotospeak)

On 1 Giu, 05:40, mdipierro  wrote:
> ... you should comment on threads like this:
>
> http://www.reddit.com/r/programming/comments/8ooh3/which_web_framewor...
>
> Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:23024] Re: if you care about web2py...

2009-06-01 Thread carlo

mine comment added.
carlo (aka sotospeak)

On 1 Giu, 05:40, mdipierro  wrote:
> ... you should comment on threads like this:
>
> http://www.reddit.com/r/programming/comments/8ooh3/which_web_framewor...
>
> Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:22553] Re: executesql is safe?

2009-05-24 Thread carlo

I would add that in appadmin.py there are several examples for using
DAL when table and field names are generated at "runtime".

carlo

On 24 Mag, 08:09, mdipierro  wrote:
> > But I have some questions:
>
> > 1.- Is more safe to use  executesql?
>
> It is less safe because you must validate values yourself to avoid SQL-
> injection vulnerabilities.
>
> > 2.- Advantage and disadvantage of executesql?
>
> No advantage if you have the option not to use it. If you need to
> build a query that cannot be expressed within the DAL, like using a
> function that it very specific of your database backend, then you have
> no choice.
>
> > 3.- executesql is more faster?
>
> The difference with the DAL is negligible.
>
> > 4.- I'll have some troubles if I use executesql?
>
> A lot of extra work to avoid injections and your code will not
> portable across databases.
>
> > 5.- If you know other method to make dynamic queries?
>
> You should use the DAL
>
> db.mytable.insert(myfield='myvalue')
> db(db.myfield=='myvalue').select(orderby=db.mytable.myvalue)
> etc.
>
> Massimo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:22514] Re: new in trunk args[i] == None

2009-05-23 Thread carlo

I am definitely with AchipA this time: no need to change request.args

carlo

On 23 Mag, 21:32, AchipA  wrote:
> Hang on, not sure if we're talking about the same thing. Style, as in
> preference of 'if' over 'try' is okay to discuss (although I think
> *forcing* people to use 'if' is wrong). This proposed change, however,
> inherently BREAKS backward compatibility, as seen from my example, for
> anybody using the EAFP approach (myself included). That was my first
> concern. Are we okay with this breakage ?
>
> On May 23, 6:34 pm, mdipierro  wrote:
>
> > request.args is a special list anyway because it could be made
> > readonly and because its elements can only be non-empty strings. This
> > is why I have difficuly seeing how this will create conflicts.
>
> > I like the fact it would allow to do
>
> >    record = db.table[request.args[0]] or redirect(...)
>
> > when you expect a valid record_id in request.args[0]. It is much
> > shorter than
>
> >    record = db.table[request.args[0] if request.args else None] or
> > redirect(...)
>
> > which would not work on python 2.4.
>
> > List only breaks checking for existence using try/except but using try/
> > except to determine whether args[i] is a valid argument is not a good
> > programming style in my opinion (although I am as guilty of using it
> > as anybody else).
>
> > Let's wait for more comments anyway.
>
> > Massimo
>
> > On May 23, 11:15 am, AchipA  wrote:
>
> > > Env and vars are somewhat different, being dicts. The Proper (TM) way
> > > for those would be target = request.vars.get('myoptionalvar', None).
> > > The reason this is the Proper (TM) way is that you *have* to know when
> > > you're handling undefined data (is that a None ? Or a '' ? Maybe 0 ?)
> > > You can't just throw in a None in a middle of a controller and hope it
> > > works out (often trading an IndexError for an even harder to debug
> > > 'unsupported operand type for None'. That would be the PHP way. Easy
> > > on beginners - yes, effect on code quality - terrible. But let's wait
> > > on further comments.
>
> > > On May 23, 5:42 pm, mdipierro  wrote:
>
> > > > yes but we do this already for request.vars and request.env
>
> > > > anyway, I am not sure about myself about this. Let's here a few
> > > > comments about this can I can revert it.
>
> > > > Massimo
>
> > > > On May 23, 10:29 am, Alexey Nezhdanov  wrote:
>
> > > > > On Saturday 23 May 2009 18:42:58 AchipA wrote:> Tt does break 
> > > > > existing properly written python code (and is very non-
> > > > > > pythonesque).
>
> > > > > +1 except for harshness. Masking exceptions is a BAD THING (TM)
>
> > > > > > Think:
>
> > > > > > try: target = request.args[0]
> > > > > > except:
> > > > > >    response.flash = 'No target specified'
> > > > > >    return
>
> > > > > > do_something(target)
> > > > > > If this is an issue for people, I think they should improve their
> > > > > > python skills (learn exceptions, for arg in request.args 
> > > > > > constructs),
> > > > > > and not fight the language by framework-specific workarounds. They
> > > > > > will benefit from it much more on the long run (as they are bound to
> > > > > > have the same IndexError or KeyError problem anyway, just someplace
> > > > > > else). My 0.02c.
>
> > > > > --
> > > > > Sincerely yours
> > > > > Alexey Nezhdanov
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:22393] Re: pre-populating forms and keepvalues=True ?

2009-05-22 Thread carlo

my solution is:

{{if request.vars.myname:}}
{{myvalue=request.vars.myname}}
{{else:}}
{{myvalue='mydefault'}}
{{pass}}


any better?

carlo

On 22 Mag, 17:33, carlo  wrote:
> I forgot to mention that my form is pure html and in the controller I
> have:
>
> form=FORM()
> if form.accepts
> (request.vars,session=None,formname='consuntivi',keepvalues=True):
>         response.flash="OK"
> elif form.errors:
>         response.flash="Errors"
>
> I noticed that values inserted are always cleared after submission
> even if the field is not pre-populated.
>
> My answer is that because the form=FORM() is never passed to the view
> I can not have my values kept. Correct?
>
> Any work around for this leaving the form as pure html?
>
> carlo
>
> On 22 Mag, 17:12, carlo  wrote:
>
> > maybe trivial but I can not get the clue: I need to have a form pre-
> > populated with some values and I know you can do it with
> > form.vars.name='myvalue'. But when I submit the form with
> > keepvalues=True I get the form back with the pre-populated values and
> > not with the changes the user made.
>
> > Any suggestion?
> > Thank you
>
> > Carlo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



[web2py:22391] Re: pre-populating forms and keepvalues=True ?

2009-05-22 Thread carlo

I forgot to mention that my form is pure html and in the controller I
have:

form=FORM()
if form.accepts
(request.vars,session=None,formname='consuntivi',keepvalues=True):
response.flash="OK"
elif form.errors:
response.flash="Errors"

I noticed that values inserted are always cleared after submission
even if the field is not pre-populated.

My answer is that because the form=FORM() is never passed to the view
I can not have my values kept. Correct?

Any work around for this leaving the form as pure html?

carlo

On 22 Mag, 17:12, carlo  wrote:
> maybe trivial but I can not get the clue: I need to have a form pre-
> populated with some values and I know you can do it with
> form.vars.name='myvalue'. But when I submit the form with
> keepvalues=True I get the form back with the pre-populated values and
> not with the changes the user made.
>
> Any suggestion?
> Thank you
>
> Carlo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~--~~~~--~~--~--~---



  1   2   >