[web2py] Re: Issue with web2py load component

2017-01-13 Thread Gaurav Vichare
Thank You so much Anthony, It worked :)

- Gaurav


On Saturday, January 14, 2017 at 2:42:27 AM UTC+5:30, Anthony wrote:
>
> I consider this a router bug. The problem is that the list of functions 
> must include the function.extension combination in cases where URLs might 
> include extensions. So, in the router, change:
>
> functions = ['index', 'user', 'download', 'call', 'test_load']
>
> to:
>
> functions = ['index', 'user', 'download', 'call', 'test_load.load'
> ]
>
> More, generally, if you plan to call a given function with multiple 
> extensions (and possibly no extension), you must include all possibilities:
>
> functions = ['myfunc', 'myfunc.load', 'myfunc.json', 
> 'myfunc.xml']
>
> I made a pull request to fix this: 
> https://github.com/web2py/web2py/pull/1558
>
> Anthony
>
> On Friday, January 13, 2017 at 10:51:03 AM UTC-5, Gaurav Vichare wrote:
>>
>> I was unable to access http://127.0.0.1:8000/admin as well, so I first 
>> removed attached routes.py and then created w2p package. Chrome gave error 
>> "Too many redirects".
>>
>> Please find attached minimal app and web2py/routes.py file.
>> I am using web2py 2.14.6
>>
>> Thank You
>>
>> On Friday, January 13, 2017 at 8:34:42 PM UTC+5:30, Anthony wrote:
>>>
>>> Please attach a minimal app that reproduces the problem (along with 
>>> routes.py).
>>>
>>> On Thursday, January 12, 2017 at 12:35:41 PM UTC-5, Gaurav Vichare wrote:

 I have LOAD component in my application. I made changes in 
 web2py/routes.py file and made my application default application, 
 'default' controller and 'index' function as defaults. Also added function 
 list of default.py controller in routes.py to distinguish between args and 
 function name(
 https://groups.google.com/d/msg/web2py/yi5rPK4APKs/rVBg9AiShPUJ). Now 
 when I open my app (http://127.0.0.1:8000/  or 
 http://127.0.0.1:8000/test/default/index), load component div loads 
 complete app in it, and this goes in loop. 

 Here is routes.py and minimal code

 #routes.py

 routers = dict(

 # base router
 BASE=dict(
 default_application='test',
 default_controller = 'default',
 default_function = 'index',
 functions = ['index', 'user', 'download', 'call',
  'test_load'],
 ),)


 --

 # default.pydef index():
 return dict(message=T('Welcome to web2py!'))
 def test_load():
 return dict(message=T('This is sample component'))

 ---

 # Views{{extend 
 'layout.html'}}{{=message}}{{=LOAD('default','test_load.load',ajax=True)}}

 {{=message}}


 Screenshot:


 

 Please help me to solve this issue.

 Thank You
 - Gaurav

>>>

-- 
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: FPDF

2017-01-13 Thread Áureo Dias Neto
I want to concatenate two functions, thats all one, return a pdf.. and i
want to show this 2 pages only in one

2017-01-13 23:02 GMT-02:00 Áureo Dias Neto :

