Home arrow Python arrow Page 4 - Karrigell for Python

A Few More Features - Python

Since Python is not specifically designed for web development, a number of technologies created by Python users exist that aim to provide a web development environment. While the exact approach to the situation varies among each framework, a few of these frameworks really stand out in the crowd. One such framework is Karrigell. Read on to learn more.

TABLE OF CONTENTS:
  1. Karrigell for Python
  2. Scripts and Services
  3. Being HIP
  4. A Few More Features
By: Peyton McCullough
Rating: starstarstarstarstar / 15
January 03, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Although I'm not a huge fan of the practice, tags can be generated within Python scripts, as shown here in tagTest.py:

from HTMLTags import *

print CENTER ( B ( "Test." ) )

Sessions are also possible with Karrigell, and Karrigell presents a nice, object-oriented approach to sessions. Let's create a simple script that demonstrates sessions in Karrigell. Upon accessing the script for the first time, the user will receive a “lucky number” of sorts. If the user refreshes, the same number will still appear since it will be stored inside of a session. However, the user will be given the option of resetting his or her lucky number by closing the session. Create a Karrigell service named luckyNumber.ks in which to house this script:

import random

user = Session()

def index():
   if not "luckyNumber" in dir ( user ):
      user.luckyNumber = random.randint ( 0, 20 )
   print "Your lucky number:", user.luckyNumber
   print "<br /><br />"
   print "<a href='reset'>Reset Lucky Number</a>"
def reset():
   user.close()
   print "Your lucky number has been reset."
   print "<br /><br />"
   print "<a href='index'>Back</a>"

Conclusion

Karrigell offers four methods of web development using Python: Python scripts, Karrigell services, HTML Inside Python and Python Inside HTML. Each method is unique and has its benefits, but they all share one thing in common: each method is very simple to employ in applications. Karrigell approaches web development in a straightforward manner, presenting simple solutions to a simple problem. Even installing Karrigell and configuring Apache and Karrigell to interact is a surprisingly simple process. Because of all this, Karrigell appeals to both newcomers and experts in Python alike.



 
 
>>> More Python Articles          >>> More By Peyton McCullough
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: