Re: webapp development in pure python

2011-10-26 Thread Rebelo
Try Pylons. Use html templates which get populated with data from your database 
and then just render them. If you just want to display data, with simple forms 
for editing and adding Pylons framework is more then enough.

http://pylonsbook.com/en/1.1/
http://www.pylonsproject.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: logging: warn() methods and function to be deprecated.

2011-10-26 Thread Vinay Sajip
Mike C. Fletcher  vrplumber.com> writes:

> I actually consider .warning() a nit :) .  After all, it's 3 extra
> characters :) , and *who* actually reads documentation instead of just
> poking around and finding the shortest-named method in the instance?

Readability counts :-) Are you saying there's no need to bother documenting
stuff ??? ;-)
 
> Anyway, I personally don't see this as worth the breakage.
 
What breakage are we really talking about? Remember, Python 2.x will not change
in this area - the proposed change is for Python 3.3 and later only, and will
not be backported :-)

As far as I know, Trac doesn't work with Python 3 anyway. Most of the code out
there (which Mark found via Google Code Search) is Python 2.x. When porting from
2 to 3.3, it's just one extra little thing to deal with - small compared with
other issues which come up when doing such ports.

Regards,

Vinay Sajip


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


Forking simplejson

2011-10-26 Thread Amirouche Boubekki
Héllo,

I would like to fork simplejson [1] and implement serialization rules based
on protocols instead of types [2], plus special cases for protocol free
objects, that breaks compatibility. The benefit will be a better API for
json serialization of custom classes and in the case of iterable it will
avoid a calls like:

>>> simplejson.dumps(list(my_iterable))

The serialization of custom objects is documented in the class instead of
the ``default`` function of current simplejson implementation [3].

The encoding algorithm works with a priority list that is summarized in the
next table:

+---+---+
| Python protocol   | JSON  |

|  or special case  |   |
+===+===+
| (ø) __json__  | see (ø)   |

+---+---|

| map   | object|

+---+---+
| iterable  | array |
+---+---+
| (*) float,int,long| number|

+---+---+
| (*) True  | true  |
+---+---+
| (*) False | false |

+---+---+
| (*) None  | null  |
+---+---+
| (§) unicode   | see (§)   |

+---+---+


(ø) if the object implements a __json__ method, the returned value is used
as the serialization of the object
(*) special objects which are protocol free are serialized the same way it's
done currently in simplejson
(§) if the algorithm arrives here, call unicode (with proper encoding rule)
on the object and use the result as json serialization

As soon as an object match a rule, it's serialized.

What do you think ? Do you find this API an improvement over simplejson ? Is
it worth to code ?

Where are documented the different protocols implemented by Python objects ?



Regards,

Amirouche

[1] https://github.com/simplejson/simplejson
[2]
https://github.com/simplejson/simplejson/blob/master/simplejson/encoder.py#L75
[3]
http://simplejson.readthedocs.org/en/latest/index.html#simplejson.JSONEncoder.default
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: logging: warn() methods and function to be deprecated.

2011-10-26 Thread Mike C. Fletcher
On 11-10-26 05:12 AM, Vinay Sajip wrote:
> Mike C. Fletcher  vrplumber.com> writes:
>
>> I actually consider .warning() a nit :) .  After all, it's 3 extra
>> characters :) , and *who* actually reads documentation instead of just
>> poking around and finding the shortest-named method in the instance?
> Readability counts :-) Are you saying there's no need to bother documenting
> stuff ??? ;-)

More: an undocumented entry point is not "deprecated" because, after
all, it shows up in PyDoc as a regular method.
>  
>> Anyway, I personally don't see this as worth the breakage.
>  
> What breakage are we really talking about? Remember, Python 2.x will not 
> change
> in this area - the proposed change is for Python 3.3 and later only, and will
> not be backported :-)
>
> As far as I know, Trac doesn't work with Python 3 anyway. Most of the code out
> there (which Mark found via Google Code Search) is Python 2.x. When porting 
> from
> 2 to 3.3, it's just one extra little thing to deal with - small compared with
> other issues which come up when doing such ports.
Sure, but most of *everything* is Python 2.x, and porting to Python 3.x
is already enough of a pain that key-stone projects like Trac still
aren't there :) .  This isn't going to be easily amenable to
auto-translation via 2to3 (because you generally are calling log.warn()
rather than logging.warning, but sometimes you are doing getattr( log,
log_level ) and then passing that method around a few times), and it
will often fall into the small percentage of untested code in most
projects (coverage is often poor for logging messages in corner cases),
so often won't get caught by test suites.

Not a 3.x user, but expecting to have to be some day in the future,
Mike

-- 

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

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


Re: webapp development in pure python

2011-10-26 Thread Roy Smith
In article 
<18902163.1637.1319614150053.JavaMail.geo-discussion-forums@yqp37>,
 Rebelo  wrote:

> Try Pylons. Use html templates which get populated with data from your 
> database and then just render them. If you just want to display data, with 
> simple forms for editing and adding Pylons framework is more then enough.
> 
> http://pylonsbook.com/en/1.1/
> http://www.pylonsproject.org/

If you're looking at web frameworks, you should also look at 
http://www.tornadoweb.org/.  It's more of a HTTP engine than a 
application framework, but has some elements of both.  We use it for 
lots of small HTTP tools we write.

But, to go back to the OP's request:

> What I need is a programmable GUI with windows, event handlers and
> extensible widgets, for creating applications that use http/https and a web
> browser for rendering.

combined with:

> I need something that does not require javascript knowledge, just pure Python.

I'm not sure there's a good answer to that.  If you're talking GUIs, 
windows, and extensible widgets, it really sounds like the kinds of 
things you're trying to do are going to require javascript.  I'm not a 
huge fan of javascript, but the reality today is that for any kind of 
interactive UI in a web browser, you need to go there.  Well, or Flash, 
but that's probably even more evil.

You might want to look at [[Dart (programming language)]], but that's 
more of a research project than a tool at the moment.  Check out that 
wikipedia page, however, it's got some pointers to other similar 
projects people are working on.
-- 
http://mail.python.org/mailman/listinfo/python-list


Parsing using one gramar with contexts

2011-10-26 Thread projetmbc
Hello,
I'm seeking for one friendly library to parse one language with taking
care of the context.

For example, I would like to parse text in one docstring differently
than the other code, or to add special keyword for the parsing when
I'm in one class...


Is there existing python tools for that ?
-- 
http://mail.python.org/mailman/listinfo/python-list


services/daemons

2011-10-26 Thread Andrea Crotti

Running pypiserver as a service?

I'm writing some scripts which in theory should be able to:
- start up a local pypi server as a daemon (or well a service on Windows)

- run "python setup.py develop" on a potentially very big set of eggs,
  possibly discovering automatically for changes.
  In theory using develop changes should be automatically seen, but if I
  move/rename something of course things might not work anymore.

- run/debug/develop applications using this big set of eggs.
  On the distutils list it was suggested to use the "-m" option to
  easy_install, which avoids writing on the global easy_install.pth,
  which is one of the current problems.

For the first one reading I thought I might use pypiserver (which ships
also as a single file) and create a windows service/unix daemon from it.

For the second I've seen watchdog:
https://github.com/gorakhargosh/watchdog/ which looks interesting.

As last thing the whole process should be as transparent and robust as
possible, anyone did something similar or has suggestions?

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


Re: spawnl issues with Win 7 access rights

2011-10-26 Thread Tim Golden

On 26/10/2011 02:11, Terry Reedy wrote:

OP reports 2.6 with XP works.


Where do you see that, Terry? (Or was there an offlist email?)


Did that use VS 2005? Maybe C runtime
changed (regressed).


That's possible -- and is essentially my main guess (faute de mieux). 
I've got the same results on 32 & 64-bit machines.


Hopefully the workaround I suggested -- doubling up the executable 
filepath -- will get round the user's particular issue. I'm not going to 
fight CRT changes, but if no-one else gets there, I will try to address 
issue8036


TJG
--
http://mail.python.org/mailman/listinfo/python-list


Re: logging: warn() methods and function to be deprecated.