> this is my all code of first page
> i want another page, totally different of this, in the same pdf
>
> def ticketliberacao():
> from gluon.contrib.pyfpdf import FPDF, HTMLMixin
> by_cdc_search = db(db.veiculos.CDC==request.args(0)).select(db.veiculos.
> ALL).first()
> if by_cdc_search.FlagSaida!=True:
> redirect(URL('default', 'docs',args=('naoliberado')))
>
> class MyFPDF(FPDF, HTMLMixin):
> def header(self):
> self.set_title("TICKET")
> self.set_font('Arial', 'B', 11)
> self.set_y(33)
> self.cell(0, 0, "", 1, 0, 'L')
> self.set_xy(10,40)
> self.write(0,"TICKET DE LIBERAÇÃO".decode('utf-8'))
> self.set_font('Arial', '', 11)
> self.set_xy(144,40)
> self.write(0,"Via do Responsável do veículo".decode('utf-8'))
> logo = os.path.join(request.folder, "static", "images", "logo_patio.png")
> self.image(logo, 10, 12)
> logo = os.path.join(request.folder,"static", "images",
> "logo_scov_preto.png")
> self.image(logo, 150, 12)
>
> self.ln(10)
> self.set_font('Arial', '', 13)
> self.set_text_color(255,255,255)
> self.cell(50,7,['CDC nº: '+by_cdc_search.CDC][-1].
> decode('utf-8'),1,0,'L',True)
> cor=db(db.cores.id==by_cdc_search.Cor).select(db.cores.Cor).first()
> self.cell(140,7,[by_cdc_search.MarcaModelo +' - '+
> cor.Cor][-1].decode('utf-8'),1,0,'R',True)
> self.set_text_color(0,0,0)
> self.ln(13)
> liberadopara=db(db.pessoas.id==by_cdc_search.LiberadoPara).
> select().first()
> self.multi_cell(190,7,['Data da Liberação: 
> '+by_cdc_search.DataSaida.strftime("%d/%m/%Y")+'
> - '+by_cdc_search.HoraSaida + '\nLiberado Por: '+by_cdc_search.LiberadoPor
> + '\nLiberado Para: '+ '('+liberadopara.Tipo+') ' + liberadopara.Nome +
> '\nChaves: '+by_cdc_search.Chaves+' | Vaga: '+by_cdc_search.Vaga][-1].
> decode('utf-8'),0,1,'L')
> self.ln(13)
> self.cell(110,7,['Observações da Saída:'][-1].decode('utf-8'),0,0,'L')
> self.cell(80,7,['Confirmação da saída do pátio'][-1].decode('utf-8'),0,
> 1,'L')
> self.set_font('Arial','',8)
> self.cell(90,7,['NÃO HÁ OBSERVAÇÕES' if by_cdc_search.ObservacoesSaida==''
> else by_cdc_search.ObservacoesSaida][-1].decode('utf-8'),0,1,'L')
> self.set_x(120)
> self.cell(80,7,['__'][-1].decode('utf-8'),0
> ,1,'L')
> self.set_x(120)
> self.set_font('Arial','',10)
> self.cell(80,7,['Responsável da portaria'][-1].decode('utf-8'),0,0,'L')
> self.ln(15)
> self.write(0,'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - - - - - - - - - - - - -'.decode('utf-8'))
> self.set_font('Arial', 'B', 11)
> self.set_y(150)
> self.ln(14)
> self.cell(0, 0, "", 1, 0, 'L')
> self.set_xy(10,170)
> self.write(0,"TICKET DE LIBERAÇÃO".decode('utf-8'))
> self.set_font('Arial', '', 11)
> self.set_xy(170,170)
> self.write(0,"Via do Pátio".decode('utf-8'))
> logo = os.path.join(request.folder,"static", "images", "logo_patio.png")
> self.image(logo, 10, 144)
> logo = os.path.join(request.folder, "static", "images",
> "logo_scov_preto.png")
> self.image(logo, 150, 144)
>
> self.ln(10)
> self.set_font('Arial', '', 13)
> self.set_text_color(255,255,255)
> self.cell(50,7,['CDC nº: '+by_cdc_search.CDC][-1].
> decode('utf-8'),1,0,'L',True)
> cor=db(db.cores.id==by_cdc_search.Cor).select(db.cores.Cor).first()
> self.cell(140,7,[by_cdc_search.MarcaModelo +' - '+
> cor.Cor][-1].decode('utf-8'),1,0,'R',True)
> self.set_text_color(0,0,0)
> self.ln(13)
> self.multi_cell(190,7,['Data da Liberação: 
> '+by_cdc_search.DataSaida.strftime("%d/%m/%Y")+'
> - '+by_cdc_search.HoraSaida + '\nLiberado Por: '+by_cdc_search.LiberadoPor
> + '\nLiberado Para:'][-1].decode('utf-8'),0,1,'L')
> liberadopara=db(db.pessoas.id==by_cdc_search.LiberadoPara).
> select().first()
> self.cell(190,7,['('+liberadopara.Tipo+') ' +
> liberadopara.Nome][-1].decode('utf-8'),0,1,'L')
> self.cell(190,7,['Chaves: '+by_cdc_search.Chaves+' | Vaga:
> '+by_cdc_search.Vaga][-1].decode('utf-8'),0,0,'L')
> self.ln(13)
> self.cell(110,7,['Observações da Saída:'][-1].decode('utf-8'),0,1,'L')
> self.set_font('Arial','',8)
> self.cell(90,7,['NÃO HÁ OBSERVAÇÕES' if by_cdc_search.ObservacoesSaida==''
> else by_cdc_search.ObservacoesSaida][-1].decode('utf-8'),0,0,'L')
> fotofrente=db(db.fotos.Veiculo.like(by_cdc_search.id) &
> db.fotos.Tipo.like('Dianteira')).select().first()
> if (fotofrente != None):
> arquivo=fotofrente.Arquivo
> fotolocal = os.path.join(request.folder, "uploads", arquivo)
> self.image(fotolocal,120,190,80,50)
> self.set_y(268)
> self.set_font('Arial','',12)
> self.cell(110,7,['___
>  _'][-1].decode('utf-8'),0,1,'L')
> self.cell(110,1,['Responsável pela separação/entrega
>  Responsável do veículo'][-1].decode('utf-8'),0,1,'L')
>
> pdf = MyFPDF()
> pdf.add_page()
> 

Re: [web2py] Re: FPDF

2017-01-13 Thread Áureo Dias Neto
this is my all code of first page
i want another page, totally different of this, in the same pdf

def ticketliberacao():
from gluon.contrib.pyfpdf import FPDF, HTMLMixin
by_cdc_search =
db(db.veiculos.CDC==request.args(0)).select(db.veiculos.ALL).first()
if by_cdc_search.FlagSaida!=True:
redirect(URL('default', 'docs',args=('naoliberado')))

class MyFPDF(FPDF, HTMLMixin):
def header(self):
self.set_title("TICKET")
self.set_font('Arial', 'B', 11)
self.set_y(33)
self.cell(0, 0, "", 1, 0, 'L')
self.set_xy(10,40)
self.write(0,"TICKET DE LIBERAÇÃO".decode('utf-8'))
self.set_font('Arial', '', 11)
self.set_xy(144,40)
self.write(0,"Via do Responsável do veículo".decode('utf-8'))
logo = os.path.join(request.folder, "static", "images", "logo_patio.png")
self.image(logo, 10, 12)
logo = os.path.join(request.folder,"static", "images",
"logo_scov_preto.png")
self.image(logo, 150, 12)

self.ln(10)
self.set_font('Arial', '', 13)
self.set_text_color(255,255,255)
self.cell(50,7,['CDC nº:
'+by_cdc_search.CDC][-1].decode('utf-8'),1,0,'L',True)
cor=db(db.cores.id==by_cdc_search.Cor).select(db.cores.Cor).first()
self.cell(140,7,[by_cdc_search.MarcaModelo +' - '+
cor.Cor][-1].decode('utf-8'),1,0,'R',True)
self.set_text_color(0,0,0)
self.ln(13)
liberadopara=db(db.pessoas.id==by_cdc_search.LiberadoPara).select().first()
self.multi_cell(190,7,['Data da Liberação:
'+by_cdc_search.DataSaida.strftime("%d/%m/%Y")+' -
'+by_cdc_search.HoraSaida + '\nLiberado Por: '+by_cdc_search.LiberadoPor +
'\nLiberado Para: '+ '('+liberadopara.Tipo+') ' + liberadopara.Nome +
'\nChaves: '+by_cdc_search.Chaves+' | Vaga:
'+by_cdc_search.Vaga][-1].decode('utf-8'),0,1,'L')
self.ln(13)
self.cell(110,7,['Observações da Saída:'][-1].decode('utf-8'),0,0,'L')
self.cell(80,7,['Confirmação da saída do
pátio'][-1].decode('utf-8'),0,1,'L')
self.set_font('Arial','',8)
self.cell(90,7,['NÃO HÁ OBSERVAÇÕES' if by_cdc_search.ObservacoesSaida==''
else by_cdc_search.ObservacoesSaida][-1].decode('utf-8'),0,1,'L')
self.set_x(120)
self.cell(80,7,['__'][-1].decode('utf-8'),0
,1,'L')
self.set_x(120)
self.set_font('Arial','',10)
self.cell(80,7,['Responsável da portaria'][-1].decode('utf-8'),0,0,'L')
self.ln(15)
self.write(0,'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -'.decode('utf-8'))
self.set_font('Arial', 'B', 11)
self.set_y(150)
self.ln(14)
self.cell(0, 0, "", 1, 0, 'L')
self.set_xy(10,170)
self.write(0,"TICKET DE LIBERAÇÃO".decode('utf-8'))
self.set_font('Arial', '', 11)
self.set_xy(170,170)
self.write(0,"Via do Pátio".decode('utf-8'))
logo = os.path.join(request.folder,"static", "images", "logo_patio.png")
self.image(logo, 10, 144)
logo = os.path.join(request.folder, "static", "images",
"logo_scov_preto.png")
self.image(logo, 150, 144)

self.ln(10)
self.set_font('Arial', '', 13)
self.set_text_color(255,255,255)
self.cell(50,7,['CDC nº:
'+by_cdc_search.CDC][-1].decode('utf-8'),1,0,'L',True)
cor=db(db.cores.id==by_cdc_search.Cor).select(db.cores.Cor).first()
self.cell(140,7,[by_cdc_search.MarcaModelo +' - '+
cor.Cor][-1].decode('utf-8'),1,0,'R',True)
self.set_text_color(0,0,0)
self.ln(13)
self.multi_cell(190,7,['Data da Liberação:
'+by_cdc_search.DataSaida.strftime("%d/%m/%Y")+' -
'+by_cdc_search.HoraSaida + '\nLiberado Por: '+by_cdc_search.LiberadoPor +
'\nLiberado Para:'][-1].decode('utf-8'),0,1,'L')
liberadopara=db(db.pessoas.id==by_cdc_search.LiberadoPara).select().first()
self.cell(190,7,['('+liberadopara.Tipo+') ' +
liberadopara.Nome][-1].decode('utf-8'),0,1,'L')
self.cell(190,7,['Chaves: '+by_cdc_search.Chaves+' | Vaga:
'+by_cdc_search.Vaga][-1].decode('utf-8'),0,0,'L')
self.ln(13)
self.cell(110,7,['Observações da Saída:'][-1].decode('utf-8'),0,1,'L')
self.set_font('Arial','',8)
self.cell(90,7,['NÃO HÁ OBSERVAÇÕES' if by_cdc_search.ObservacoesSaida==''
else by_cdc_search.ObservacoesSaida][-1].decode('utf-8'),0,0,'L')
fotofrente=db(db.fotos.Veiculo.like(by_cdc_search.id) &
db.fotos.Tipo.like('Dianteira')).select().first()
if (fotofrente != None):
arquivo=fotofrente.Arquivo
fotolocal = os.path.join(request.folder, "uploads", arquivo)
self.image(fotolocal,120,190,80,50)
self.set_y(268)
self.set_font('Arial','',12)
self.cell(110,7,['___
   _'][-1].decode('utf-8'),0,1,'L')
self.cell(110,1,['Responsável pela separação/entrega
 Responsável do veículo'][-1].decode('utf-8'),0,1,'L')

pdf = MyFPDF()
pdf.add_page()
response.headers['Content-Type'] = 'application/pdf'
return pdf.output(dest='S')


2017-01-06 16:03 GMT-02:00 Edwood :

> It should work unless there is something in the HTML markup messing with
> the output.  I tried this similar code with file output instead of stream
> and it did what you expected (as I understood it):
>
> from gluon.contrib.pyfpdf import FPDF, HTMLMixin
> from datetime import datetime
>
> class 

[web2py] Re: Issue with web2py load component

2017-01-13 Thread Anthony
I consider this a router bug. The problem is that the list of functions 
must include the function.extension combination in cases where URLs might 
include extensions. So, in the router, change:

functions = ['index', 'user', 'download', 'call', 'test_load']

to:

functions = ['index', 'user', 'download', 'call', 'test_load.load']

More, generally, if you plan to call a given function with multiple 
extensions (and possibly no extension), you must include all possibilities:

functions = ['myfunc', 'myfunc.load', 'mfunc.json', 'myfunc.xml'
]

I made a pull request to fix this: 
https://github.com/web2py/web2py/pull/1558

Anthony

On Friday, January 13, 2017 at 10:51:03 AM UTC-5, Gaurav Vichare wrote:
>
> I was unable to access http://127.0.0.1:8000/admin as well, so I first 
> removed attached routes.py and then created w2p package. Chrome gave error 
> "Too many redirects".
>
> Please find attached minimal app and web2py/routes.py file.
> I am using web2py 2.14.6
>
> Thank You
>
> On Friday, January 13, 2017 at 8:34:42 PM UTC+5:30, Anthony wrote:
>>
>> Please attach a minimal app that reproduces the problem (along with 
>> routes.py).
>>
>> On Thursday, January 12, 2017 at 12:35:41 PM UTC-5, Gaurav Vichare wrote:
>>>
>>> I have LOAD component in my application. I made changes in 
>>> web2py/routes.py file and made my application default application, 
>>> 'default' controller and 'index' function as defaults. Also added function 
>>> list of default.py controller in routes.py to distinguish between args and 
>>> function name(
>>> https://groups.google.com/d/msg/web2py/yi5rPK4APKs/rVBg9AiShPUJ). Now 
>>> when I open my app (http://127.0.0.1:8000/  or 
>>> http://127.0.0.1:8000/test/default/index), load component div loads 
>>> complete app in it, and this goes in loop. 
>>>
>>> Here is routes.py and minimal code
>>>
>>> #routes.py
>>>
>>> routers = dict(
>>>
>>> # base router
>>> BASE=dict(
>>> default_application='test',
>>> default_controller = 'default',
>>> default_function = 'index',
>>> functions = ['index', 'user', 'download', 'call',
>>>  'test_load'],
>>> ),)
>>>
>>>
>>> --
>>>
>>> # default.pydef index():
>>> return dict(message=T('Welcome to web2py!'))
>>> def test_load():
>>> return dict(message=T('This is sample component'))
>>>
>>> ---
>>>
>>> # Views{{extend 
>>> 'layout.html'}}{{=message}}{{=LOAD('default','test_load.load',ajax=True)}}
>>>
>>> {{=message}}
>>>
>>>
>>> Screenshot:
>>>
>>>
>>> 
>>>
>>> Please help me to solve this issue.
>>>
>>> Thank You
>>> - Gaurav
>>>
>>

-- 
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: Order of form.vars not same as they appear in form

2017-01-13 Thread Rahul Priyadarsi
Yes form.fields works!
Thank you very much

On 13 January 2017 at 01:12, Anthony  wrote:

> form.vars is a dict-like object, so not guaranteed to return keys in any
> particular order. If the form is based on a db table, you can iterate
> through db.table._fields. The form object also includes the list of field
> names in form.fields.
>
> Anthony
>
>
> On Thursday, January 12, 2017 at 1:37:03 PM UTC-5, Rahul Priyadarsi wrote:
>>
>> Currently I see that the order in which the fields appear in form is not
>> same when i iterate through form.vars
>> I am using SQLFORM.
>>
>> So how do I get the form.vars so that they appear in same order as they
>> do on the form?
>>
> --
> 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/fZygOaWseek/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.
>



-- 
*Cheers,*
*RAHUL PRIYADARSI*

-- 
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: Call functions from other applications without network requests

2017-01-13 Thread Anthony


> You can use the DAL from modules as well. As Niphlod suggested, you can 
>> also use the scheduler to schedule and run a task in the context of another 
>> app, though that might not be as fast as you'd like, as even setting 
>> immediate=True, it could take up to "heartbeat" seconds for the worker to 
>> pick up and execute the task, and then you have to check for the results.
>>
>>
> I can use the DAL, but can I use the "db" object defined in my models 
> file?  Or do you mean I could use the DAL if I rewrote my other app to use 
> a "model-less" approach where the models were defined in some other manner?
>

Yes, the point was that you can put whatever you want into modules, which 
means the code can be shared across apps. If you want to share the code to 
create a database connection object, then put that code in a module. Here 
is the basic idea:

/app1/modules/db.py:

import os
from gluon import *

def dal(**kwargs):
web2py_folder = current.request.env.applications_parent
db_folder = os.path.abspath(os.path.join(web2py_folder, 'applications',
 'app1', 'databases'))
return DAL('sqlite://storage.sqlite', folder=db_folder, **kwargs)

def define_tables(db):
db.define_table('table1', Field('field1'))

/app2/models/db.py:

from applications.app1.modules.db import dal, define_tables

app1_db = dal()
define_tables(app1_db)

# Now use app1_db as usual.

Of course, the module defining the database connection and tables doesn't 
have to be in the /modules folder of any particular application, nor does 
the folder specified as the "folder" argument -- that can all be 
centralized somewhere if desired.

Also, note there is a way to share models defined in the model files of 
another app, though with limitations. See 
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Using-DAL-without-define-tables.
 
That approach can be used to access model definitions from app1 model files 
from within app2 model files. However, the model definitions within app2 
will only include the table and field attributes that can be gleaned from 
the *.table migration files in app1's /databases folder, which only 
includes attributes needed for the database schema definition (i.e., it 
doesn't include any web2py-specific attributes, such as validators, labels, 
represent functions, etc.).

Anthony

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


[web2py] Re: Issue with web2py load component

2017-01-13 Thread Anthony
Please attach a minimal app that reproduces the problem (along with 
routes.py).

On Thursday, January 12, 2017 at 12:35:41 PM UTC-5, Gaurav Vichare wrote:
>
> I have LOAD component in my application. I made changes in 
> web2py/routes.py file and made my application default application, 
> 'default' controller and 'index' function as defaults. Also added function 
> list of default.py controller in routes.py to distinguish between args and 
> function name(
> https://groups.google.com/d/msg/web2py/yi5rPK4APKs/rVBg9AiShPUJ). Now 
> when I open my app (http://127.0.0.1:8000/  or 
> http://127.0.0.1:8000/test/default/index), load component div loads 
> complete app in it, and this goes in loop. 
>
> Here is routes.py and minimal code
>
> #routes.py
>
> routers = dict(
>
> # base router
> BASE=dict(
> default_application='test',
> default_controller = 'default',
> default_function = 'index',
> functions = ['index', 'user', 'download', 'call',
>  'test_load'],
> ),)
>
>
> --
>
> # default.pydef index():
> return dict(message=T('Welcome to web2py!'))
> def test_load():
> return dict(message=T('This is sample component'))
>
> ---
>
> # Views{{extend 
> 'layout.html'}}{{=message}}{{=LOAD('default','test_load.load',ajax=True)}}
>
> {{=message}}
>
>
> Screenshot:
>
>
> 
>
> Please help me to solve this issue.
>
> Thank You
> - Gaurav
>

-- 
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: Issue with web2py load component

2017-01-13 Thread Gaurav Vichare
There is no  {{extend 'index.html'}} in test_load.load.  

I faced similar issue once, when I added {{extend 'layout.html'}} inside 
load view. But this time, I have  {{extend 'layout.html'}} only in 
index.html
Thanks for the reply!

On Friday, January 13, 2017 at 6:54:53 PM UTC+5:30, Leonel Câmara wrote:
>
> Are you sure test_load.load doesn't have an {{extend 'index.html'}} there?
>

-- 
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: Issue with web2py load component

2017-01-13 Thread Leonel Câmara
Are you sure test_load.load doesn't have an {{extend 'index.html'}} there?

-- 
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: Are executesql parameters escaped?

2017-01-13 Thread Jorrit
Thank you!


On Friday, January 13, 2017 at 8:59:35 AM UTC+1, Niphlod wrote:
>
> when you do that, you're passing 'string'.format() (which is a string) to 
> executesql.
>
> the proper way is to use parameters!!!
>
> db.executesql('select * from auth_user where id = ?', placeholders=(1, ), 
> as_dict=True)
>
> the nitty gritty details of the syntax depend on the driver parameter
>
> On Thursday, January 12, 2017 at 2:46:28 PM UTC+1, Jorrit wrote:
>>
>> When I use *db.executesql* like so:
>>
>> birthdays = db.executesql("SELECT * FROM auth_user WHERE  
>> DAYOFYEAR(curdate() -2) < dayofyear(dateOfBirth) "
>>   "AND DAYOFYEAR(curdate()) +7 >= 
>> dayofyear(dateOfBirth) "
>>   "AND employeeState_id = {1} AND location_id IN 
>> (SELECT location_id FROM clusterLocation WHERE cluster_id={0}) ORDER BY 
>> MONTH(dateOfBirth), "
>>   "DAY(dateOfBirth);".format(cluster, active_id), 
>> as_dict=True)
>>
>>
>> ...are the cluster and active_id parameters SQL-escaped? If not what is 
>> the best way to do this?
>>
>

-- 
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: How to manually construct IS_IN_DB for FK with foreign_table _format?

2017-01-13 Thread Jurgis Pralgauskis
SOLVED:

sf.requires = IS_IN_DB( db(query), db.*other_*table.*_id* , 
label=other_table._format,  left=left, distinct=True )

instead of

sf.requires = IS_IN_DB( db(query), db.table.*other_id* , 
label=other_table._format,  left=left, distinct=True )

:)

On Friday, January 13, 2017 at 11:13:10 AM UTC+2, Jurgis Pralgauskis wrote:
>
>
>
> Hi, 
>
> I have query  to get subset of stuff (and I want to have the same nice 
> options widget as is for default foreign keys)
>
> sf.requires = IS_IN_DB( db(query), db.table.other_id , 
> label=other_table._format,  left=left, distinct=True )
>
>
> but I get
>
> form = SQLFORM.factory( *updatables, table_name="jurgio")
>   File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 1809, in factory
> **attributes)
>   File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 1286, in __init__
> inp = field.widget(field, default)
>   File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 388, in widget
> options = requires[0].options()
>   File "/home/jurgis/dev/web2py_src/gluon/validators.py", line 598, in options
> self.build_set()
>   File "/home/jurgis/dev/web2py_src/gluon/validators.py", line 573, in 
> build_set
> fields = [table[k] for k in self.fieldnames]
>   File "/home/jurgis/dev/web2py_src/gluon/packages/dal/pydal/objects.py", 
> line 510, in __getitem__
> raise KeyError(key)
> KeyError: 'role'
>
>
>
> I could do select myself and construct IS_IN_SET -- but how can I fluently 
> get all the fields needed for   foreign _format (if  _format  varies 
> depending on other_table)? 
>
> any suggestions?
>
> 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] Customising Calendar widgets in Start Date and End date of SmartGrid

2017-01-13 Thread Amit Kumar Modak
Hello,

I am using Smartgrid in which there are two date fields Start Date and End 
Date.
Is it possible to make in Start Date field Calendar widget only dates ahead 
of today enabled and in End Date only dates ahead of date selected in Start 
Date is enabled.


Regards,
Amit

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


[web2py] How to manually construct IS_IN_DB for FK with foreign_table _format?

2017-01-13 Thread Jurgis Pralgauskis


Hi, 

I have query  to get subset of stuff (and I want to have the same nice 
options widget as is for default foreign keys)

sf.requires = IS_IN_DB( db(query), db.table.other_id , 
label=other_table._format,  left=left, distinct=True )


but I get

form = SQLFORM.factory( *updatables, table_name="jurgio")
  File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 1809, in factory
**attributes)
  File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 1286, in __init__
inp = field.widget(field, default)
  File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 388, in widget
options = requires[0].options()
  File "/home/jurgis/dev/web2py_src/gluon/validators.py", line 598, in options
self.build_set()
  File "/home/jurgis/dev/web2py_src/gluon/validators.py", line 573, in build_set
fields = [table[k] for k in self.fieldnames]
  File "/home/jurgis/dev/web2py_src/gluon/packages/dal/pydal/objects.py", line 
510, in __getitem__
raise KeyError(key)
KeyError: 'role'



I could do select myself and construct IS_IN_SET -- but how can I fluently 
get all the fields needed for   foreign _format (if  _format  varies 
depending on other_table)? 

any suggestions?

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] Re: Are executesql parameters escaped?

2017-01-13 Thread Niphlod
when you do that, you're passing 'string'.format() (which is a string) to 
executesql.

the proper way is to use parameters!!!

db.executesql('select * from auth_user where id = ?', placeholders=(1, ), 
as_dict=True)

the nitty gritty details of the syntax depend on the driver parameter

On Thursday, January 12, 2017 at 2:46:28 PM UTC+1, Jorrit wrote:
>
> When I use *db.executesql* like so:
>
> birthdays = db.executesql("SELECT * FROM auth_user WHERE  DAYOFYEAR(curdate() 
> -2) < dayofyear(dateOfBirth) "
>   "AND DAYOFYEAR(curdate()) +7 >= 
> dayofyear(dateOfBirth) "
>   "AND employeeState_id = {1} AND location_id IN 
> (SELECT location_id FROM clusterLocation WHERE cluster_id={0}) ORDER BY 
> MONTH(dateOfBirth), "
>   "DAY(dateOfBirth);".format(cluster, active_id), 
> as_dict=True)
>
>
> ...are the cluster and active_id parameters SQL-escaped? If not what is 
> the best way to do this?
>

-- 
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.