From: Bruno Desthuilliers on
Stephen Hansen a �crit :
> On 6/10/10 8:35 AM, Bruno Desthuilliers wrote:
>> Stephen Hansen (L/P) a �crit :
>>> On 6/10/10 7:14 AM, Victor Subervi wrote:
>> (snip)
>>> +1 for "absolutely worst framed question of the day" :)
>> IMHO you're wasting your time. Some guys never learn, and I guess we do
>> have a world-class all-times champion here.
>>
>>
>
> Well, he eventually learned about bare excepts and using string
> formatting in SQL. It took a long time, but he finally believed us.

No ??? Incredible. Perhaps I'm being a bit too pessimistic then.

> He just sort of needs to give us the benefit of the doubt when we say,
> "umm, its bad to do that" :)
>
From: Emile van Sebille on
On 6/11/2010 4:46 AM Victor Subervi said...
> Now you guys can make fun of me all you want, but until you actually READ
> and UNDERSTAND what I'm writing, I'm afraid I think your criticisms are
> ridiculous and make you look like fools.

I think the point is exactly as you state -- until you actually READ and
UNDERSTAND what you're writing, I'm afraid your questions are ridiculous
and make you look like a fool.

Emile

From: Stephen Hansen on
On 6/11/10 4:46 AM, Victor Subervi wrote:
> You know, if this were the first time I'd worked with "passing variables
> around" through cgi, I'd think you may be right. But answer me this:
if what
> you assume is correct,

I do not assume. I know.

With CGI, each web request is independent. This is simple fact.

The web server launches Python, Python runs a script, Python returns a
string containing the result, *Python closes*. The web host sends that
string to the client.

The Python application *ends*. Its memory is cleared. It is gone. This
is how CGI works (and why CGI is almost never used anymore, as it is
quite slow as a result-- most people use something like FastCGI or WSGI
either with a long-running daemon Python process or embedding Python
into Apache itself).

When the next request comes in, it all starts up again: each request has
only the information provided to it, either in cookies, the environment
variables (there's quite a few interesting ones), and the request
parameters.

This is *how it works*.

This is not some vague guess of mine. This is *years* of experience of
*actually* doing *exactly* what you're doing (while at the time actually
making an attempt to understand the actual processes going on instead of
just moving things around in files and observing the results to guess
what's going on under the covers).

Sure, if you have some file that two separate scripts import, and in
said file you generate some value-- as long as that value will be the
same at all times, it'll appear that the two scripts are sharing some
state. They are not, however. The two scripts can not communicate.

> Now you guys can make fun of me all you want, but until you actually READ
> and UNDERSTAND what I'm writing, I'm afraid I think your criticisms are
> ridiculous and make you look like fools.

And this comment ends my attempt at assisting you, for multiple reasons
(from the utter absurdity of you insisting we understand you when you
take insultingly little care to actually express your problems clearly,
to your arrogant and repeated refusal to take advice that is given, to
your abject rudeness here, and so on).

--

Stephen Hansen
... me+list/python (AT) ixokai (DOT) io

From: Stephen Hansen on
[reordering the message a bit]

On 6/11/10 10:40 AM, Victor Subervi wrote:
>>> Now you guys can make fun of me all you want, but until you actually
READ
>>> and UNDERSTAND what I'm writing, I'm afraid I think your criticisms are
>>> ridiculous and make you look like fools.

> On Fri, Jun 11, 2010 at 12:24 PM, Stephen Hansen
> <me+list/python(a)ixokai.io>wrote:
>>
>> And this comment ends my attempt at assisting you, for multiple reasons
>> (from the utter absurdity of you insisting we understand you when you
>> take insultingly little care to actually express your problems clearly,
>> to your arrogant and repeated refusal to take advice that is given, to
>> your abject rudeness here, and so on).
>>
>
> That comment was not addressed to you as you didn't bother to quote the
> other part just after it, where I stated I appreciate your help and
> understand how difficult it is to not misunderstand each other. Sorry you
> misunderstood. I am not being arrogant or rude.

"I think your criticisms are ridiculous and make you look like fools" is
what I object to. I didn't quote the rest, because it doesn't matter --
once you say something like that, you become an jerk. Once you're an
jerk, you don't get to backtrack and say, 'oh, except you'. I don't
really accept the appreciation from someone being an jerk. If you're an
jerk at all, you can't really expect any sort of help at all :P

That said, I'll answer once more:

>> Sure, if you have some file that two separate scripts import, and in
>> said file you generate some value-- as long as that value will be the
>> same at all times, it'll appear that the two scripts are sharing some
>> state. They are not, however. The two scripts can not communicate.
>>
>
> I'm glad you have lots of experience and I respect that. However, I did not
> say that "two separate scripts import said file." To repeat:
>
> 1) variable value generated is
> create_edit_passengers2.py<http://example.com/create_edit_passengers2.py>
> 2) create_edit_passengers2.py<http://example.com/create_edit_passengers2.py>calls
> create_edit_passengers3.py
> <http://example.com/create_edit_passengers2.py>via a <form...> and
> passes the value of the var thereunto.
> 3) theoretically! Yet for some reason I can't call it in
> create_edit_passengers3.py
> <http://example.com/create_edit_passengers2.py>but *can* call it in a
> script that is imported by
> create_edit_passengers3.py <http://example.com/create_edit_passengers2.py>
>
> I think I'm being clear here, am I not? With all your knowledge and
> understanding, I still fail to understand how it is you don't understand and
> cannot answer my question.