2011-10-26 Thread Vinay Sajip
Mike C. Fletcher  vrplumber.com> writes:

> More: an undocumented entry point is not "deprecated" because, after
> all, it shows up in PyDoc as a regular method.

Deprecated methods also show up in PyDoc. Of course, if the deprecation is
mentioned in the docstring, users would see this - but if it isn't, they
wouldn't know until they got a DeprecationWarning.

> auto-translation via 2to3 (because you generally are calling log.warn()
> rather than logging.warning, but sometimes you are doing getattr( log,
> log_level ) and then passing that method around a few times), and it

That doesn't sound like a good usage pattern to me, especially as loggers have a
log method which takes the logging level. There shouldn't be any need to pass a
bound method around.

Regards,

Vinay Sajip


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


Re: Data acquisition

2011-10-26 Thread spintronic
Dear friends!

Thank you for the discussion. It was really helpful. As mentioned, it
was necessary to have a longer delay. Previously I have used a delay
of 5 and 10 s but it was not long enough. Now it is 25 s and
everything works fine.

Thank you again!

Best,
AS
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: logging: warn() methods and function to be deprecated.

2011-10-26 Thread Mike C. Fletcher
On 11-10-26 10:51 AM, Vinay Sajip wrote:
...
> auto-translation via 2to3 (because you generally are calling log.warn()
>> rather than logging.warning, but sometimes you are doing getattr( log,
>> log_level ) and then passing that method around a few times), and it
> That doesn't sound like a good usage pattern to me, especially as loggers 
> have a
> log method which takes the logging level. There shouldn't be any need to pass 
> a
> bound method around.
Bound methods also pull along to *which* log you are going to send the
message, but then I suppose you could just use the logging key as well
as a piece of data.  I'll withdraw the suggestion that it is not a
trivial thing to add to 2to3, though I'll leave the implementation to
someone else.

Have fun,
Mike

-- 

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

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


Review Python site with useful code snippets

2011-10-26 Thread Chris Hall
I am looking to get reviews, comments, code snippet suggestions, and
feature requests for my site.
I intend to grow out this site with all kinds of real world code
examples to learn from and use in everyday coding.
The site is:

http://www.pythonsnippet.com

If you have anything to contribute or comment, please post it on the
site or email me directly.

Thanks,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Forking simplejson

2011-10-26 Thread Nathan Rice
Since this happily went off to the wrong recipient the first time...

The python json module/simpljson are badly in need of an architecture
update.  The fact that you can't override the encode method of
JSONEncoder and have it work reliably without monkey patching the pure
python encoder is a sign that something is horribly wrong.

On Wed, Oct 26, 2011 at 5:14 AM, Amirouche Boubekki
 wrote:
> Héllo,
>
> I would like to fork simplejson [1] and implement serialization rules based
> on protocols instead of types [2], plus special cases for protocol free
> objects, that breaks compatibility. The benefit will be a better API for
> json serialization of custom classes and in the case of iterable it will
> avoid a calls like:
>
 simplejson.dumps(list(my_iterable))
>
> The serialization of custom objects is documented in the class instead of
> the ``default`` function of current simplejson implementation [3].
>
> The encoding algorithm works with a priority list that is summarized in the
> next table:
>
> +---+---+
> | Python protocol   | JSON  |
>
>
> |  or special case  |   |
> +===+===+
> | (ø) __json__  | see (ø)   |
>
>
> +---+---|
>
> | map   | object|
>
>
> +---+---+
> | iterable  | array |
> +---+---+
> | (*) float,int,long| number|
>
>
> +---+---+
> | (*) True  | true  |
> +---+---+
> | (*) False | false |
>
>
> +---+---+
> | (*) None  | null  |
> +---+---+
> | (§) unicode   | see (§)   |
>
>
> +---+---+
>
> (ø) if the object implements a __json__ method, the returned value is used
> as the serialization of the object
>
>
> (*) special objects which are protocol free are serialized the same way it's
> done currently in simplejson
> (§) if the algorithm arrives here, call unicode (with proper encoding rule)
> on the object and use the result as json serialization
>
>
> As soon as an object match a rule, it's serialized.
>
> What do you think ? Do you find this API an improvement over simplejson ? Is
> it worth to code ?
>
> Where are documented the different protocols implemented by Python objects ?
>
>
>
> Regards,
>
> Amirouche
>
> [1] https://github.com/simplejson/simplejson
> [2]
> https://github.com/simplejson/simplejson/blob/master/simplejson/encoder.py#L75
> [3]
> http://simplejson.readthedocs.org/en/latest/index.html#simplejson.JSONEncoder.default
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Data acquisition

2011-10-26 Thread Dietmar Schwertberger

Am 26.10.2011 17:58, schrieb spintronic:

Thank you for the discussion. It was really helpful. As mentioned, it
was necessary to have a longer delay. Previously I have used a delay
of 5 and 10 s but it was not long enough. Now it is 25 s and
everything works fine.

If you use the correct sequence of trigger and OPC/WAIT, I'm sure
you can reduce the waiting time to the required minimum time and
still your script will be more robust...

Regards,

Dietmar

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


Re: spawnl issues with Win 7 access rights

2011-10-26 Thread Terry Reedy

On 10/26/2011 10:38 AM, Tim Golden wrote:

On 26/10/2011 02:11, Terry Reedy wrote:

OP reports 2.6 with XP works.


Where do you see that, Terry? (Or was there an offlist email?)


The first message of http://bugs.python.org/issue8036
"Python 2.6 is however happy and just reports invalid arg."

--
Terry Jan Reedy

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


Re: Forking simplejson

2011-10-26 Thread Terry Reedy

On 10/26/2011 5:14 AM, Amirouche Boubekki wrote:

Héllo,

I would like to fork simplejson [1] and implement serialization rules
based on protocols instead of types [2], plus special cases for protocol
free objects, that breaks compatibility. The benefit will be a better
API for json serialization of custom classes and in the case of iterable
it will avoid a calls like:

 >>> simplejson.dumps(list(my_iterable))

The serialization of custom objects is documented in the class instead
of the ``default`` function of current simplejson implementation [3].

The encoding algorithm works with a priority list that is summarized in
the next table:

+---+---+
| Python protocol | JSON |
| or special case | |
+===+===+
| (ø) __json__ | see (ø) |
+---+---|
  | map   | object|


I am curious what you mean by the 'map' protocol.

> Where are documented the different protocols implemented by Python 
objects ?


Ref 3.3 special method names (and elsewhere ;-)
http://docs.python.org/py3k/reference/datamodel.html#special-method-names

---
Terry Jan Reedy


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


inserting \ in regular expressions

2011-10-26 Thread Ross Boylan
I want to replace every \ and " (the two characters for backslash and
double quotes) with a \ and the same character, i.e.,
\ -> \\
" -> \"

I have not been able to figure out how to do that.  The documentation
for re.sub says "repl can be a string or a function; if it is a string,
any backslash escapes in it are processed.That is, \n is converted to a
single newline character, \r is converted to a carriage return, and so
forth. Unknown escapes such as \j are left alone."

\\ is apparently unknown, and so is left as is. So I'm unable to get a
single \.

Here are some tries in Python 2.5.2.  The document suggested the result
of a function might not be subject to the same problem, but it seems to
be.
>>> def f(m):
...return "\\"+m.group(1)
... 
>>> re.sub(r"([\\\"])", f, 'Silly " quote')
'Silly \\" quote'
>>> re.sub(r"([\\\"])", r"\\1", 'Silly " quote')
'Silly \\1 quote'
>>> re.sub(r"([\\\"])", "1", 'Silly " quote')
'Silly \\1 quote'
>>> re.sub(r"([\\\"])", "\1", 'Silly " quote')
'Silly \\\x01 quote'
>>> re.sub(r"([\\\"])", "\\1", 'Silly " quote')
'Silly \\" quote'

Or perhaps I'm confused about what the displayed results mean.  If a
string has a literal \, does it get shown as \\?

I'd appreciate it if you cc me on the reply.

Thanks.
Ross Boylan

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


