[web2py] Programatically create Row

2021-02-12 Thread david...@gmail.com
I have a controller that displays confidential data from a table but want 
to be able to show the form publicly with some dummy data. The controller 
makes use of field representation and references so I basically need a Row.

I can create the object I need using the table.insert() methods and then 
db.rollback() to avoid committing the dummy data but is there a better 
method. I've had a look at the internals of Row and suspect that trying to 
create a Row object by hand would be pretty fraught, but is there a better 
way than just using insert() and rollback()? It feels like using a 
sledgehammer to crack a nut.

Cheers,
David

-- 
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/068a3914-7560-4edf-a4f1-2071d0fd9749n%40googlegroups.com.


[web2py] Re: Fixes for uWSGI + ngnix install script in Ubuntu 20.04.01 LTS?

2021-01-07 Thread david...@gmail.com
OK - thanks for the feedback. I've read around on similar comments and I 
completely get that there is a groundswell against making web2py code 
require python 3 (essentially other frameworks should be used instead), but 
this would just be removing a barrier to getting it working with python 3 
on Ubuntu 20.04 without requiring python 2 to run the setup script. I'll 
submit it.  

On Thursday, 7 January 2021 at 10:28:14 UTC tim.n...@conted.ox.ac.uk wrote:

> Agree that the changes merit a pull request, and the script should now be 
> py3-specific, since we're past py2 EOL.
>
> Re. problem 3, I think the script once handled ubuntu/debian versions with 
> initd OR systemd, and that the init config is long obsolete and should be 
> removed.  It was useful having both back when some of us were on Debian 7 
> or other versions without systemd, but that's no longer the case.
>
> And yes, the Execstart in the uwsgi service should match the options in 
> the upstart config.  On my Debian servers, I have `ExecStart = 
> /usr/local/bin/uwsgi --emperor /etc/uwsgi/apps-enabled --logto 
> /var/log/uwsgi/uwsgi.log`, and it works just fine.
>
> On Friday, 18 December 2020 at 11:14:41 UTC david...@gmail.com wrote:
>
>> Just to add: I fixed the unresolved issues as I typed the email and then 
>> forgot to change the opening paragraph, so ignore part (b). Part (a) and 
>> part (c) from the first paragraph still apply.
>>
>> On Friday, 18 December 2020 at 11:12:40 UTC david...@gmail.com wrote:
>>
>>> Hi there,
>>>
>>> I'm trying to set up Web2Py in Ubuntu 20.04.01 LTS using the scripts:
>>>
>>>
>>> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh
>>>
>>> It doesn't work. I've been going through it some details and have almost 
>>> got it working but wanted to (a) check I'm not being an idiot (b) ask about 
>>> a couple of unresolved issues and (c) does this merit a pull request?
>>>
>>> # Problem 1:
>>>
>>>
>>> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L31-34
>>>
>>> Python 2 is no longer shipped in 20.04 and --no-build-wheel is 
>>> deprecated. Rather than install it, it makes sense to me to switch this 
>>> section and use the installed Python 3.8. I understand that this makes the 
>>> script Python 3 specific, but that seems a sane thing to offer as a script 
>>> with Ubuntu 20.04
>>>
>>> ```
>>> apt-get -y install build-essential python3-dev libxml2-dev python-pip3 
>>> unzippip3 install setuptools --no-binary :all: --upgrade
>>> PIPPATH=`which pip3`
>>> $PIPPATH install --upgrade uwsgi
>>> ```
>>>
>>> # Problem 2:
>>>
>>>
>>> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L133-136
>>>
>>> OpenSSL no longer accepts 1024 bit keys, so this needs to be altered. I 
>>> think these two lines do the same job with a 2048 bit key.
>>>
>>> ```
>>> openssl req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout 
>>> web2py.key -out web2py.crt
>>> openssl x509 -noout -text -in web2py.crt -out web2py.info
>>> ```
>>>
>>> # Problem 3:
>>>
>>>
>>> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L185
>>>
>>> I'm really out on a limb here, but I don't think this is creating the 
>>> services correctly on 20.04, which I think is to do with the removal of 
>>> Upstart (?). If I _manually_ start uwsgi from the command line on my 
>>> server, then I can access the web2py Welcome page:
>>>
>>> ```
>>> sudo uwsgi --master --die-on-term --emperor /etc/uwsgi --logto 
>>> /var/log/uwsgi/uwsgi.log
>>> ```
>>>
>>> The script does create a uwsgi service:
>>>
>>>
>>> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L144
>>>
>>> This doesn't seem to work as expected and I think this is because the 
>>> ExecStart statement isn't correct. If I substitute the ExecStart command 
>>> with the one in the upstart config at line 201 and restart the services, 
>>> then it works. I suspect that makes lines 185 to 202 redundant?
>>>
>>> And I think that is it - I get an instance running on Ubuntu 20.04 with:
>>>
>>> 2.21.1-stable+timestamp.2020.11.28.04.10.44
>>> (Running on nginx/1.18.0, Python 3.8.5)
>>>
>>> Thoughts / Comments / Have you never read about this massive security 
>>> hole you've just opened up?
>>>
>>

-- 
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/7f0aabf3-03f5-4730-9a37-fadbacc0fc6dn%40googlegroups.com.


[web2py] Re: Fixes for uWSGI + ngnix install script in Ubuntu 20.04.01 LTS?

2020-12-18 Thread david...@gmail.com
Just to add: I fixed the unresolved issues as I typed the email and then 
forgot to change the opening paragraph, so ignore part (b). Part (a) and 
part (c) from the first paragraph still apply.

On Friday, 18 December 2020 at 11:12:40 UTC david...@gmail.com wrote:

> Hi there,
>
> I'm trying to set up Web2Py in Ubuntu 20.04.01 LTS using the scripts:
>
>
> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh
>
> It doesn't work. I've been going through it some details and have almost 
> got it working but wanted to (a) check I'm not being an idiot (b) ask about 
> a couple of unresolved issues and (c) does this merit a pull request?
>
> # Problem 1:
>
>
> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L31-34
>
> Python 2 is no longer shipped in 20.04 and --no-build-wheel is deprecated. 
> Rather than install it, it makes sense to me to switch this section and use 
> the installed Python 3.8. I understand that this makes the script Python 3 
> specific, but that seems a sane thing to offer as a script with Ubuntu 20.04
>
> ```
> apt-get -y install build-essential python3-dev libxml2-dev python-pip3 
> unzippip3 install setuptools --no-binary :all: --upgrade
> PIPPATH=`which pip3`
> $PIPPATH install --upgrade uwsgi
> ```
>
> # Problem 2:
>
>
> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L133-136
>
> OpenSSL no longer accepts 1024 bit keys, so this needs to be altered. I 
> think these two lines do the same job with a 2048 bit key.
>
> ```
> openssl req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout 
> web2py.key -out web2py.crt
> openssl x509 -noout -text -in web2py.crt -out web2py.info
> ```
>
> # Problem 3:
>
>
> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L185
>
> I'm really out on a limb here, but I don't think this is creating the 
> services correctly on 20.04, which I think is to do with the removal of 
> Upstart (?). If I _manually_ start uwsgi from the command line on my 
> server, then I can access the web2py Welcome page:
>
> ```
> sudo uwsgi --master --die-on-term --emperor /etc/uwsgi --logto 
> /var/log/uwsgi/uwsgi.log
> ```
>
> The script does create a uwsgi service:
>
>
> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L144
>
> This doesn't seem to work as expected and I think this is because the 
> ExecStart statement isn't correct. If I substitute the ExecStart command 
> with the one in the upstart config at line 201 and restart the services, 
> then it works. I suspect that makes lines 185 to 202 redundant?
>
> And I think that is it - I get an instance running on Ubuntu 20.04 with:
>
> 2.21.1-stable+timestamp.2020.11.28.04.10.44
> (Running on nginx/1.18.0, Python 3.8.5)
>
> Thoughts / Comments / Have you never read about this massive security hole 
> you've just opened up?
>

-- 
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/8a5c2445-7373-468c-8657-eb566a6dabcan%40googlegroups.com.


[web2py] Fixes for uWSGI + ngnix install script in Ubuntu 20.04.01 LTS?

2020-12-18 Thread david...@gmail.com
Hi there,

I'm trying to set up Web2Py in Ubuntu 20.04.01 LTS using the scripts:

https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh

It doesn't work. I've been going through it some details and have almost 
got it working but wanted to (a) check I'm not being an idiot (b) ask about 
a couple of unresolved issues and (c) does this merit a pull request?

# Problem 1:

https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L31-34

Python 2 is no longer shipped in 20.04 and --no-build-wheel is deprecated. 
Rather than install it, it makes sense to me to switch this section and use 
the installed Python 3.8. I understand that this makes the script Python 3 
specific, but that seems a sane thing to offer as a script with Ubuntu 20.04

```
apt-get -y install build-essential python3-dev libxml2-dev python-pip3 
unzippip3 install setuptools --no-binary :all: --upgrade
PIPPATH=`which pip3`
$PIPPATH install --upgrade uwsgi
```

# Problem 2:

https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L133-136

OpenSSL no longer accepts 1024 bit keys, so this needs to be altered. I 
think these two lines do the same job with a 2048 bit key.

```
openssl req -x509 -nodes -sha256 -days 365 -newkey rsa:2048 -keyout 
web2py.key -out web2py.crt
openssl x509 -noout -text -in web2py.crt -out web2py.info
```

# Problem 3:

https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L185

I'm really out on a limb here, but I don't think this is creating the 
services correctly on 20.04, which I think is to do with the removal of 
Upstart (?). If I _manually_ start uwsgi from the command line on my 
server, then I can access the web2py Welcome page:

```
sudo uwsgi --master --die-on-term --emperor /etc/uwsgi --logto 
/var/log/uwsgi/uwsgi.log
```

The script does create a uwsgi service:

https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh#L144

This doesn't seem to work as expected and I think this is because the 
ExecStart statement isn't correct. If I substitute the ExecStart command 
with the one in the upstart config at line 201 and restart the services, 
then it works. I suspect that makes lines 185 to 202 redundant?

And I think that is it - I get an instance running on Ubuntu 20.04 with:

2.21.1-stable+timestamp.2020.11.28.04.10.44
(Running on nginx/1.18.0, Python 3.8.5)

Thoughts / Comments / Have you never read about this massive security hole 
you've just opened up?

-- 
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/6cd2a0ae-af07-4107-9098-579d2f7c2e14n%40googlegroups.com.