[web2py] p4web auth issues

2020-02-22 Thread Maurice Waka
Using this code,

File "apps/_scaffolds/controllers.py", line 82, in index 
db.posts.insert(message="Welcome "+auth_user.first_name+'.'+' Thank you for 
signing in with us. Blah blah blah.', author=auth.user_id, 
created_by=auth.user_id, modified_by=auth.user_id) 


I get an error:


NameError: name 'auth_user' is not defined

I also tried:


Auth.first_name;
auth.first_name;
auth.user.first_name



and the errors are the same


Please help here.


Regards

-- 
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/00b6213f-074e-4e80-b3a9-c8946e7541c0%40googlegroups.com.


[web2py] Deploying of a web2py based webapp on GAE fails with 'No module named 'google'

2020-02-22 Thread Sreedevi


My aim is to create a python 3 based webapp using web2py 2.18.5 + google 
cloud sdk 281.0.0 + python 3.7.6. I am using the web2py's inbuilt welcome 
app.

   - The app.yaml and requirements.txt file that I am using are attached
   - I can run this web2py app on my local machine and view the welcome app.
   - But when I try to deploy the same app onto the cloud, I get 502 Bad 
   Gateway, nginx error. The logs corresponding to this error are as follows
   Traceback (most recent call last): File 
   "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in 
   spawn_worker worker.init_process() File 
   "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 92, in 
   init_process super().init_process() File 
   "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in 
   init_process self.load_wsgi() File 
   "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in 
   load_wsgi self.wsgi = self.app.wsgi() File 
   "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 
   self.callable = self.load() File 
   "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in 
   load return self.load_wsgiapp() File 
   "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in 
   load_wsgiapp return util.import_app(self.app_uri) File 
   "/env/lib/python3.7/site-packages/gunicorn/util.py", line 358, in 
   import_app mod = importlib.import_module(module) File 
   "/opt/python3.7/lib/python3.7/importlib/init.py", line 127, in 
   import_module return _bootstrap._gcd_import(name[level:], package, level) 
   File "", line 1006, in _gcd_import File "", line 983, in _find_and_load 
   File "", line 967, in _find_and_load_unlocked File "", line 677, in 
   _load_unlocked File "", line 728, in exec_module File "", line 219, in 
   _call_with_frames_removed File "/srv/main.py", line 1, in import gaehandler 
   File "/srv/gaehandler.py", line 48, in from google.appengine.ext import 
   webapp ModuleNotFoundError: No module named 'google'

-- 
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/a39f6a47-ab8a-495c-96d5-64a6fa542838%40googlegroups.com.
google==2.0.3


app.yaml
Description: Binary data


[web2py] Re: unexpected end of stream - py4web

2020-02-22 Thread Massimo Di Pierro
Can you show us some minimum code to rproduce?

On Friday, 21 February 2020 20:38:08 UTC-8, Edoardo Torrini wrote:
>
> Hi 
>
> I create a project client/server compose by an application mobile (client) 
> and a webservice (py4web).
> the application create request to the webservice and the server reply.
> I add a request scheduling using the celery and redis.
> I follow pass for pass the guide on the official py4web site.
>
> the problem is that when I generete the get request from the app create an 
> exception: "unexpected end of stream"
> Someone know how to fix this issue?
>
> Thanks
> Edoardo Torrini
>

-- 
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/1483d926-2e83-440b-ba2f-21aa2c5c6840%40googlegroups.com.


[web2py] Substituting an email address with a reference in a web2py emailing form

2020-02-22 Thread mostwanted
I've created an emailing form in my application but have substituted where 
the email goes with a reference that contains the email, the problem is 
that now the email is not being sent unless i write a proper explicit email 
address. Whats the difference between writing an explicit email address & 
using a variable that supposedly contains the email? I have to use the 
referencing variable as I currently am because different registered users 
get to log in & send emails, its not just one user. How can I solve this 
problem???

*CODE*
def contact_us():
details=db.hotel_profile(request.args(0, cast=int))
form = SQLFORM.factory(
Field('name', requires=IS_NOT_EMPTY()),
Field('cell_number', requires=IS_NOT_EMPTY()),
Field('email', requires =[ IS_EMAIL(error_message='invalid email!'), 
IS_NOT_EMPTY() ]),
Field('subject', requires=IS_NOT_EMPTY()),
Field('message', requires=IS_NOT_EMPTY(), type='text')
)
if form.process().accepted:
*mail.send(to='details.email_address', *
  #subject='contact request from %(your_name)s %(email)s' 
 % form.vars,
  subject=form.vars.subject,
  message = '%(message)s \nName: %(name)s \nEmail Address: 
%(email)s \nCell Number: %(cell_number)s' % form.vars)
response.flash = T('Thank you, your form was submitted')
#redirect(URL('index'))
return dict(form=form)


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/572c29c6-a77e-41e5-b086-53c098928bbc%40googlegroups.com.


Re: [web2py] Using postgresql with py4web gives error

2020-02-22 Thread Maurice Waka
OK.
Thanks for the update.
I reinstalled postgresql.
I'll check performance.
Regards

On Sat, Feb 22, 2020, 16:38 E L  wrote:

> If you are using ## in the password, that might cause problems for the
> URL/URI parser since # is part of URL structure.
> Otherwise, it looks like postgres is not running.
>
>
> On Wed, Feb 19, 2020 at 10:32 AM Maurice Waka 
> wrote:
> >
> > db = DAL( "postgres://mauricewaka:b123test##@localhost:5432/mydb")
> > But got this error:
> ...
> > RuntimeError: Failure to connect, tried 5 times:
> ...
> > Is the server running on host "localhost" (127.0.0.1) and accepting
> > TCP/IP connections on port 5432?
>
> --
> 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/8c2O5FoZIow/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/CAEVys%2BQXMzDM03niqtGHf7RdsEsH6hhuAyTQ_uU4uLub0Zf55A%40mail.gmail.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/CALkNK55YE%3DRSZMASjiE8j0fYNa73%2BN5sTP%3DWdtzz3TChBoHpag%40mail.gmail.com.


Re: [web2py] py4web issue on get requests

2020-02-22 Thread Christian Varas
Hi Torrini,

I don’t know what is causing the error but you can use a local proxy like
burp suite to catch your client request and see what’s wrong with that
request. If is malformed you can see with with this.

Cheers.

El El sáb, 22 de feb. de 2020 a la(s) 01:38, Edoardo Torrini <
edoardo.torr...@gmail.com> escribió:

> Good morning,
>
> I am a software developer and I want to create a project client-server.
> The client is wrote in c# with xamarine and the server on py4web.
> The client create request with some parameters and the server reply with a
> data in json form.
> I use celery for scheduling the request and I create a task for each type
> of requests.
>
> When with the client application I create a request [like the example
> below], the function await.response.Content.ReadAsStringAsync create an
> exception: *unexpected end of stream*
>
> [image: Exception - Xamarine.png]
>
>
> Server side the situation is that I create for each request a DAL and I
> define a table where I took the date to send to the client.
> in this way:
> [image: Controller - py4web.png]
>
> I invoke  the task that reply the json file to the client in this way:
>
> [image: task prd - py4web.png]
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Someone know why the operation create this type of exception, I try using
> a request with chrome but the page was displayed correctly.
> Thanks for the help.
>
> Edoardo Torrini
>
>
>
>
> --
> 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/a25df1ac-50b3-4033-a661-374577da6281%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/CA%2Bs%2BuJtGtB6AQxAq6C9rDU%3D7vS1s4Jy1%3Df84AmicV2KL%3DXDYwQ%40mail.gmail.com.


Re: [web2py] Using postgresql with py4web gives error

2020-02-22 Thread E L
If you are using ## in the password, that might cause problems for the
URL/URI parser since # is part of URL structure.
Otherwise, it looks like postgres is not running.


On Wed, Feb 19, 2020 at 10:32 AM Maurice Waka  wrote:
>
> db = DAL( "postgres://mauricewaka:b123test##@localhost:5432/mydb")
> But got this error:
...
> RuntimeError: Failure to connect, tried 5 times:
...
> Is the server running on host "localhost" (127.0.0.1) and accepting
> TCP/IP connections on port 5432?

-- 
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/CAEVys%2BQXMzDM03niqtGHf7RdsEsH6hhuAyTQ_uU4uLub0Zf55A%40mail.gmail.com.


[web2py] Re: Redirect "website.pythonanywhere.com" to "www.newwebsite.de"

2020-02-22 Thread villas
Hi Alexander

If you cannot redirect using the webserver,  and you cannot figure out 
routes, I guess you could still do something simple in your web2py 
controller, like this...

def index():

redirect('https://www.my_redirected_site.com{0}'.format(request.env.request_uri))


-- 
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/31516391-33f8-42e8-9f11-ca95ace24f24%40googlegroups.com.


[web2py] Re: Many records in one transaction

2020-02-22 Thread villas
You do not explain why you would need to delete and then insert 25K records 
to prepare a timetable.  
It seems that you are creating a temporary table and that is seldom the 
correct approach.  

   - If all the data is already available in the tables,  then you should 
   be able to write SQL which only selects the rows you require.  Iterate 
   those rows to produce your timetable.
   - If the select is taking too long,  then try using pure SQL using 
   db.executesql().  Compare the times. Experiment and optimise the SQL.
   - If the select is still very slow even using pure SQL,  optimise your 
   table schema and use indexes. 
   - Avoid creating temporary tables!  
   


-- 
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/3fb7e1f3-bda8-4ddf-af94-d0ef0d2c7cc7%40googlegroups.com.


[web2py] Re: select for list:integer, but in a specific position

2020-02-22 Thread p a
And a second version with SUBSTR

def operator_field_starts(field, first_int, query_env={}):
'''bla bla '''
if not field.type != 'list:integer':
raise AttributeError, "bla bla"
dialect = field._dialect
second = '|'+dialect._like_escaper_default(str(first_int))+'|'
return "(%s = '%s')"%(
dialect.substring(field, (1,len(second))),
second
)



-- 
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/77b0d95e-d7e8-4df6-94b3-7bcc52ad5fa5%40googlegroups.com.


[web2py] Re: select for list:integer, but in a specific position

2020-02-22 Thread p a
I came up with a first version that works:

def operator_field_starts(field, first_int, query_env={}):
'''bla bla
'''
if not field.type.startswith('list:'):
raise AttributeError, "bla bla bla"
dialect = field._dialect
arg = '|'+dialect._like_escaper_default(str(first_int))+'|%'
op = dialect.like
return op(field, arg, escape='\\', query_env=query_env)

from pydal.objects import Query
def field_starts(field, first_int):
db = field._db
return Query(db, operator_field_starts, field, first_int)

and then it is used like this:

db( field_starts(db.operation.parameters, my_parameter) & (db.operation.
canceled==True))._count()

I feel it would be more efficient to use SUBSTR instead of LIKE, so I'll go 
for a second version...

Regards

-- 
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/0c32d063-ad65-46a8-beb2-0bf4e1eb212c%40googlegroups.com.