[web2py] No being able to access all the details from a for loop in the view

2019-08-12 Thread mostwanted
I am working on a house rental application, i want users to easily notify 
one another of places they know via whatsapp, i have written the 
functionality and this is how it should work:
Next to the rental amount is a whatsapp sharing link that when the user 
clicks it carries forward all the rental details to their desired contact 
but now the problem i am facing is that on my list of rentals the details 
of the first link are missing, the user can't share all of them but the 
following link is able to share all its details, i hope i am clear! I have 
a feeling this is caused by the for loop just dont know how to rectify it, 
here is my code below:

CODE:
{{extend 'layout.html'}}
{{=
breadcrumbs() }}
  
function goBack()
{
window.history.back();
}

BACK




Listed Rentals In Kanye & Surrounding Areas
 {{=
houseCount}} available houses up for rent






   
   HOUSE OWNER
   CELL NUMBER
   HOUSE DESCRIPTION
   LOCATION
   RENTAL AMOUNT
   
{{for details in details:}}



$(document).ready(function() {
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS
() || isMobile.Opera() || isMobile.Windows());
}
};
 $(document).on("click", '.whatsapp', function(e) {
 //const id = $(this).data('id'); // Extract the data-id attribute of 
the link.
if( isMobile.any() ) {
var text = $(this).attr("data-text");
//var url = $('#' + id).attr("data-link");
var message =text;
var whatsapp_url = "whatsapp://send?text=" + message + "C/O 
SESOA&trade";
window.location.href = whatsapp_url;
} else {
alert("This is only shareable on mobile devices!");

  }
 e.preventDefault();
});
});



   {{=A(details.Surname, _href=URL('show', 
args=[details.id]))}} {{=details.Name}}

{{=details.Cell_Number}}
{{=details.description}}
{{=details.located_at}}
  
*{{=details.amount}}Share Details On 
Whatsapp*
{{pass}}

{{pass}}


 Regards

Mostwanted

-- 
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/77b709dc-ce0b-4510-834a-a41b65187cd5%40googlegroups.com.


[web2py] big data "out of memory" error

2019-08-12 Thread Alex Glaros
Not sure if I'm qualified to give tips here, but I had a one-time job that 
timed out with out-of-memory error. To fix that, I cloned a copy of my site 
(admin-console, manage, pack all), keeping the same database, then in db.py 
replaced every instance of 'reference my_big_tables' with 'integer' in the 
clone. It ran quickly and I then discarded the clone. If this helps anyone, 
then good.

Questions: 

Is it generally accepted that with big data tables, it's best to achieve 
referential integrity in the controller at the record-creation stage, and 
not add any rules into the database? 

My clone kept the requires statements: requires = IS_IN_DB(db, 
'my_big_tables.id'  ... and still ran fast so can the "reference 
my_big_tables" statement be safely, and completely eliminated from db.py? 
The "reference" statement really slows things down.

thanks,

Alex Glaros

-- 
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/8833de76-2fc7-4c3e-a6f6-b57e79d3bd05%40googlegroups.com.


Re: [web2py] Re: web3py -> py4web

2019-08-12 Thread Massimo Di Pierro
Not yet. Will create one eventually but want to finish a couple of features 
with support with this community

On Monday, 12 August 2019 07:38:46 UTC-7, En Ware wrote:
>
> Is there an IRC channel for py4web yet ? or an official group ? 
>
> On Tuesday, July 30, 2019 at 1:38:05 AM UTC-5, Massimo Di Pierro wrote:
>>
>> to be clear... most of the docs is backported by web2py + explanation of 
>> sessions and @action decorator.
>> Most of the new features are still undocumented or poorly documented 
>> unfortunately. Namely pydal.restapi, auth plugins, Form,  and 
>> 
>> Will try my best in the next few days.
>>
>> On Monday, 29 July 2019 02:36:40 UTC-7, Jose C wrote:
>>>
>>> Darn, I hunted around but didn't see it.  Thanks for the link...
>>>
>>>
>>>
>>> On Monday, 29 July 2019 10:06:42 UTC+1, Nico Zanferrari wrote:

 Hi Jose,

 the documentation is already on GitHub 
 
  , 
 and PR are always welcome ;-)

 Nico

 Il giorno lun 29 lug 2019 alle ore 10:14 Jose C  
 ha scritto:

> Looks promising... some questions:
>
> 1) Have spotted many typos in docs but can't find docs for py4web on 
> github.  If docs are on there, like web2py book, people can submit pull 
> requests and help massage the docs into shape.
> 2) Should there be a new official group created for py4web (or some 
> other repo of Q knowledge, StackExchange?)   A) to minimize noise in 
> the 
> web2py group and B) also make it easier to find py4web related stuff?  
> 3) When are you aiming for the first "stable" release?  
>
> Rgds,
>
>
> -- 
> 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 web...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/web2py/0693c615-1283-413e-b976-91c238da8384%40googlegroups.com
>  
> 
> .
>


-- 
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/587bfd5f-9387-4552-ab6d-2c008ffd417d%40googlegroups.com.


[web2py] gloun.tool.Expose cleans my session

2019-08-12 Thread Martin Mosbeck
Hi everyone,

I use gloun.tools.Expose to expose a folder, the base directory is built with
variables, that are saved in the session. But, gloun.tools.Expose cleans the
session at its init function.

Usecase:
User clicks a link with GET variables, this is a call to a function in a
controller. The controller takes the variables, puts them into the session and
exposes a directory based on these variables with gloun.tools.Expose. In this
exposed file view, the user clicks on a folder-link to traverse to a subfolder.
As this link is created by gloun.tools.Expose, no GET variables are set,
therefore the variables saved in the session should be used to build the base
directory.

Simplified code-snippet:

if not request.vars['UserId']:
UserId = session.viewUserId
else:
UserId = int(request.vars['UserId'])
session.viewUserId = UserId

if not request.vars['TaskNr']:
TaskNr = session.viewTaskNr
else:
TaskNr = int(request.vars['TaskNr'])
session.viewTaskNr = TaskNr

taskSubDir = "{0}/{1}/Task{2}".format(usersDir, UserId, TaskNr)
return dict(files=Expose(base=taskSubDir))
###

But, gloun.tool.Expose cleans the session in its init function. Code in the
gloun/tools Expose __init__ function:

# why would this not be callable? but otherwise tests do not pass
if current.session and callable(current.session.forget):
current.session.forget()


So I get a FILE NOT FOUND error, when traversing to any subfolder via click in
the exposed file-view, as the session was cleared.

If I delete these lines from gloun.tools.Expose init function, everything works 
as expected.

Is there any special reasons, why the session is cleaned when using
gloun.tools.Expose or is this an unintended behavior/bug or am I using Expose in
a way it was not intended? Or is there an other solution to my usecase , I am
missing?

Tested under version: Version 2.18.5-stable+timestamp.2019.04.08.04.22.03

Best & thanks

Martin Mosbeck

--
Martin Mosbeck

TU Wien
Gusshausstraße 25-29 / E384
1040 Vienna, Austria
Web: https://www.ict.tuwien.ac.at/en/
Email: martin.mosb...@tuwien.ac.at

-- 
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/56a0582f-5c43-24d3-0de8-50a4a2c7bc5a%40tuwien.ac.at.


[web2py] Re: managing web2py logs under uwsgi

2019-08-12 Thread Dave S


On Tuesday, July 30, 2019 at 7:08:43 PM UTC-7, Dave S wrote:
>
>
>
> On Monday, July 29, 2019 at 3:06:54 PM UTC-7, Dave S wrote:
>>
>>
>>
>> On Tuesday, April 23, 2019 at 8:00:44 PM UTC-7, Dave S wrote:
>>>
>>> I run web2py under nginx and uwsgi.  The latter runs in master mode 
>>> (rather than emperor mode), and I think it is what drives my question:
>>>
>>> *How do I control the size of the web2py log files?*
>>> I have seen the files grow without bound (until I did a manual log 
>>> rotate), but currently the web2py/logs/web2py.log file is being rotated for 
>>> me after 1-3 requests.  The uwsg conf file web2py.ini specifies a 
>>> log-maxsize, but that's for the uwsgi logs, and the web2py logs are being 
>>> kept under 300 bytes.
>>>
>>> (300 bytes x 6 rotations with a few requests per second means I don't 
>>> have to capture error clues)
>>>
>>> Versions: 
>>> web2py 2.1.5.4 for the moment, as I didn't jump on the .17 versions, and 
>>> the .18s kept jumping every time I began to be less inert
>>> nginx 1.14.1
>>> uwsgi 2.0.15 (master=true, processes=4)
>>>
>>> /dps
>>>
>>>
>> Having had to restart the server recently, I studied this again.
>>
>> It appears that when you start uwsgi, [web2py dir]/logs/web2py.log grows 
>> normally until it reaches a limit, and then each uwsgi worker starts 
>> autorotating it, and each rotation gives you 1-3 requests worth of logging, 
>> and this goes on until the next restart.
>>
>> My uwsgi is set to autorotate logs, but I'd expect that to only deal with 
>> uwsgi's logs.  Is the behavior above controlled by appfactory() in 
>> gluon/main.py?
>>
>  
>
In order to debug an issue, I've been using the "touch routes.py" trick, 
> and that is a more graceful way of restarting the web2py.log.  It appears 
> that autorotates start at about 1,000,000 bytes (but it's difficult to 
> catch the actual turning point).  The file used for uwsgi configuration has 
> a log size value of 2,000,000 which fits the size of the uwsgi.logs as 
> rotated by uwsgi.
>
>  
After spending more time looking at appfactory() and also the Python 
logging library, I can now report:


   - the 100 comes from my own logging.conf (probably a default value)
   - setting the delay parameter (= 1) in the args list for rotating file 
   handlers has ameliorated the issue.  With that set, logs growing to the 
   limit happens often enough that I can debug much more easily.


/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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/060861f6-539c-4adf-9d76-e64997c72ced%40googlegroups.com.


[web2py] Re: How can I insert image in HTML from database?