Re: inserting \ in regular expressions

2011-10-26 Thread Ian Kelly
On Wed, Oct 26, 2011 at 1:48 PM, Ross Boylan  wrote:
> Or perhaps I'm confused about what the displayed results mean.  If a
> string has a literal \, does it get shown as \\?

In the repr, yes.  If you try printing the string, you'll see that it
only contains one \.

By the way, regular expressions are overkill here.  You can use the
str.replace method for this:

>>> print(r'Silly \ " quote'.replace('\\', '').replace('"', r'\"'))
Silly \\ \" quote

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [wanted] python-ldap for Python 2.3 / Win32

2011-10-26 Thread Michael Ströder
Waldemar Osuch wrote:
> I did try to build it using my current setup but it failed with some linking 
> errors.
> Oh well.

Waldemar, I really appreciate your Win32 support.

> Google gods were nicer to me.  Here is a couple alternative links.
> Maybe they will work for you.
> http://web.archive.org/web/20081101060042/http://www.agescibs.org/mauro/
> http://old.zope.org/Members/volkerw/LdapWin32/

Puh, this is really ancient stuff...

For Python historians:
http://python-ldap.cvs.sourceforge.net/python-ldap/python-ldap/CHANGES?view=markup

Ciao, Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inserting \ in regular expressions

2011-10-26 Thread Dave Angel

On 10/26/2011 03:48 PM, Ross Boylan wrote:

I want to replace every \ and " (the two characters for backslash and
double quotes) with a \ and the same character, i.e.,
\ ->  \\
" ->  \"

I have not been able to figure out how to do that.  The documentation
for re.sub says "repl can be a string or a function; if it is a string,
any backslash escapes in it are processed.That is, \n is converted to a
single newline character, \r is converted to a carriage return, and so
forth. Unknown escapes such as \j are left alone."

\\ is apparently unknown, and so is left as is. So I'm unable to get a
single \.

Here are some tries in Python 2.5.2.  The document suggested the result
of a function might not be subject to the same problem, but it seems to
be.

def f(m):

...return "\\"+m.group(1)
...

re.sub(r"([\\\"])", f, 'Silly " quote')

'Silly \\" quote'


re.sub(r"([\\\"])", "\\1", 'Silly " quote')

'Silly \\" quote'

Or perhaps I'm confused about what the displayed results mean.  If a
string has a literal \, does it get shown as \\?

I'd appreciate it if you cc me on the reply.

Thanks.
Ross Boylan

I can't really help on the regex aspect of your code, but I can tell you 
a little about backslashes, quote literals, the interpreter, and python.


First, I'd scrap the interpreter and write your stuff to a file.  Then 
test it by running that file.  The reason for that is that the 
interpreter is helpfully trying to reconstruct the string you'd have to 
type in order to get that result.  So while you may have successfully 
turned a double bacdkslash into a single one, the interpreter helpfully 
does the inverse, and you don't see whether you're right or not.


Next, always assign to variables, and test those variables on a separate 
line with the regex.  This is probably what your document meant when it 
mentioned the result of a function.


Now some details about python.

When python compiles/interprets a quote literal, the syntax parsing has 
to decide where the literal stops, so quotes are treated specially.  
Sometimes you can sidestep the problem of embedding quotes inside 
literals by using single quotes on the outside and double inside, or 
vice versa.  As you did on the 'Silly " quote' example.


But the more general way to put funny characters into a quote literal is 
to escape each with a backslash.  So there a bunch of two-character 
escapes.  backslash-quote is how you can put either kind of quote into a 
literal, regardless of what's being used to delimit it.  backslash-n 
gets a newline, which would similarly be bad syntax.  backslash-t and 
some others are usually less troublesome, but can  be surprising.  And 
backslash-backslash represents a single backslash.  There are also 
backslash codes to represent arbitrary characters you might not have on 
your keyboard.  And these may use multiple characters after the backslash.


So write a bunch of lines like
 a = 'this is\'nt a surprise'
 print a

and experiment.  Notice that if you use \n in such a string, the print 
will put it on two lines.  Likewise the tab is executed.