You're not even *approaching* being clear.

"Variable value generated is" means WHAT?

What does "generated" mean?

If you have a line,

x = MyFunction()

At the top level of some script, then everytime that script is called,
MyFunction is called, and it assigns its value to x. If MyFunction is
deterministic and doesn't rely on any sort of state, it'll be the same
value every time.

[For the rest of the analysis, I refuse to continue typing these
absurdly long names. create_edit_passengers2.py is bar1.py,
create_edit_passengers3.py is bar2.py]

Okay, at 1, you say.. you have Value generated. When you go
http://foo/bar1.py, then it will load, "generate" your value, dump the
resulting output, and then close.

And its done. That value ceases to exist.

Okay, so. Step 2. The output that bar1 returned contained a form. This
form, I assume (but you did not state), contains embedded in it the
value of "var". Yes? No? Either way

Now we're at step 2. In step 2, you have some form, and its calling back
to http://foo/bar2.py via a <form>, passing the value of "var" in it. I
can't quite make out what all is going on here, so its all a guess, as
you have this slightly crazy bar2.py<http://foo/bar1.py> thing going on
that I can't figure out. But, I'll just handwave that, and guess.

So, bar2 receives our "var".

Then you say:

> 3) theoretically! Yet for some reason I can't call it in
> create_edit_passengers3.py
> <http://example.com/create_edit_passengers2.py>but *can* call it in a
> script that is imported by
> create_edit_passengers3.py <http://example.com/create_edit_passengers2.py>

I can't even vaguely guess at what you're trying to express there, which
is why I didn't address this originally -- its utterly meaningless
gibberish to me.

"Yet for some reason I can't call it in bar2.py<http://foo/bar1.py>"

"but *can* call it in a script that is imported by
bar2.py<http://foo/bar1.py"

First of all, what is "it", and what are you "calling" -- using names
like 'calling' is so very damaging to clarity when you're talking about
CGI scripts interacting. As they don't call each-other. They return
output. That output may contain a link (or form, or whatever) to another
CGI script, or the same, or a different. That's not /calling/.

Either way: when last step 2 left us, bar2.py had received the "var" via
a <form>, and we aren't sure what happened then.

It returned some output. What output? Or.. its doing something. Or, its
the thing that's trying to do something. But can't. Because its..
"calling". What? How? What's that even mean?

--

Stephen Hansen
... me+list/python (AT) ixokai (DOT) io

From: Dave Angel on
Victor Subervi wrote:
> On Fri, Jun 11, 2010 at 12:24 PM, Stephen Hansen
> <me+list/python(a)ixokai.io>wrote:
>
>
>> Sure, if you have some file that two separate scripts import, and in
>> said file you generate some value-- as long as that value will be the
>> same at all times, it'll appear that the two scripts are sharing some
>> state. They are not, however. The two scripts can not communicate.
>>
>>
>
> I'm glad you have lots of experience and I respect that. However, I did not
> say that "two separate scripts import said file." To repeat:
>
> 1) variable value generated is
> create_edit_passengers2.py<http://example.com/create_edit_passengers2.py>
> 2) create_edit_passengers2.py<http://example.com/create_edit_passengers2.py>calls
> create_edit_passengers3.py
> <http://example.com/create_edit_passengers2.py>via a <form...> and
> passes the value of the var thereunto.
> 3) theoretically! Yet for some reason I can't call it in
> create_edit_passengers3.py
> <http://example.com/create_edit_passengers2.py>but *can* call it in a
> script that is imported by
> create_edit_passengers3.py <http://example.com/create_edit_passengers2.py>
>
> I think I'm being clear here, am I not? With all your knowledge and
> understanding, I still fail to understand how it is you don't understand and
> cannot answer my question.
>
> <snip>
You could try actually stating something approaching what your code is
doing.

"variable value generated is create_edit_passengers2.py" So you're generating that source code, and storing it in some variable called "value"?


"calls create_edit_passengers3.py" You say you're calling
create_edit_passengers3.py

but that's not a function, it's a source file. You can't call a source
file.

And "passes the value of the var therunto" is mighty roundabout.
Assuming you meant "import" in the last part, how are you passing the
value? Import doesn't take any parameters.

"script that is imported by". Nitpick: a script cannot be imported.
Once it is, it's a module.

"for some reason I can't call it in create_edit_passengers3.py" No idea
what "it" refers to, is it some mythical script that you're still trying
to call?

Your problem could be circular imports. If one module imports another,
which directly or indirectly imports the first, you can get into various
trouble. If somebody imports the *script* you're definitely hosed,
since there will then be two instances of that one, the script, and the
module.


Maybe it's all clear if one looks at those files, but from here the
links seem broken. So I'm just going by your message, which is
confusing. I suggest you construct a simple example to show the
problem, one small enough to include here in its entirety. Then
describe it in proper Python terminology.

DaveA