Re: Flask: request vs Request

2018-03-12 Thread Andrew Z
Thank you Christopher.

On Mar 12, 2018 09:10, "Christopher Mullins" 
wrote:

> Could you please give some context when you reply, TIA
>>
>
> Whoops, thanks for the reminder Mark.
>
> So what for the Request is used  for then?
>
>
> In general when you see that something in Python starts with a capital
> letter, that indicates a class. Check out the relevant section of the PEP8
> coding style [1], this is a good reference to have on hand.  (This
> generalization doesn't apply to builtin types which follow a separate
> convention, also outlined in [1] -- and of course there are a numerous
> exceptions.)
>
> This holds for your variable in question "request" which is an instance of
> the Request class.  Check out [2] for more information on this.  PyCharm
> tries to do its best but I've had this problem too.  You can always open up
> a python REPL and look at the object yourself:
>
> >>> import flask
> >>> r = flask.Request
> >>> r
> 
> >>> dir(r)
>
> and so on.  When I'm working in python I like to keep one of these open
> for this purpose.
>
> HTH,
> Chris
>
> [1] https://www.python.org/dev/peps/pep-0008/#class-names
> [2] http://flask.pocoo.org/docs/0.12/api/#incoming-request-data
>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-12 Thread Christopher Mullins
>
> Could you please give some context when you reply, TIA
>

Whoops, thanks for the reminder Mark.

So what for the Request is used  for then?


In general when you see that something in Python starts with a capital
letter, that indicates a class. Check out the relevant section of the PEP8
coding style [1], this is a good reference to have on hand.  (This
generalization doesn't apply to builtin types which follow a separate
convention, also outlined in [1] -- and of course there are a numerous
exceptions.)

This holds for your variable in question "request" which is an instance of
the Request class.  Check out [2] for more information on this.  PyCharm
tries to do its best but I've had this problem too.  You can always open up
a python REPL and look at the object yourself:

>>> import flask
>>> r = flask.Request
>>> r

>>> dir(r)

and so on.  When I'm working in python I like to keep one of these open for
this purpose.

HTH,
Chris

[1] https://www.python.org/dev/peps/pep-0008/#class-names
[2] http://flask.pocoo.org/docs/0.12/api/#incoming-request-data
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-11 Thread Andrew Z
 after reading the docs and stackoverflow i got some rudimentary
understanding of Request vs request.
i still don't understand why i PyCharm won't show properties, but it is
tool centric question that hardly belongs to this group.

On Sun, Mar 11, 2018 at 10:02 AM, Andrew Z  wrote:

> Sorry guys. i realized i was "mumbling" .
>
> What is the difference between Request and request?  -   RTFM
> , Andrew
>
> Questions:
>  a. when do i use Request?
>  b. why can't I see any properties of the request?  For example, in
> Michael's tutorial, there is a call for  request.json. PyCharm brings no
> suggestions when i type in "request. "
>
>
>
>
> On Sat, Mar 10, 2018 at 11:30 PM, Mark Lawrence 
> wrote:
>
>> On 11/03/18 04:09, Christopher Mullins wrote:
>>
>>> In the code you linked, I don't see where the *R*equest is used. The
>>> request variable is setup by flask when you annotate the function with
>>> the
>>> resource endpoint and POST method. It contains the content of the request
>>> which can be converted to json if that content type was specified.
>>>
>>>
>> Could you please give some context when you reply, TIA.
>>
>> --
>> My fellow Pythonistas, ask not what our language can do for you, ask
>> what you can do for our language.
>>
>> Mark Lawrence
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-11 Thread Andrew Z
Sorry guys. i realized i was "mumbling" .

What is the difference between Request and request?  -   RTFM
, Andrew

Questions:
 a. when do i use Request?
 b. why can't I see any properties of the request?  For example, in
Michael's tutorial, there is a call for  request.json. PyCharm brings no
suggestions when i type in "request. "




On Sat, Mar 10, 2018 at 11:30 PM, Mark Lawrence 
wrote:

> On 11/03/18 04:09, Christopher Mullins wrote:
>
>> In the code you linked, I don't see where the *R*equest is used. The
>> request variable is setup by flask when you annotate the function with the
>> resource endpoint and POST method. It contains the content of the request
>> which can be converted to json if that content type was specified.
>>
>>
> Could you please give some context when you reply, TIA.
>
> --
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
>
> Mark Lawrence
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-11 Thread Mark Lawrence

On 11/03/18 04:09, Christopher Mullins wrote:

In the code you linked, I don't see where the *R*equest is used. The
request variable is setup by flask when you annotate the function with the
resource endpoint and POST method. It contains the content of the request
which can be converted to json if that content type was specified.



Could you please give some context when you reply, TIA.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Flask: request vs Request

2018-03-10 Thread Andrew Z
that's right there is no Request used.
So what for the Request is used  for then?

Here

it is explained that request is for current request... that's kinda of
clears the air a bit.
but where do i find it's methods?



On Sat, Mar 10, 2018 at 11:09 PM, Christopher Mullins <
christopherrmull...@gmail.com> wrote:

> In the code you linked, I don't see where the *R*equest is used. The
> request variable is setup by flask when you annotate the function with the
> resource endpoint and POST method. It contains the content of the request
> which can be converted to json if that content type was specified.
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Flask: request vs Request

2018-03-10 Thread Christopher Mullins
In the code you linked, I don't see where the *R*equest is used. The
request variable is setup by flask when you annotate the function with the
resource endpoint and POST method. It contains the content of the request
which can be converted to json if that content type was specified.
-- 
https://mail.python.org/mailman/listinfo/python-list


Flask: request vs Request

2018-03-10 Thread Andrew Z
hello,

 i'm playing with  Michael Grinberg's "Restful API with python and flask"
tutorial

.

And i'm very much confused whats the difference between request and Request.
 the "request" is introduced @ the point he talks about "POST". Here is the
sample from the tutorial:

from flask import request
@app.route('/todo/api/v1.0/tasks', methods=['POST'])def create_task():
if not request.json or not 'title' in request.json:
abort(400)
task = {
'id': tasks[-1]['id'] + 1,
'title': request.json['title'],
'description': request.json.get('description', ""),
'done': False
}
tasks.append(task)
return jsonify({'task': task}), 201


the help system talks about somekind of LocalProxy class and then im
getting lost 
The immediate trouble is that i don't see any methods for "request". ( Or,
at least, PyCharm can't find anything) and not sure what the "*r*equest" is
for and what i can do with it. Or should i use the "*R*equest"

Appreciate some guidance on the matter.
-- 
https://mail.python.org/mailman/listinfo/python-list