Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 2nd, 2004, 06:41 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
net-0.1 (Attached)

I hate to toot my own horn, but if you do anything with CGI and Python then chances are you’ll find this pretty interesting and or hopefully useful .

Some History:

A little while ago I had an idea for a project kind of a Zope-WikiWiki-CGI half bread named Nickel. However I was reluctant to start on the project using Pythons current CGI modules (I don’t think I’m the only one who things Python is lagging behind the times in this respect), in particular ‘Cookies’; as it seemed to me that that the module itself has been mostly depreciated and in need of a serious update.

So I sat down whipped up my own module to handle common CGI tasks the way I wanted them handled

As of version 0.1 net supports:
1.A uniquely easy to use, flexible, full-featured cookie interface with support for loading cookie data!

2.Automatic form variables (net.form[‘key’]). Although this seems very stable it does need heavy testing. With the possibility of more features being added to the form parser.

3.Simple, automatic error catching. This is just a formatted HTML version of Pythons standard error messages.

4.Last but not least the module comes ready packaged to take advantage of Python 2.3’s ZIP import feature. All you have to do is move net.zip to you're site-packages directory and point a pth file at it!

If you want to find out more about pth files check out the link below:

http://www.python.org/doc/2.3.3/lib/module-site.html

If you haven’t realised it yet… this is more or less everything you need to write web applications with Python and CGI!

Tthere are no home page or docs right now although I’d be happy to post examples if you're is interest. Anyway, you have an interesting ideas/features that need adding? Let me know what you think .

Mark.
Attached Files
File Type: zip net.zip (10.4 KB, 267 views)
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #2  
Old March 2nd, 2004, 04:49 PM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 7
Send a message via MSN to Grim Archon
Netytan- it looks . Going to test it out.

Does this display all form values if it was the cgi called from a form page?
Code:
#!/usr/bin/env python
#printform.py

import net
print 'Content-Type: text/html\n'
for n in form.keys():
    print n,`form[n]`


Grim
__________________
*** Experimental Python Markup CGI V2 ***

Reply With Quote
  #3  
Old March 2nd, 2004, 05:32 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Thanks Grim, actually what you want is more like this.

Code:
#!/usr/bn/env python

import net

print 'Content-Type: text/html\n'

for field in net.form:
    pritn field, '=>', net.form[field]


Mark.

Reply With Quote
  #4  
Old March 2nd, 2004, 05:44 PM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 7
Send a message via MSN to Grim Archon
oops! forgot the module That will teach me to check my code before posting .

Grim

Reply With Quote
  #5  
Old March 2nd, 2004, 07:59 PM
rebbit rebbit is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 84 rebbit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 7 m
Reputation Power: 5
It looks pretty good to me mate, though it doesn't seem to provide a great deal of extra functionality over the current cgi module. maybe add a logging feature like there is in cgi.py, then start working on some nifty little features to show the current cgi module up

Very interesting though, I'll see if I can think of anything to add.

Reply With Quote
  #6  
Old March 3rd, 2004, 05:00 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Ah the idea wasn't to fill the module with lots of useless stuff like multiple field storage classes .

Although i plan to make the functions in module.py available in though 'net' for version 0.2 aswell as having cookies variables automatically loaded like forms.

I'm trying to keep it as simple as i can, but make it more of an environment than a module... it actually does the job of cgi, Cookie and cgitb but much more elagantly! All you have to do is import the module and most common tasks are done for you...

Which one looks cleaner?

Code:
#!/usr/bin/env python

import net


or

Code:
#!/usr/bin/env python

import cgi, Cookies, cgitb
cgitb.enable()
form = cgi.FieldStorage()


I was also considering a URL data type for manipulating URLs and or reading from a website. The log sounds cool though. i just don't like the idea of somone being able to load the error log though there browser. Seems like a bit of a security hole.

Plus, in order to be of much use it would have to have all the power of Apache's error log.

Mark.

Reply With Quote
  #7  
Old March 3rd, 2004, 09:34 AM
XxChris XxChris is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 217 XxChris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool stuff netytan . One question though: Is there any way to submit things like this, along with language extentions to the Python team for review or something? That way if a developer wrote something that had potential, it could have the chance to be included in the language or distribution.

Oh, and it's well commented

Last edited by XxChris : March 3rd, 2004 at 09:37 AM.

Reply With Quote
  #8  
Old March 3rd, 2004, 09:56 AM
FLNHST FLNHST is offline
404 Error
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: http://hester.dns2go.com
Posts: 18 FLNHST User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 3 sec
Reputation Power: 0
Nice stuff! this could really help me because i just started web apps programming.

but how do you use the cookie module?

Reply With Quote
  #9  
Old March 3rd, 2004, 09:56 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Thanks , i did go a little comment nuts i admit but. Not as far as i know Xx:

I think if everyone is using the module or there is demand for the it in python then the Python team include it although not having anything in the standard lib myself i don't know the finer points... but it seems to be a populrity contenst .

Having said that there are alot excelent 3rd party things that havn't yet made it in!

So i surpose if you really wished to show of you're work you could always post it on the mailing list or email the Python guys directly at webmaster@python.org and see what comes back.

Another good way to get you're code around would be to add it to the PyPI like Grim did with his excelent py2html module.

http://www.python.org/pypi

Mark.

Reply With Quote
  #10  
Old March 3rd, 2004, 10:10 AM
XxChris XxChris is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 217 XxChris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ahh cool, thanks . I hope Python will have something like CPAN soon!

Last edited by XxChris : March 3rd, 2004 at 10:12 AM.

Reply With Quote
  #11  
Old March 4th, 2004, 02:21 AM
rebbit rebbit is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 84 rebbit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 7 m
Reputation Power: 5
netytan - I realise you're trying to make things cleaner rather than bloat the module, and that's cool. however, all the functionality your module provides is already achieveable with existing modules, so using it is purely for cosmetic reasons. I hope you don't take offense or anything, I like the idea and the implementation so far, I don't mean to come off as an ***

To get it considered as a module to ship with the standard Python distro, you would probably need to suggest it in a PEP on the Python site and see what kind of support / criticism you get. If the idea is supported, you could get it added to the list of todo's. However, as the module doesn't provide any extra functionality and would be put into to use for "cleaning" purposes, it would probably be low on the list if supported.

Your best bet would be to look into getting it on the "Sumo" distro of Python. I'm not sure on the status of this project, but it's basically a distro of Python with a whole heap of extra bells and whistles (in the form of third party modules etc). Worth looking into anyway

Reply With Quote
  #12  
Old March 4th, 2004, 05:38 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
No problem rebbit, critasism is as good as praise . Actually net suports loading cookies - a feature i am not aware of in the std-lib. And in version 0.2 a new encode, decode (URL encryption and decyption) and escape (an omproved version of cgi.escape; the only remotly useful function in there IMO) function are availble.

I'm also thinking about replacing the 'form' variable with 'request' or 'namespace' like in PHP which will contain values from all input streams (currently - cookies and forms) instead of having seperate var names. I will also be adding a config file to give more controle over nets options.

Ah. i dont wana get it in the std-lib. Or at least not yet , it has a long way to go before i'll be happy with it. But it usable, and whats morevery clean, and i'm a big fan of clean code .

Mark.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > net-0.1 (Attached)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump