Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no

2021-07-09 Thread Menno Holscher

Op 09-07-2021 om 08:14 schreef vergos@gmail.com:

Στις Παρασκευή, 9 Ιουλίου 2021 στις 12:03:00 π.μ. UTC+3, ο χρήστης Menno 
Holscher έγραψε:

Op 08-07-2021 om 15:42 schreef vergos@gmail.com:

import flask
dir(flask)

['Blueprint', 'Config', 'Flask', 'Markup', 'Request', 'Response',
'Session', '__builtins__', '__cached__', '__doc__', '__file__',
'__loader__', '__name__', '__package__', '__path__', '__spec__',
'__version__', '_app_ctx_stack', '_compat', '_request_ctx_stack',
'abort', 'after_this_request', 'app', 'appcontext_popped',
'appcontext_pushed', 'appcontext_tearing_down',
'before_render_template', 'blueprints', 'cli', 'config',
'copy_current_request_context', 'ctx', 'current_app', 'escape', 'flash',
'g', 'get_flashed_messages', 'get_template_attribute', 'globals',
'got_request_exception', 'has_app_context', 'has_request_context',
'helpers', 'json', 'json_available', 'jsonify', 'make_response',
'message_flashed', 'redirect', 'render_template',
'render_template_string', 'request', 'request_finished',
'request_started', 'request_tearing_down', 'safe_join', 'send_file',
'send_from_directory', 'session', 'sessions', 'signals',
'signals_available', 'stream_with_context', 'template_rendered',
'templating', 'url_for', 'wrappers']
... there is no "run" there. What were you trying to achieve?

When you look at the exported symbols, there is no route, so if you 
expected flask to export route it is not there either.

How is that even possible?

Do i have  something wrong in the www.py?

from flask import Flask, route, request, redirect, render_template, url_for, 
send_from_directory, debug

app = Flask(__name__)
app.run(debug=True)


There is 2 possibilities here. One is you have a module named route. 
Than you do not import it as a name from flask, but as a module.


The other is you are looking for the attribute route from the Flask class.

@app.route("/item/", methods=["GET", "POST"])

This creates a route. The route method is a method of an instance of 
Flask (i.e. app), so importing Flask is enough.


Also i use run for this

app.run( host='superhost.gr', port=5000, debug=True )


Yes, that is OK, if DNS contains a host superhost.gr.

--
Met vriendelijke groet / Kind regards

Menno Hölscher


--
https://mail.python.org/mailman/listinfo/python-list


Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no

2021-07-09 Thread vergos....@gmail.com
Στις Παρασκευή, 9 Ιουλίου 2021 στις 3:57:11 μ.μ. UTC+3, ο χρήστης Menno 
Holscher έγραψε:
> Op 09-07-2021 om 08:14 schreef vergos@gmail.com:
> > Στις Παρασκευή, 9 Ιουλίου 2021 στις 12:03:00 π.μ. UTC+3, ο χρήστης Menno 
> > Holscher έγραψε: 
> >> Op 08-07-2021 om 15:42 schreef vergos@gmail.com:
> > import flask 
> > dir(flask) 
> >> ['Blueprint', 'Config', 'Flask', 'Markup', 'Request', 'Response', 
> >> 'Session', '__builtins__', '__cached__', '__doc__', '__file__', 
> >> '__loader__', '__name__', '__package__', '__path__', '__spec__', 
> >> '__version__', '_app_ctx_stack', '_compat', '_request_ctx_stack', 
> >> 'abort', 'after_this_request', 'app', 'appcontext_popped', 
> >> 'appcontext_pushed', 'appcontext_tearing_down', 
> >> 'before_render_template', 'blueprints', 'cli', 'config', 
> >> 'copy_current_request_context', 'ctx', 'current_app', 'escape', 'flash', 
> >> 'g', 'get_flashed_messages', 'get_template_attribute', 'globals', 
> >> 'got_request_exception', 'has_app_context', 'has_request_context', 
> >> 'helpers', 'json', 'json_available', 'jsonify', 'make_response', 
> >> 'message_flashed', 'redirect', 'render_template', 
> >> 'render_template_string', 'request', 'request_finished', 
> >> 'request_started', 'request_tearing_down', 'safe_join', 'send_file', 
> >> 'send_from_directory', 'session', 'sessions', 'signals', 
> >> 'signals_available', 'stream_with_context', 'template_rendered', 
> >> 'templating', 'url_for', 'wrappers'] 
> >> ... there is no "run" there. What were you trying to achieve? 
> >>
> When you look at the exported symbols, there is no route, so if you 
> expected flask to export route it is not there either.
> > How is that even possible? 
> > 
> > Do i have something wrong in the www.py? 
> > 
> > from flask import Flask, route, request, redirect, render_template, 
> > url_for, send_from_directory, debug 
> > 
> > app = Flask(__name__) 
> > app.run(debug=True)
> There is 2 possibilities here. One is you have a module named route. 
> Than you do not import it as a name from flask, but as a module. 
> 
> The other is you are looking for the attribute route from the Flask class. 
> 
> @app.route("/item/", methods=["GET", "POST"]) 
> 
> This creates a route. The route method is a method of an instance of 
> Flask (i.e. app), so importing Flask is enough.
> > 
> > Also i use run for this 
> > 
> > app.run( host='superhost.gr', port=5000, debug=True ) 
> >
> Yes, that is OK, if DNS contains a host superhost.gr.
> -- 
> Met vriendelijke groet / Kind regards 
> 
> Menno Hölscher
please tell me what i need to do to be able to see error messages in browser 
and not only via console:

app = Flask(__name__)
app.debug = True
application = app

The above only displays error via console into the error_log, having to open it 
each time. how can i see it in browser?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no

2021-07-09 Thread Chris Angelico
On Fri, Jul 9, 2021 at 11:07 PM vergos@gmail.com
 wrote:
> please tell me what i need to do to be able to see error messages in browser 
> and not only via console:
>
> app = Flask(__name__)
> app.debug = True
> application = app
>
> The above only displays error via console into the error_log, having to open 
> it each time. how can i see it in browser?

Until you're able to serve pages, you won't get anything in the browser.

Nikos, you've come back to this list a few times over the years, and
each time, you're trying to host web sites with a very shaky
understanding of what's actually going on. Are you still trying to
provide hosting services to other people, and if so, have you - as was
advised multiple times in the past - dedicated a week to actually
learning how HTTP works and how web browsers and back end apps
communicate?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no

2021-07-09 Thread vergos....@gmail.com
Στις Παρασκευή, 9 Ιουλίου 2021 στις 4:10:29 μ.μ. UTC+3, ο χρήστης Chris 
Angelico έγραψε:
> On Fri, Jul 9, 2021 at 11:07 PM vergos@gmail.com 
>  wrote: 
> > please tell me what i need to do to be able to see error messages in 
> > browser and not only via console: 
> > 
> > app = Flask(__name__) 
> > app.debug = True 
> > application = app 
> > 
> > The above only displays error via console into the error_log, having to 
> > open it each time. how can i see it in browser?
> Until you're able to serve pages, you won't get anything in the browser. 
> 
> Nikos, you've come back to this list a few times over the years, and 
> each time, you're trying to host web sites with a very shaky 
> understanding of what's actually going on. Are you still trying to 
> provide hosting services to other people, and if so, have you - as was 
> advised multiple times in the past - dedicated a week to actually 
> learning how HTTP works and how web browsers and back end apps 
> communicate? 
> 
> ChrisA

This is a perosnal project of mine.

Iam abl to server the page i want, its just in a specific function i get an 
error and that error is being displayed on console, and i'am trying to make it 
seen via browser instead.

Isn't app.debug = True enough to do that? eveb if i add app.testing=True i 
still cant see the errors in the browser.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no

2021-07-09 Thread vergos....@gmail.com
Στις Παρασκευή, 9 Ιουλίου 2021 στις 4:10:29 μ.μ. UTC+3, ο χρήστης Chris 
Angelico έγραψε:
> On Fri, Jul 9, 2021 at 11:07 PM vergos@gmail.com 
>  wrote: 
> > please tell me what i need to do to be able to see error messages in 
> > browser and not only via console: 
> > 
> > app = Flask(__name__) 
> > app.debug = True 
> > application = app 
> > 
> > The above only displays error via console into the error_log, having to 
> > open it each time. how can i see it in browser?
> Until you're able to serve pages, you won't get anything in the browser. 
> 
> Nikos, you've come back to this list a few times over the years, and 
> each time, you're trying to host web sites with a very shaky 
> understanding of what's actually going on. Are you still trying to 
> provide hosting services to other people, and if so, have you - as was 
> advised multiple times in the past - dedicated a week to actually 
> learning how HTTP works and how web browsers and back end apps 
> communicate? 
> 
> ChrisA

from werkzeug.debug import DebuggedApplication

app = Flask(__name__)
application = app
application = DebuggedApplication(app, True)

I even tries this solution and i still see errors appear *only* in the 
error_log. WHY?!
-- 
https://mail.python.org/mailman/listinfo/python-list


Correct traceback for multiline chain of method calling

2021-07-09 Thread Артем Комендантян
Hello!

There is a code https://pastebin.com/0NLsHuLa.
It has a multiline chain of method calling, when some method fails. In
python3.7 it fails in a row which corresponds to the failing method, in
python3.9 it corresponds to the very first line.

Another similar example is https://pastebin.com/2P9snnMn
The error is on the first line for older pythons too.

I propose to have a line with the method name in traceback if this method
fails.

I develop some library when it is very popular among users to declare some
operations with such multiline chains. Also I want to keep correct
traceback for each operation because the first line is not very informative
when some method occurred more than once in this chain.

Can this improvement be done? Maybe anybody has any other suggestions on
how to get the correct line in traceback right now?


--
Best wishes,
Artem Komendantian
komendantyan.ar...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Verify independence and uniform distribution of discrete values in Python?

2021-07-09 Thread Dan Stromberg
I've posted a question about CPython 3.[0-9]'s
random.SystemRandom().choice(list_) at
https://stackoverflow.com/questions/68319071/verify-independence-and-uniform-distribution-of-discrete-values-in-python

In short, we need to be able to support CPython's a little older than the
secrets module goes back, but we still need independence and uniform
distribution - in fact, we need cryptographic strength randomness.

Does anyone know if SystemRandom() is cryptographically strong in CPython
>= 3.0?

It appears that the good module secrets is cryptographically strong, but
doesn't go back in CPython 3.x's history far enough, and it appears to
build on random.SystemRandom().

Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no

2021-07-09 Thread Menno Holscher

Op 09-07-2021 om 15:01 schreef vergos@gmail.com:

please tell me what i need to do to be able to see error messages in browser 
and not only via console:

app = Flask(__name__)
app.debug = True
application = app

The above only displays error via console into the error_log, having to open it 
each time. how can i see it in browser?

This is totally unrelated to your earlier question, and (as many things 
Flask) well documented.


Look at 
https://flask.palletsprojects.com/en/2.0.x/debugging/#the-built-in-debugger


--
Met vriendelijke groet / Kind regards

Menno Hölscher


--
https://mail.python.org/mailman/listinfo/python-list


Re: i just moved from bottleframework to flask. I changes what needed to be altered to convert the code and when i run it i just get "Internal server error" Running tail -f ../logs/error_log i get no

2021-07-09 Thread vergos....@gmail.com
Στις Παρασκευή, 9 Ιουλίου 2021 στις 11:48:43 μ.μ. UTC+3, ο χρήστης Menno 
Holscher έγραψε:
> Op 09-07-2021 om 15:01 schreef vergos@gmail.com:
> > please tell me what i need to do to be able to see error messages in 
> > browser and not only via console: 
> > 
> > app = Flask(__name__) 
> > app.debug = True 
> > application = app 
> > 
> > The above only displays error via console into the error_log, having to 
> > open it each time. how can i see it in browser? 
> >
> This is totally unrelated to your earlier question, and (as many things 
> Flask) well documented. 
> 
> Look at 
> https://flask.palletsprojects.com/en/2.0.x/debugging/#the-built-in-debugger
> -- 
> Met vriendelijke groet / Kind regards 
> 
> Menno Hölscher

i managed to run i with built in debugger by setting export 
FLASK_ENV=development

Every time I start up my flask app the environment variable is set to 
production. I want to have it set to development mode by default. Otherwise 
every time I start my app i have to run ..

export FLASK_ENV=development

How can I set environment's default value as development in every startup?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Verify independence and uniform distribution of discrete values in Python?

2021-07-09 Thread Ethan Furman

From Tim Peters:

> `secrets` is just a wrapper around `random.SystemRandom`, so the
> presence or absence of `secrets` doesn't matter.
>
> As to SystemRandom, all answers depend on the quality of the platform
> os.urandom(), which Python has no control over. See my answer here,
> and the comments on it:
>
> https://stackoverflow.com/questions/20936993/

--
https://mail.python.org/mailman/listinfo/python-list


Re: Correct traceback for multiline chain of method calling

2021-07-09 Thread Cameron Simpson
On 09Jul2021 18:29, Артем Комендантян  wrote:
>There is a code https://pastebin.com/0NLsHuLa.
>It has a multiline chain of method calling, when some method fails. In
>python3.7 it fails in a row which corresponds to the failing method, in
>python3.9 it corresponds to the very first line.
>
>Another similar example is https://pastebin.com/2P9snnMn
>The error is on the first line for older pythons too.

Interesting.

There was some work done in recent Pythons to improve syntax error 
reporting. I wonder if it has had side effects on the reporting.

>I propose to have a line with the method name in traceback if this 
>method
>fails.

That line is already there:

#   File "/home/komendart/temp/script.py", line 6, in fail
# raise RuntimeError('fail')

See that it points at the fail() method from line 6 of the script?

>I develop some library when it is very popular among users to declare some
>operations with such multiline chains. Also I want to keep correct
>traceback for each operation because the first line is not very informative
>when some method occurred more than once in this chain.
>
>Can this improvement be done? Maybe anybody has any other suggestions on
>how to get the correct line in traceback right now?

Aside from putting the whole thing on 1 line? Joking.

Possibly only by breaking it up purely while debugging:

x = a.do_nothing()
x = x.do_nothing()
x = x.fail(True)

and so forth. Annoying, but it would providethe desired precision.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Correct traceback for multiline chain of method calling

2021-07-09 Thread Artem Komendantian
> That line is already there:

>#   File "/home/komendart/temp/script.py", line 6, in fail
># raise RuntimeError('fail')

Probably I should rewrite more concretely.
I have such traceback ending for python3.7
#   File "script.py", line 15, in main
# .fail(True)
#   File "script.py", line 6, in fail
# raise RuntimeError('fail')

It has the exact line of the failing method's call (line 15) and that is
what I want for fresh python in general.
Just the name of the method and place inside of it with error in the last
part of traceback is not enough because this method can occur in the chain
several times (like .fail in my simple example) and I want to get a line of
the exact call.

> Annoying, but it would provide the desired precision.
I agree with all parts of this sentence :) Well, I can live with such a
solution but it is really uncomfortable.

In python3.7 and lower (even in python2, lol) if a method was called with
some arguments traceback had a line corresponding to some argument of
needed call. This behaviour was suitable for me.

I can a bit formalize my suggestion to improve python tracebacks.
If we have code in one line like

(
(some complex construction of object with __call__)
(
some arguments
)
)

traceback should contain a line with opening brace before arguments (Now in
the last python traceback seems to contain the start of the called object's
construction)
The last line of called object's construction or first of arguments
enumerating is ok too, it doesn't really matter for me.

BTW it is not important for me but I can dream how this proposal can be
generalized. For example for failing index operations a[b] (error line must
be close to [ here) or for all binary operations (a + b fails => the error
line must be close to the line with plus operator).

Does it sound reasonable? Am I on the right mailing list for python
improvement suggestions? :)

--
Best wishes,
Artem Komendantian
komendantyan.ar...@gmail.com


сб, 10 июл. 2021 г. в 02:53, Cameron Simpson :

> On 09Jul2021 18:29, Артем Комендантян 
> wrote:
> >There is a code https://pastebin.com/0NLsHuLa.
> >It has a multiline chain of method calling, when some method fails. In
> >python3.7 it fails in a row which corresponds to the failing method, in
> >python3.9 it corresponds to the very first line.
> >
> >Another similar example is https://pastebin.com/2P9snnMn
> >The error is on the first line for older pythons too.
>
> Interesting.
>
> There was some work done in recent Pythons to improve syntax error
> reporting. I wonder if it has had side effects on the reporting.
>
> >I propose to have a line with the method name in traceback if this
> >method
> >fails.
>
> That line is already there:
>
> #   File "/home/komendart/temp/script.py", line 6, in fail
> # raise RuntimeError('fail')
>
> See that it points at the fail() method from line 6 of the script?
>
> >I develop some library when it is very popular among users to declare some
> >operations with such multiline chains. Also I want to keep correct
> >traceback for each operation because the first line is not very
> informative
> >when some method occurred more than once in this chain.
> >
> >Can this improvement be done? Maybe anybody has any other suggestions on
> >how to get the correct line in traceback right now?
>
> Aside from putting the whole thing on 1 line? Joking.
>
> Possibly only by breaking it up purely while debugging:
>
> x = a.do_nothing()
> x = x.do_nothing()
> x = x.fail(True)
>
> and so forth. Annoying, but it would providethe desired precision.
>
> Cheers,
> Cameron Simpson 
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list