[web2py] Re: want to lookup a phone number in a db

2021-10-19 Thread A3
Thanks Jim,
Didn't realize that it will retrieve all. Actually the database is not so 
big at the moment so I don't notice any performance problems. 
Better try your suggestions before it has grown to big. 
Cheers - A3
Op dinsdag 19 oktober 2021 om 16:50:13 UTC+2 schreef Jim S:

> I don't think this is a good solution because it is retrieving all the 
> rows from the database and then iterating over them to find a match.
>
> Do you have the option of sanitizing a phone number before it is stored in 
> the database?  Or, could you create a new 'sanitized' phone number field 
> that you could select over?
>
> Either that, or take the value you're looking for an parse it in to all 
> the possible ways it could be stored and then search for those options.
>
> Ex
>
> phone_numbers = ['+31123456789', '+31-(0)123 456 789', '+31-0 123 456 789', 
> etc.]
>
> db(db.table.phonenumber.belongs(phone_numbers)).select()
>
> -Jim
>
>
> On Tuesday, October 19, 2021 at 2:17:55 AM UTC-5 A3 wrote:
>
>> finally I tried:
>> db((db.table.id >0)).select(db.table.phonenumber).find(lambda rw: 
>> rw.phonenumber.replace("-","").replace(" ","").replace("(0)","")==caller if 
>> rw is not None else None)
>> Initially this gave an error TypeError: 'NoneType' object has no 
>> attribute '__getitem__' 
>> <https://www.ursadina.nl/admin/default/errors/gtd1#>
>> The problem was that the field phonenumber could also be None. 
>> Solution:  in the table definition :set default to ""  and update all 
>> existing None values to "" 
>>
>> Any other suggestions?  
>> Op maandag 18 oktober 2021 om 15:37:24 UTC+2 schreef A3:
>>
>>> Want to lookup a phone number in a db table 
>>> the value to lookup is  e.g.  caller = "+31123456789"
>>> Phone numbers in db field can contain + - .  and also () and is not very 
>>> consistent.
>>> could look like:  phonenumber = "+31-(0)123 456 789" 
>>>
>>> would like something: 
>>> db(db.table.phonenumber.like(caller)).select()
>>>
>>> Any suggestions? 
>>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/668df9f3-9f28-4709-86e2-a707c5666b07n%40googlegroups.com.


[web2py] Re: want to lookup a phone number in a db

2021-10-19 Thread A3
finally I tried:
db((db.table.id >0)).select(db.table.phonenumber).find(lambda rw: 
rw.phonenumber.replace("-","").replace(" ","").replace("(0)","")==caller if 
rw is not None else None)
Initially this gave an error TypeError: 'NoneType' object has no attribute 
'__getitem__' <https://www.ursadina.nl/admin/default/errors/gtd1#>
The problem was that the field phonenumber could also be None. 
Solution:  in the table definition :set default to ""  and update all 
existing None values to "" 

Any other suggestions?  
Op maandag 18 oktober 2021 om 15:37:24 UTC+2 schreef A3:

> Want to lookup a phone number in a db table 
> the value to lookup is  e.g.  caller = "+31123456789"
> Phone numbers in db field can contain + - .  and also () and is not very 
> consistent.
> could look like:  phonenumber = "+31-(0)123 456 789" 
>
> would like something: 
> db(db.table.phonenumber.like(caller)).select()
>
> Any suggestions? 
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/28a9210d-19c1-4adc-88f0-0fececdfeab5n%40googlegroups.com.


[web2py] Re: message in register form

2021-10-18 Thread A3
You can edit the view:  default/user.html
  
add some html code like you would do in a standard html doc

Op maandag 11 oktober 2021 om 20:49:45 UTC+2 schreef lucas:

> hello one and all,
>
> how can i add a simple message to the /user/register form?  just plain 
> text with a link in there also.
>
> thank you in advance, lucas
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/a98ec8a2-4130-49ac-b0b1-7ee26860deeen%40googlegroups.com.


[web2py] want to lookup a phone number in a db

2021-10-18 Thread A3
Want to lookup a phone number in a db table 
the value to lookup is  e.g.  caller = "+31123456789"
Phone numbers in db field can contain + - .  and also () and is not very 
consistent.
could look like:  phonenumber = "+31-(0)123 456 789" 