Now for a digression.  The interpreter uses  repr() to display strings.  
You can experiment with that by doing

 print a
 print repr(a)

Notice the latter puts quotes around the string.  They are NOT part of 
the string object in a.  And it re-escapes any embedded funny 
characters, sometimes differently than the way you entered them.


Now, once you're confident that you can write a literal to express any 
possible string, try calling your regex.

print re.sub(a, b, c)

or whatever.

 Now, one way to cheat on the string if you know you'll want to put 
actual backslashes is to use the raw string. That works quite well 
unless you want the string to end with a backslash.  There isn't a way 
to enter that as a single raw literal.  You'd have to do something 
string like

 a = r"strange\literal\with\some\stuff" + "\\"

My understanding is that no valid regex ends with a backslash, so this 
may not affect you.


Now there are other ways to acquire a string object. If you got it from 
a raw_input() call, it doesn't need to be escaped, but it can't have an 
embedded newline, since the enter key is how the input is completed.  If 
you read it from a file, it doesn't need to be escaped.


Now you're ready to see what other funny requirements regex needs.  You 
will be escaping stuff for their purposes, and sometimes that means your 
literal might have 4 or even more backslashes in a row.  But hopefully 
now you'll see how to separate the different problems.

--

DaveA

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


RE: webapp development in pure python

2011-10-26 Thread Prasad, Ramit
I am not really an expert web developer, so this is just my two cents.

> My Python module would connect to a database server and query 
>some data, then display it in a grid. This cannot be compiled into 
>javascript because of the database server connection. 

You technically can connect to databases from JavaScript. It is a terrible 
idea, but achievable. Not really sure how it would get "compiled" into 
JavaScript, so it is possible that is the stumbling block.
http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript

>I would have to create the server side part separately, the user interface 
>separately, and hand-code the communication between the widets and the server 
>side.

As far as I know, this is the Right way to do a web/GUI apps; you may want to 
read about the MVC design pattern.

>I would like to use this theoretical web based framework just like pygtk or 
>wxPython

Even in wxPython/pygtk, you should be using MVC pattern. Usually if your app is 
one class, you either have a trivial application or you are doing it wrong. Of 
course, that really applies to larger projects more than hacked together code 
for personal use.

Apologies in advance if I misunderstood something.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inserting \ in regular expressions

2011-10-26 Thread MRAB

On 26/10/2011 20:48, Ross Boylan wrote:

I want to replace every \ and " (the two characters for backslash and
double quotes) with a \ and the same character, i.e.,
\ ->  \\
" ->  \"

I have not been able to figure out how to do that.  The documentation
for re.sub says "repl can be a string or a function; if it is a string,
any backslash escapes in it are processed.That is, \n is converted to a
single newline character, \r is converted to a carriage return, and so
forth. Unknown escapes such as \j are left alone."

\\ is apparently unknown, and so is left as is. So I'm unable to get a
single \.


[snip]
The backspace character is also used for escaping in a regex, so you
need to escape it with a backslash:

>>> print('Silly " quote or \\ backslash')
Silly " quote or \ backslash
>>> print (re.sub(r'(["])', r"\\\1", 'Silly " quote or \\ backslash'))
Silly \" quote or \\ backslash
--
http://mail.python.org/mailman/listinfo/python-list


Re: No more Python support in NetBeans 7.0

2011-10-26 Thread web
Sorry to comment on an old topic, but I wanted to clarify for others like me 
who might get the wrong idea. 

It looks like this is no longer true. Netbeans 7 might be supporting python 
after all.

http://wiki.netbeans.org/Python70Roadmap
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing Python data to a javascript function

2011-10-26 Thread Chris Rebert
On Wed, Oct 26, 2011 at 7:25 PM, Bill Allen  wrote:
>
> Benjamin,
>
> I was afraid I was doing that.   I have simplified it quite a bit, still not
> getting the output I am looking for.   I am down to that I am not passing
> the value in the onload=showPID() call correctly.  I know this is getting a
> bit far from a Python issue now, but if you have more insight on this, I
> would appreciate it.  Is there another way of passing the data from the
> Python script to the javascript than what I am doing in this CGI?

