[web2py] ask about static files

2017-03-18 Thread 黄祥
hi,

i've several question about static files in web2py
1. what is the response.optimize_css & js used for?
response.optimize_css = 'concat,minify,inline'
response.optimize_js = 'concat,minify,inline'

i've defined it in models/db.py but when check with developer tools, the 
*.css file loaded is not minified (still have line feed / carriage return)

2. what is the zip_static_files.py used for?
i've ziped the static files which is affect the *.css & *.js when check 
with developer tools the file loaded is the original (unizpped files), why? 
is it normal?

3. the static file outside of web2py scaffolding apps is not cached on 
pythonanywhere, while in my computer the same web2py app which is used 
basic web2py application (rocket) is cached

4. what is the esponse.static_version used for?

thanks and best regards,
stifan

-- 
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] Call a javascript function from SQLFORM.smartgrid

2017-03-18 Thread 'FERNANDO VILLARROEL' via web2py-users
Dear All.
How a i can call a javascript function from a link of sqlform.grid
My controller:
  d=datetime.datetime.strptime(request.vars.desde, "%d/%m/%Y %H:%M:%S") \    if 
request.vars.desde else 
datetime.datetime.strptime(datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d
 00:00:00'), \        '%Y-%m-%d %H:%M:%S')    
h=datetime.datetime.strptime(request.vars.hasta, "%d/%m/%Y %H:%M:%S") \    if 
request.vars.hasta else 
datetime.datetime.strptime(datetime.datetime.strftime(datetime.datetime.now(),'%Y-%m-%d
 23:59:59'), \        '%Y-%m-%d %H:%M:%S')
    form = SQLFORM.factory(Field('desde','datetime', 
requires=IS_DATETIME(format='%Y-%m-%d %H:%M:%S'),default=d),                    
        Field('hasta','datetime',requires=IS_DATETIME(format='%Y-%m-%d 
%H:%M:%S'), default=h),formstyle='table2cols',method='POST')

 orderby=~db.mensajes.id    links=[dict(header='Detalle',body=lambda row: 
A(IMG(_src=URL(c='static',f='images/view.png'), _width=24, _height=24), 
_href=URL('showsms', args=[row.mensajes.id])))]    #links = [lambda row: A('Ver 
SMS',_href=URL("default","showsms",args=[row.id]))]    
query=(db.mensajes.id_cia==auth.user.cia) & (db.mensajes.fenvio>=d) & 
(db.mensajes.fenvio<=d)    
left=[db.estadosms.on(db.mensajes.estado==db.estadosms.id)]    
fields=[db.mensajes.id,db.mensajes.numero,db.mensajes.msg,db.mensajes.fecha,db.mensajes.fenvio,db.mensajes.fentrega,db.mensajes.respuesta,db.mensajes.frespuesta,db.estadosms.n$

    if form.process().accepted:
        d,h=form.vars.desde,form.vars.hasta
    query=(db.mensajes.id_cia==auth.user.cia) & (db.mensajes.fenvio>=d) & 
(db.mensajes.fenvio<=h)
    table=SQLFORM.smartgrid(db.mensajes, 
constraints=dict(mensajes=query),fields=fields,orderby=orderby,left=left,searchable=True,args=request.args[:1],links=links,
       exportclasses=dict(xml=False, html=False, json=False, tsv=False, 
tsv_with_hidden_cols=False),details=False,create=False,editable=False,deletable=False,csv=True,paginate=50,formstyle='bootstrap')
 return dict(form=form,table=table)




My View:{{extend 'layout.html'}}
Formulario Reporte Mensajes
     {{=form}}     {{=table}}


function getData(id) {    alert('blablabla');
}


How i call function getData(id) from link of sqlform.smartgrid and this 
function receive id row as parameter?




-- 
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] grid ondelete redirection

2017-03-18 Thread Andrea Fae'
Why the redirection is not working?

def mostra_evento():
evento_id=request.args(0)
query = (db.evento.id == evento_id)

db.evento.inizio.writable=db.evento.fine.writable=db.evento.risorsa.writable=db.evento.docente.writable=db.evento.materia.writable=False
db.evento.colore.readable=db.evento.colore.writable=False

# recupero la sede dell'evento
sede_evento = db(db.risorsa.id == 
db.evento.risorsa).select().first().risorsa.sede

exportcls = dict(csv_with_hidden_cols=False, html=False, json=False, 
tsv_with_hidden_cols=False, tsv=False)
callback = lambda *args: redirect(URL('default', 'index'))
form = SQLFORM.grid(query, args=[evento_id], 
fields=[db.evento.titolo,db.evento.inizio,db.evento.fine,db.evento.risorsa,db.evento.docente,db.evento.studenti],create=False,
 
details=True, editable=True, deletable=True, maxtextlength=60, 
exportclasses = exportcls, ondelete=callback)
return dict(form=form)


...and moreover the record isn't deleted!
For the true I'd like to redirect not on index but in "sched" wirh 
args=sede_evento

How todo?
Thanks

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


[web2py] Comparar hash dinamicamente em uma consulta

2017-03-18 Thread Rodrigo attique santana
Olá meus amigos.
Estou postando esta dúvida aqui pois não encontrei nada na net e acredito 
que possa ser de utilidade para muitos.

Tenho a seguinte estrutura:
Clientes = db.define_table('clientes'
   ,Field('nome')
   ,Field('documento',unique=True)
   ,Field('email_login','string')
   ,Field('senha','string')
   ,Field('telefone','list:string')
   ,Field('endereco','list:string')
   ,Field('status')
  )

Eu preciso fazer uma validação para este cliente pois o sistema externo me 
enviará um hash com um campo aleatório, email_login, senha, documento.
No banco de dados estes campos não estão criptografados eu preciso 
criptografá-los em tempo de consulta. Como em:

cliente = db(hashlib.md5(
  (Clientes.senha).hexdigest()==request.args(0)) | 
(Clientes.documento).hexdigest()==request.args(0)) | 
 (Clientes.email_login).hexdigest()==request.args(0)).select()

Tipo, ele tem que converter em md5 no memento da consulta. Como ein:

select * from clientes where md5(email_login) = argumento_hash or 

-- 
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] Access DB2/400 from IBM i (AS/400) PASE environment

2017-03-18 Thread Jim Steil
In this example he is connecting using a DB2 connector.  However, I'm
hoping to use the ibm_db_dbi connector and don't know how to specify it on
the dal connection.  He is using:

db = DAL('db2://DSN=MYDSN;UID=x;PWD=x', migrate_enabled=False)


I'm not sure what to put in place of the db2://DSN...

Anyone?

-Jim


On Fri, Mar 17, 2017 at 7:38 PM, António Ramos  wrote:

> maybe
> http://www.web2pyslices.com/slice/show/1474/calling-
> remote-program-on-db2-from-pythonweb2py
>
>
> 
>  Sem
> vírus. www.avast.com
> 
> <#m_-838279669736982895_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> 2017-03-17 21:06 GMT+00:00 Jim S :
>
>> Hi
>>
>> In a former (and somewhat current) life I was an AS/400 guy.  Our shop
>> still uses the platform though most of my time is spent on Python and
>> web2py now.
>>
>> Recently Python became available and officially supported on IBM i and
>> I'm trying to get web2py running there accessing the local DB2/400
>> database.  Using the local python on the system I can create a database
>> connection to the local database doing this:
>>
>> import ibm_db_dbi as db
>>
>> conn = db.connect(database='*LOCAL')
>>
>> I'm hoping to find an easy way to convert this into a connectstring for
>> the DAL so I can have my database created there.  The SQL-flavor it should
>> use would be the same as ODBC-flavored SQL.
>>
>> Can anyone give me a clue how to modify the DAL code to connect to my
>> db?  Any pointers to other articles or links would really be appreciated.
>> It would be exciting for me to get this working since I could then show RPG
>> developers how easy it would be to get an application on the web from the
>> AS/400 using python/web2py.
>>
>> -Jim
>>
>> --
>> 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.
>>
>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/qrlN5TSSBgs/unsubscribe.
> 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/d/optout.
>

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


[web2py] Re: Web2py admin > database datetime field error

2017-03-18 Thread lyn2py
I'm at testing stage, so sqlite, with plans to move over to postgresql, 
which I discovered to handle such nonexistent dates similarly.

Yes I can do a select on fields that do not have dates.


On Friday, March 17, 2017 at 8:15:10 AM UTC+8, Dave S wrote:
>
>
>
> On Thursday, March 16, 2017 at 3:59:47 PM UTC-7, lyn2py wrote:
>>
>>
>> I've loaded a bunch of data into the DB, and some of the tables and rows 
>> has the datetime field "-00-00"
>>
>> That caused web2py admin > this app's database to raise an error because 
>> of the datetime field:
>> "year is out of range"
>>
>>
>
> Which database are you using?
>  
>
>> (1) I tried to use filter_out on the field but it is not working. What 
>> can I do for this error?
>>
>> def filter_out_datetime(table, fields):
>> def check_datetime(self, dt):
>> if dt=='-00-00 00:00:00':
>> return ''
>> else:
>> return dt
>> for field in fields:
>> db[table][field].filter_out = lambda val, cdt=check_datetime: cdt(val)
>>
>> (2) Is there a way to retrieve all fields of "datetime" type in web2py? I 
>> have a number of such fields across the many tables. And may be adding 
>> more...
>>
>> (3) How do I use SQLCustomType for this use case?
>>
>>
>> Thank you!
>>
>
> Can you do a select where you request only the fields that are *not* 
> supposed to have dates (a name field, for instance)?
>
> /dps
>
>  
>

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


Re: [web2py] Re: change the size of a text field in a form

2017-03-18 Thread Maurice Waka
I had the same problem and changed but noted that the button 'submit' 
disappears.any help on how to sort this hout

On Tuesday, January 19, 2016 at 7:00:10 PM UTC+3, Richard wrote:
>
> And why not :
>
> 
> textarea {
> width: 1320px;
> height: 70px;
> }
> 
>
> You don't need js for that...
>
> Also consider make your textarea elastic there is js plugins for that...
>
> :)
>
> Richard
>
> On Tue, Jan 19, 2016 at 10:38 AM, Ron Chatterjee  > wrote:
>
>> Add this to your view:
>>
>> $('textarea').css('width','1320px').css('height','70px');
>>
>> Should change the size.
>>
>> On Thursday, May 17, 2012 at 5:59:11 PM UTC-4, Pystar wrote:
>>>
>>> I would suggest you using custom forms in your view and targeting the 
>>> attribute you wish to change with CSS. I find that approach more flexible.
>>>
>>> In the view:
>>>
>>> {{=form.custom.begin}}
>>> ###you can include normal HTML here to build up the form elements and 
>>> target it with CSS
>>> or
>>> 
>>> {{=form.custom.end}}
>>>
>>> hope that helps?
>>>
>>> On Wednesday, May 16, 2012 4:59:14 PM UTC+1, Marco Prosperi wrote:


 hello, how can I change the default size of a 'text' field in a form? 
 (at first appearance, not dragging the corner)

 thanks

 Marco

>>> -- 
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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