2019-08-12 Thread Val K
100 images per page? What do your images look like? Are these icons? What size? 
To prevent db scratching there is Cache-Control

-- 
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/609e337c-3904-489a-a5f8-b60771ec020d%40googlegroups.com.


[web2py] Re: What happened to DAL(None)?

2019-08-12 Thread Leonel Câmara
DAL(None) still works, you do need to do a bit of setting up if you want to 
use it for forms, namely set the DAL default validators.

See how SQLFORM.factory does it:
https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py#L2053

-- 
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/9659de51-ceb0-4842-8c4c-2efd2098dd6e%40googlegroups.com.


[web2py] Re: How can I insert image in HTML from database?

2019-08-12 Thread Константин Комков
Yes, I want get from database many images (maybe not all, but 100 or 50 
pictures). In your case for creating 1 page I need to do 101 or 51 query to 
database. I want have one query and transfer row.recipes.IMAGE as variable 
in img function. Somthing like that (but it's not work):
def index():
image = ''
rows = db().select(db.recipes.IMAGE)
for row in rows:
image += ''
image = XML(image)
return dict(image=image)

def img():
image = request.args(0)
if image:
return image.read()

-- 
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/bdc7d1ae-7dcb-4064-8a8c-32b1b35e9dea%40googlegroups.com.


Re: [web2py] Re: web3py -> py4web

2019-08-12 Thread En Ware
Is there an IRC channel for py4web yet ? or an official group ? 

On Tuesday, July 30, 2019 at 1:38:05 AM UTC-5, Massimo Di Pierro wrote:
>
> to be clear... most of the docs is backported by web2py + explanation of 
> sessions and @action decorator.
> Most of the new features are still undocumented or poorly documented 
> unfortunately. Namely pydal.restapi, auth plugins, Form,  and 
> 
> Will try my best in the next few days.
>
> On Monday, 29 July 2019 02:36:40 UTC-7, Jose C wrote:
>>
>> Darn, I hunted around but didn't see it.  Thanks for the link...
>>
>>
>>
>> On Monday, 29 July 2019 10:06:42 UTC+1, Nico Zanferrari wrote:
>>>
>>> Hi Jose,
>>>
>>> the documentation is already on GitHub 
>>> 
>>>  , 
>>> and PR are always welcome ;-)
>>>
>>> Nico
>>>
>>> Il giorno lun 29 lug 2019 alle ore 10:14 Jose C  
>>> ha scritto:
>>>
 Looks promising... some questions:

 1) Have spotted many typos in docs but can't find docs for py4web on 
 github.  If docs are on there, like web2py book, people can submit pull 
 requests and help massage the docs into shape.
 2) Should there be a new official group created for py4web (or some 
 other repo of Q knowledge, StackExchange?)   A) to minimize noise in the 
 web2py group and B) also make it easier to find py4web related stuff?  
 3) When are you aiming for the first "stable" release?  

 Rgds,


 -- 
 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 web...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/web2py/0693c615-1283-413e-b976-91c238da8384%40googlegroups.com
  
 
 .

>>>

-- 
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/b7a007b1-f12a-440a-915b-455515883a21%40googlegroups.com.


[web2py] Re: newbie question Can't use versioning in web2py

2019-08-12 Thread Dave S


On Sunday, August 11, 2019 at 10:34:32 AM UTC-7, Jirawat Kusolpredee wrote:
>
> Access admin page -> edit -> versioning -> throw exception ??? versioning 
> just doesn't work I never messing up the core ? What happened here ?
>

Source control?  Use an external source control, like Tortoise HG or Git.  
 The built-in one is deprecated because it used an unstable interface 
(Mercurial, but not the official Mercuiral API).

/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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/966d596e-947d-46ad-9250-f85aa37ebd2f%40googlegroups.com.


[web2py] Re: How can I insert image in HTML from database?

2019-08-12 Thread Val K
I don’t quite understand what do you mean 'in cycle', do you want to 
include all images  in one html page?

to make img() more useful you can do this (for example)

def img():
id =request.args(0)
if id: 
row = db(db.recipes.id == id).select(db.recipes.IMAGE).first()
if row:
return row.IMAGE.read()


def index():
#show the first ten images
img_list = DIV()
rows = db().select(db.recipes.id, limitby = (0, 10))
for row in rows:
img_list.append(IMG(_src = URL('default', 'img', args = [row.id])))
return dict(img_list = img_list)








On Sunday, August 11, 2019 at 7:47:41 PM UTC+3, Константин Комков wrote:
>
> *Val K*, that case is work!)
> def index():
> image = XML(' class="card-img-top" alt="..."/>')
> return dict(image=image)
>
> def img():
> row = db().select(db.recipes.IMAGE).first()
> if row:
> return row.IMAGE.read()
> It seems very strange that return row.IMAGE.read() from img function work, 
> but URL( 'default', args=row.IMAGE.read()) don't work.
> I have not one image and get it in cycle. Are there variant use img 
> function for it?
> rows = db().select(db.recipes.IMAGE)
> for row in rows:
>
>
>

-- 
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/936df435-0892-4163-8b3e-e44a9982b61f%40googlegroups.com.