would like something: 
db(db.table.phonenumber.like(caller)).select()

Any suggestions? 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f00ee6df-cf92-40bb-871b-32b63a91fca1n%40googlegroups.com.


[web2py] how to run a scheduler with virtualenv

2019-10-14 Thread A3
Currently I run Web2py using wsgi / Apache using virtualenv in the 
wsgihandler.py 
I also  use a scheduler using  web2py.py --nogui -K myap
Sofar I didn't pay attention to the virtualenv  as I didn't have any 
problems.  
Probably because the python version in the virtualenv is equal to the 
system python version.
I wonder how I can easily use the same virtualenv for the scheduler?
Is it simple like this: 
  source ./python_env/bin/activate
  web2py.py --nogui -K myap
?

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/1469d93f-cbc8-4958-b4b0-e99081ee65b3%40googlegroups.com.


[web2py] Re: STYLE() function has been changed in 2.17.2

2018-10-30 Thread A3
 Python version 2.7.6 

Op dinsdag 30 oktober 2018 20:28:53 UTC+1 schreef Dave S:
>
>
>
> On Tuesday, October 30, 2018 at 4:15:49 AM UTC-7, A3 wrote:
>>
>> I recently upgraded to 2.17.2 and now I noticed that some of my apps 
>> functions don't work anymore.
>> in the past I used e.g.: STYLE(XML('body {color: white}')) 
>> this caused an error: (Expected bytes)
>>
>> after removing XML() you can use STYLE('body {color: white}')
>> but it gives the following output: 
>> <!--/*--><![CDATA[/*><!--*/ tree {color: red} /*]]>*/-->
>>
>> Is this an intended change or a bug?
>>
>>
> What version of Python are you running on?
>
> /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.


[web2py] STYLE() function has been changed in 2.17.2

2018-10-30 Thread A3
I recently upgraded to 2.17.2 and now I noticed that some of my apps 
functions don't work anymore.
in the past I used e.g.: STYLE(XML('body {color: white}')) 
this caused an error: (Expected bytes)

after removing XML() you can use STYLE('body {color: white}')
but it gives the following output: 


Is this an intended change or a bug?




-- 
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: SQLFORM.grid selectable with multiple buttons behaves strange

2017-09-07 Thread A3

After researching the forum and other locations I found the following 
"solution":
the raise HTTP(200) seems to break the running submit code. As suggested 
elsewhere the download should be invoked on another page. So first redirect 
and than start the download.

 I replaced: 
 selectable = [('Download selected PDFs as ZIP',lambda row : 
mapping_multiple(row)), 
   ('Download selected as EXCEL',lambda 
row : mapping_multiple_excel(row))
  ]