The problem is that you're not passing the data at all. You never
interpolate the pid_data value into the string(s) constituting your
embedded JavaScript (though you did do it just fine in the pure HTML).
The Python variable `pid_data` is not somehow magically accessible to
JavaScript; you must explicitly insert its value somewhere.


> pid_data = str(os.getpid())

> print """

> 

Change that line to:


As an example, if the PID happens to be 42, then the outputted
fragment will end up being:


As a sidenote, I would recommend using something higher-level than the
`cgi` module. Python has an abundance of web frameworks and templating
languages; take your pick.

Cheers,
Chris
--
http://rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webapp development in pure python

2011-10-26 Thread Chris Angelico
On Thu, Oct 27, 2011 at 8:47 AM, Prasad, Ramit
 wrote:
> You technically can connect to databases from JavaScript. It is a terrible 
> idea, but achievable. Not really sure how it would get "compiled" into 
> JavaScript, so it is possible that is the stumbling block.
> http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript
>

Strongly recommend against this. I haven't confirmed, but by the look
of it the code there is IE-only and MS SQL Server only. Also, remote
database access is a major security concern. I would recommend keeping
it all on the server (more efficient that way, too).

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


Re: passing Python data to a javascript function

2011-10-26 Thread Chris Angelico
On Thu, Oct 27, 2011 at 2:51 PM, Bill Allen  wrote:
> Chris,
>
> Wow, that seems so simple now that I see it.  I was dancing around that all
> day, but just not landing on it.   Thanks so very much for the assist.
>
> --Bill
>
> Final code that works perfectly, passes the value from the Python script to
> the javascript correctly:
>
> 

Congratulations! You've just written code that writes code. It takes a
bit to get your head around it (especially when you start worrying
about literal strings that might contain quotes, for instance), but
it's really cool and seriously powerful stuff. Your server-side Python
code can generate client-side Javascript code any way it likes...
unlimited possibilities.

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


Re: webapp development in pure python

2011-10-26 Thread 88888 Dihedral
I am thinking one has to distinguish between programs for database servers of   
the commercial applications in banks or insurance companies that cant be hacked 
in low costs, and experiments to chunk out database servers for games and 
videos all over the world! 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webapp development in pure python

2011-10-26 Thread Chris Angelico
On Thu, Oct 27, 2011 at 4:04 PM, 8 Dihedral
 wrote:
> I am thinking one has to distinguish between programs for database servers of 
>   the commercial applications in banks or insurance companies that cant be 
> hacked in low costs, and experiments to chunk out database servers for games 
> and videos all over the world!

I don't know about that. Best practices are often best for everyone;
it's more critical for a bank than for a game server, but that doesn't
mean the game server can afford to use swiss cheese as armor plate.
Particularly if it's the livelihood of the game designer; in fact,
that might even make it _more_ important than for a bank.

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


Re: webapp development in pure python

2011-10-26 Thread 88888 Dihedral
OK, lets start a framework in using python  in  the server side and the client 
side. 

(1). requirements of the server side first: 

1. sending  HTML, XML documents to be displayed  in the browsers of the clients 
 and receiving  for user inputs are  easy in  modpython, django, and etc.

2. Data received in the server side has to be stored and verified for later 
accesses performed from client's requests

3. data and traffic  amounts  to be estimated for the server in order  to 
process requests in terms of numbers of clients and costs per defined operation 
period,  well, a slow  database engine that consumes a lot CPU time in  the 
server really sucks!


(2). Lets check the client side, too! 

In scenario 1  the client side has the browser operating only via port 80. 

In scenario 2 the client side has an AP. that could be invoked in the browser, 
e.g. Adobe PDF reader or Apple's quick time engine 

In scenario 3 AP. can invoke the browser to a cyber page  in the client side 
with multiple sockets via TCPIP/UDP of various ports in the AP., e.g. skype, 
msn, and etc..  

Assuming that programmers can use a customized  python package  installed  in 
the AP. of the client side with other tools is allowed.
   
-- 
http://mail.python.org/mailman/listinfo/python-list