by:
selectable = [('Download selected PDFs as ZIP',lambda row 
:redirect(URL('default', 'downloading',

   vars=dict(ids=row, 

 message = 'zipped PDF files',

 target='make_pdf_zip',
  ('Download selected as EXCEL', lambda row 
:redirect(URL('default', 'downloading',

   vars=dict(ids=row, 

 message = 'excel',

 target='make_excel', ]

add a controller function and view

def downloading():
ids = request.vars['ids']
target = request.vars['target']
if ids<>None and ids<>'' and len(ids)<>0:
return dict(message=T("Downloading reports"), ids=ids, 
target=target)
return dict(message=T("Nothing to download"), ids=None, target='')

The view downloading.html
{{extend 'layout.html'}}
Downloading
{{=message}}
$(function() {
   {{if ids<>None:}}

window.location.replace("{{=URL('default',target,vars=dict(ids=ids))}}");
   {{pass}}
window.setTimeout(function(){
window.history.back();
}, 2000);
  });



and two target functions: 
def make_excel():
ids = request.vars['ids']
etc. make the excel file etc.
raise HTTP(200, buff.getvalue(), **response.headers)

def make_zip_pdf():
   ids = request.vars['ids']
   etc. make the pdfs and zip'm etc.
   raise HTTP(200, buff.getvalue(), **response.headers)

After clicking the appropriate button a new page is shown with the message 
and the file is downloaded. After 2 seconds the previous page is shown.

Not really elegant but it works.  

anybody in for suggestions?

-- 
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] SQLFORM.grid selectable with multiple buttons behaves strange

2017-09-04 Thread A3
When using SQLFORM.grid  selectable with multiple button I get the 
following phenomena:

- When I click the buttons the associated action is properly performed. 
which is the download of a zip file or excel file.
- After the download the button text of the second button changed and 
becomes equal to the first one.  
- When I click the button again, no action is performed but the text 
changes back to the original.

- If there is no row selected a flash message is show to instruct the user. 
In this case the buttons remain unchanged.  

- The problem is probably related to the " raise HTTP" part of the download 
see below.

- I do not understand what happens after the raise HTTP.

Can anybody help me with this?

Thanks, A3


Here is a fragment of the code:

@auth.requires_login()
def view_report_simple():
qr = (db.reports.Customerid=="020030")
fields = (db.reports.id,db.reports.Reportdate, db.reports.Reportnr, 
db.reports.Reference,db.reports.Sample_date)
list_of_names_to_include = ['Reportdate','Reportnr','Reference']
[setattr(f, 'readable', False) for f in db.reports if f.name not in 
list_of_names_to_include]
left = None
links = [dict(header='',body=lambda row: A('Pdf', 
_class='btn',_href=(URL('default','showpdf',vars=dict(id=row.reports.id, 
Reportnr= row.reports.Reportnr))),
   user_signature=True)),
]
grid = SQLFORM.grid(qr,fields =fields,
orderby= 
~db.reports.Reportdate|~db.reports.Reportnr,
groupby = db.reports.Reportnr,
left = left,
create = False,
deletable = False,
editable = False,
showbuttontext=False,
csv=False,
maxtextlength = 64,
paginate = 10,
links_in_grid=True,
links = links,
selectable = [('Download selected PDFs as 
ZIP',lambda row : mapping_multiple(row)), 
   ('Download selected as EXCEL',lambda 
row : mapping_multiple_excel(row))
  ]
   )
heading=grid.elements('th')
if heading:
heading[0].append(INPUT(_type='checkbox', 
_id = 'check_all',

_onclick="""jQuery('input[type=checkbox][name="records"]').each(function(k)
{if 
($("#check_all").prop("checked")){

 jQuery(this).prop('checked', true);

 }else{

 jQuery(this).prop('checked', false);

  }
});"""))
details = DIV("Details",_id="details")
return dict(grid=grid, details=details, reportnr="123456")

@auth.requires_login()
def mapping_multiple_excel(ids):
#ids is equal to Reportnr because groupby = db.reports.Reportnr,
if ids<>None and ids<>'' and len(ids)<>0:
book = None
buff = None
import xlwt
import StringIO
buff = StringIO.StringIO()
# This is my excel file:
book = xlwt.Workbook()
lent = len(ids)
if len(ids) > 1:
start = ids[0]
end = ids[-1]
filename = "Reports {start}_{end}".format(start=start, end=end)
else:
start = ids[0]
filename = "Reports {start}".format(start=start)
sheet1 = book.add_sheet('Reports')
fields = customheaderlist
for col in range(len(fields)):
sheet1.write(0,col,fields[col])
r = 1  
for row in ids:
Rnr = row
q = (db.reports.Reportnr==Rnr)
s = db(q)
xlsrow = s.select(cache=(cache.ram, 1800)).first()
if xlsrow == None:
return 'Report nr %s not found' % Rnr
report=xlsrow.get('reports')
data = [ reports.field1, reports.field2,   ]
for col in range(len(data)):
sheet1.write(r,col,data[col])
r = r + 1
book.save(buff)
response.headers['Content-Type']='application/vnd.ms-excel'
   

[web2py] Re: How can I union 2 different table datasets?

2017-04-25 Thread A3
Maybe you can use:

db.define_table(‘animal’,

Field('name', 'string', length=45),

Field(‘age’, ‘integer’),

Field(‘apt_time’,’datetime’)


and then subclass: 


db.define_table(‘cat’, db.animal)

and

db.define_table(‘dog’, db.animal)


and then query on db.animal ? 

-- 
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: force redirect after expiration login session expiration time

2017-04-25 Thread A3

Anthony your right, I was just looking in the wrong direction.

What about something like: 

def index():
timeout = auth.settings.expiration
return dict( timeout=timeout)

or put the variable timeout in the layout directly to simplify. 

And in the layout

 var timeout = {{=timeout}};
 var time = new Date().getTime();
 var refreshrate = 1;
 $(document.body).bind("mousemove keypress", function(e) {
 time = new Date().getTime();
 });

 function refresh() { 
 if(new Date().getTime() - time >= timeout*1000)  {
 window.location.replace("{{=URL('user',args=['logout'], 
vars=dict(_next=URL('index')))}}" );
}  
 else {
 setTimeout(refresh, refreshrate);
}
 }

 setTimeout(refresh, refreshrate);
 refresh();


can anybody give a clue how to do the redirect properly?


-- 
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: force redirect after expiration login session expiration time

2017-04-24 Thread A3
Thanks, I thought there was a standard solution. 

I tried this:  

add this scrip to layout:
  

 var time = new Date().getTime();
 $(document.body).bind("mousemove keypress", function(e) {
 time = new Date().getTime();
 });

 function refresh() { 
 if(new Date().getTime() - time >= 6) 
 ajax("{{=URL('default', 'login_status')}}", [], ':eval')
 else 
 setTimeout(refresh, 1);
 }

 setTimeout(refresh, 1);


and this function to the default controller.

def login_status():
if auth.user:
return ''  # user is still logged in
else:
redirect(URL('default', 'index'), client_side=True)


The java script checks every 10 second for mouse activity:  if there is 60 
seconds no activity it will make an ajax call to see if the user is still 
logged in. 
if not logged in it will redirect.

http://stackoverflow.com/questions/4644027/how-to-automatically-reload-a-page-after-a-given-period-of-inactivity

http://stackoverflow.com/questions/10323714/how-to-dynamically-check-logged-in-state-from-view-in-web2py

Unfortunately it doesn't work:  
I hoped it worked but it seems that the ajax call keeps the user logged in.

Is it possible to read the time left from auth.settings.expiration  ? 

 

-- 
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] force redirect after expiration login session expiration time

2017-04-21 Thread A3
Using auth and auth.settings.expiration the login expires correctly, when 
you refresh manually or click a button or menu it redirects to login.

My problem is that the page last shown before it expired remains visible.
There is no automatic redirecting just after the expiration time has 
passed. 

What can I do to automatically redirect it at expiration time?

Any help is very welcome.

-- 
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 get the id of the first row in sqlform.grid when it is loaded?

2017-04-07 Thread A3

>
> I made following changes to make it work: 
>
- When the fields rendered the first row is marked as topfield and stored 
in session.topfield
- First time load or reload returns row.id = 0 and forces to row.id stored 
in session.topfield 

 

 def view_report():
qry.reportnr.represent = render_FIELD(qry.reportnr)
fields = (qry.id,qry.detail, qry.reportnr,)
grid = SQLFORM.grid(qr,fields =fields,
orderby= qry.reportnr,
groupby = qry.reportnr,
create = False,
deletable = False,
editable = False,
showbuttontext=False,
csv=False,
maxtextlength = 64,
paginate = 10)
details = DIV("Details",_id="details")
return dict(grid=grid, details=details, dummynr="0")

The View:
view_report.html
 {{=grid}}
 
 {{=LOAD('default','report_details.load',ajax=True, target='details', 
user_signature=True ,vars={"Rnr_id":dummynr})}}

def render_FIELD():
def __init__(self):
  self.topfield = True
def __call__(self,ids,row,col=None):
... 
span.append(A(ids,callback=URL('default','report_details.load', 
vars=dict(id=ids, Rnr_id=row.id)),target='details'))
if self.topfield:
   session.topfield = row.id
self.topfield = False



The loaded  view:
report_details.load
 {{=report.detail}}

The function 
def report_details()
row_id = request.vars['Rnr_id']
if row_id == '0': 
   row_id = session.topfield
table = "tbl_reports"
field = "id"
q =(db[table][field]==row_id) 
s = db(q)
row = s.select().first()
return dict(report=row)

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


[web2py] how to get the id of the first row in sqlform.grid when it is loaded?

2017-03-27 Thread A3
I am using sqlform.grid, with links that show details in a div when 
clicked.  

here are some fragments of the code:

def view_report():
qry.reportnr.represent = render_FIELD(qry.reportnr)
fields = (qry.id,qry.detail, qry.reportnr,)
grid = SQLFORM.grid(qr,fields =fields,
orderby= qry.reportnr,
groupby = qry.reportnr,
create = False,
deletable = False,
editable = False,
showbuttontext=False,
csv=False,
maxtextlength = 64,
paginate = 10)
details = DIV("Details",_id="details")
return dict(grid=grid, details=details, dummynr="123456")

The View:
view_report.html
 {{=grid}}
 {{=LOAD('default','report_details.load',ajax=True, target='details', 
user_signature=True ,vars={"Rnr_id":dummynr})}}

def render_FIELD():
def __call__(self,ids,row,col=None):
... 
span.append(A(ids,callback=URL('default','report_details.load', 
vars=dict(id=ids, Rnr_id=row.id)),target='details'))

The loaded  view:
report_details.load
 {{=report.detail}}

The function 
def report_details()
row_id = request.vars['Rnr_id']
table = "tbl_reports"
field = "id"
q =(db[table][field]==row_id) 
s = db(q)
row = s.select().first()
return dict(report=row)

This works fine. 
When the links are clicked the details are show.

However, when the page loads the first time I need to the dummynr to 
prevent  an "None" error.

How can I make the page to load and select the top record in the grid 
automatically and show the details as if the link was clicked?

The same applies to  changing pagination and 

what about handling sorting ? Is it possible to select the top record after 
the user has clicked the column to be sorted?

Any hint are very welcome.










-- 
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 test if a controller function exists

2015-10-20 Thread A3
Thanks for the detailed explanation. 

Op dinsdag 20 oktober 2015 03:11:53 UTC+2 schreef Anthony:
>
> If you have the function name, you can do:
>
> if function_name in globals():
>
> And if you have the actual function object, you can do:
>
> if function.__name__ in globals():
>
> Note, those will yield hits even if there is an object of that name 
> defined in a model file. If that is a concern, you can diff the globals 
> before and after executing the controller to get a list of objects 
> specifically defined in the controller. To do that, at the top of the 
> controller file (or anywhere before the first component you want to 
> register):
>
> pre_controller_objects = dir()
>
> Then at the bottom of the controller (or after the last component):
>
> controller_objects = set(dir()) - set(pre_controller_objects)
>
> Then, wherever you want to test for the existence of a function:
>
> if function_name in controller_objects:
>
> Note, that will identify any objects defined in the controller, even if 
> they are not functions. If that's a concern, you can further filter 
> controller_objects to include only function objects.
>
> Finally, if you only want to identify specific actions that your have 
> defined as components, you could use a special prefix/postfix to identify 
> them, or just manually maintain a list of their names. One other option 
> would be to create a decorator that registers a component name in a special 
> object. In a module or model file, or at the top of the controller:
>
> class Component(object):
> def __init__(self):
> self.names = []
>
> def __call__(self, f):
> self.names.append(f.__name__)
> return f
>
> component = Component()
>
> Then you would decorate components:
>
> @component
> def component1():
> return dict()
>
> @component
> def component2():
> return dict()
>
> Finally, wherever needed, check for a component as follows:
>
> if 'component1' in component.names:
>
> Anthony
>
> On Monday, October 19, 2015 at 4:19:30 PM UTC-4, A3 wrote:
>>
>>
>> I want to be able to test if a certain function exists in a controller.
>> (I am loading a component with help of another)
>>
>> controller: 
>> default.py
>> def myfunction()
>>  return
>>
>> def mytest()
>>  if exists(myfunction()):
>>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] how to test if a controller function exists

2015-10-19 Thread A3

I want to be able to test if a certain function exists in a controller.
(I am loading a component with help of another)

controller: 
default.py
def myfunction()
 return

def mytest()
 if exists(myfunction()):
   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: Simple Wiki Markmin Google docs viewer needs HTTPS

2015-10-07 Thread A3
Yes @auth.requires_login(), after removing it works.
But ...
How can I protect my pages when I want to use the viewer?


Op vrijdag 25 september 2015 05:29:07 UTC+2 schreef Massimo Di Pierro:
>
> Is there any @auth.require* protection for the url that serves the xls 
> document? The viewer is a google app and it does not share your 
> credentials. It wants the doc to be public.
>
> On Wednesday, 23 September 2015 08:50:35 UTC-5, A3 wrote:
>>
>> Hi Massimo: 
>> I tried it: browser is no longer complaining about mixed content but ..
>> the viewer is not showing anything.
>> I tried to open the document in the viewer using the rendered link:
>>
>> https://docs.google.com/viewer?url=https://www.myserver.com/application/default/index/3/testexcel.xls&embedded=true
>> This shows a document with the HTML login page?  
>> It seems web2py doesn't want to pass the excel document to the viewer?
>>
>>
>>  
>>
>> Op donderdag 20 augustus 2015 21:00:58 UTC+2 schreef Massimo Di Pierro:
>>>
>>> Made a change in master branch that uses https instead of http for this. 
>>> Please try it.
>>>
>>> On Wednesday, 19 August 2015 16:39:14 UTC-5, A3 wrote:
>>>>
>>>> Hi, I tried to use the Simple Wiki and found the following problem:
>>>> I uploaded an excel file in page media.
>>>> On the wiki page I used the link to the uploaded file: 
>>>> @3/testexcel.xls
>>>> When i look at the page i get an empty square.   
>>>> I am using Chrome: when I inspect the element, is shows:  
>>>> Mixed Content: The page at 'https://_.
>>>> pythonanywhere.com/controller/default/index/page#' was loaded over 
>>>> HTTPS, but requested an insecure resource '
>>>> http://docs.google.com/viewer?url=https%3A//f.pythonanywhere.com/controller/default/index/3/testexcel.xls&embedded=true'.
>>>>  
>>>> This request has been blocked; the content must be served over HTTPS.  
>>>>
>>>> hope anybody can help.
>>>> regards Adri
>>>>
>>>

-- 
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: auth.wiki markmin extra not working?

2015-09-24 Thread A3
I made a new application and only added the code to the index: and now it 
works.
Then I tried to do the same in my earlier application. 
Replaced index: 
Replaced view/index
Replaced model/db
This had no effect. 

Op donderdag 24 september 2015 16:18:22 UTC+2 schreef Leonel Câmara:
>
> Do you have any call to auth.wiki before this one? Say in the models?
>

-- 
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] auth.wiki markmin extra not working?

2015-09-24 Thread A3
I tried to extend the auth.wiki using the extra option but I cannot get it 
to work. 
I set  auth.wiki(resolve=False) in the models
and used the following controller:

def index():
checked = lambda text: '%s' % text + ' ✓'
return auth.wiki(render='markmin',extra=dict(checked=checked))

in a new wiki page:
``this is OK``:checked

expect to see:  
this is OK ✓
I get: 
this is OK


I did a small test to check the function: 
by adding these line to the controller index:
z = MARKMIN("``this is OK``:checked",
extra=dict(checked=checked))
response.flash = z

this shows in the response flash:  this is OK ✓

Do I have set any other options or is it a bug.

-- 
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: SQLform grid custom function for delete

2015-09-23 Thread A3
explained here: 

https://groups.google.com/d/msg/web2py/asCPsD9UGb8/ksmYX0UjBx0J

Op dinsdag 22 september 2015 04:22:39 UTC+2 schreef Yebach:
>
> Ok thanx. This worked.
>
> One more question. My SQLFORM.grid is not refreshed after callback. So 
> record stays there. HOw to do a grid refresh?
>
> 2015-09-19 20:32 GMT+08:00 Anthony >:
>
>> On Saturday, September 19, 2015 at 4:18:49 AM UTC-4, Yebach wrote:
>>>
>>> Hello
>>>
>>> So I managed to put link and create it but now I have a probelm getting 
>>> the id of the record I want to deal with
>>>
>>> links = [lambda row: A('',_class='glyphicon glyphicon 
>>> glyphicon-remove-sign',
>>> callback=URL('settings','deactivate',vars=dict(table='skills',field = 
>>> 'sk_status', value = form.vars.id )))]
>>>
>>
>> If you want the id of the record in a given row of the table, then 
>> instead of value=form.vars.id, it should be value=row.id.
>>  
>>
>>> @auth.requires_login() def deactivate(): ##Aktiviramo delavca ko user 
>>> klikne na activate user = auth.user_id org = db(db.auth_user.id == 
>>> user).select(db.auth_user.organization)[0]["organization"] #Worker je id 
>>> zaposlenenga ki ga damo v aktiven id = request.vars["id"]
>>>
>>
>> In the URLs generated in the grid, you used the variable name "value", 
>> yet here you are looking for the variable name "id". The above line should 
>> be:
>>
>> id = request.vars.value
>>
>> Or you can change the URLs to use "id" as the variable name.
>>
>> 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 a topic in the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/web2py/3T1Qaf39wJg/unsubscribe.
>> 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/d/optout.
>>
>
>
>
> -- 
> Lep pozdrav 
>
> Vid Ogris
>
>
>

-- 
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: Simple Wiki Markmin Google docs viewer needs HTTPS

2015-09-23 Thread A3
Hi Massimo: 
I tried it: browser is no longer complaining about mixed content but ..
the viewer is not showing anything.
I tried to open the document in the viewer using the rendered link:
https://docs.google.com/viewer?url=https://www.myserver.com/application/default/index/3/testexcel.xls&embedded=true
This shows a document with the HTML login page?  
It seems web2py doesn't want to pass the excel document to the viewer?


 

Op donderdag 20 augustus 2015 21:00:58 UTC+2 schreef Massimo Di Pierro:
>
> Made a change in master branch that uses https instead of http for this. 
> Please try it.
>
> On Wednesday, 19 August 2015 16:39:14 UTC-5, A3 wrote:
>>
>> Hi, I tried to use the Simple Wiki and found the following problem:
>> I uploaded an excel file in page media.
>> On the wiki page I used the link to the uploaded file: 
>> @3/testexcel.xls
>> When i look at the page i get an empty square.   
>> I am using Chrome: when I inspect the element, is shows:  
>> Mixed Content: The page at 'https://_.
>> pythonanywhere.com/controller/default/index/page#' was loaded over 
>> HTTPS, but requested an insecure resource '
>> http://docs.google.com/viewer?url=https%3A//f.pythonanywhere.com/controller/default/index/3/testexcel.xls&embedded=true'.
>>  
>> This request has been blocked; the content must be served over HTTPS.  
>>
>> hope anybody can help.
>> regards Adri
>>
>

-- 
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] auth.wiki search generates error 'exceptions.AttributeError'

2015-09-14 Thread A3
Hi,  I'm learning to use the auth.wiki and ran into the following problem:

I tried the minimal example in the code:
def index()
return auth.wiki()
I add a user 

Created a wikipage with a tag: mytag

When I click the tag mytag or use the wiki menu search page it show me:


Please note I'am using pythonanywhere as host.

Any clues?

-- 
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: Simple Wiki Markmin Google docs viewer needs HTTPS

2015-08-20 Thread A3
Also tried to force insecure: 
this shows me the HTML page in the box.  
  

-- 
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] Simple Wiki Markmin Google docs viewer needs HTTPS

2015-08-19 Thread A3
Hi, I tried to use the Simple Wiki and found the following problem:
I uploaded an excel file in page media.
On the wiki page I used the link to the uploaded file: @3/testexcel.xls
When i look at the page i get an empty square.   
I am using Chrome: when I inspect the element, is shows:  
Mixed Content: The page at 
'https://_.pythonanywhere.com/controller/default/index/page#' was 
loaded over HTTPS, but requested an insecure resource 
'http://docs.google.com/viewer?url=https%3A//f.pythonanywhere.com/controller/default/index/3/testexcel.xls&embedded=true'.
 
This request has been blocked; the content must be served over HTTPS.  

hope anybody can help.
regards Adri

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