Author: justi9
Date: 2010-10-08 15:43:07 -0400 (Fri, 08 Oct 2010)
New Revision: 4379
Modified:
mgmt/trunk/wooly/python/wooly/__init__.py
mgmt/trunk/wooly/python/wooly/bench.py
mgmt/trunk/wooly/python/wooly/datatable.py
mgmt/trunk/wooly/python/wooly/demo.py
mgmt/trunk/wooly/python/wooly/pages.py
mgmt/trunk/wooly/python/wooly/parameters.py
mgmt/trunk/wooly/python/wooly/server.py
mgmt/trunk/wooly/python/wooly/sql.py
mgmt/trunk/wooly/python/wooly/tables.py
mgmt/trunk/wooly/python/wooly/util.py
mgmt/trunk/wooly/python/wooly/widgets.py
Log:
Clean up wooly imports
Modified: mgmt/trunk/wooly/python/wooly/__init__.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/__init__.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/__init__.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,10 +1,4 @@
-from cStringIO import StringIO
-from urllib import quote, unquote_plus, unquote
-from copy import copy
-from urlparse import urlsplit
-from time import gmtime
-
-from wooly.profile import *
+from profile import *
from resources import ResourceFinder, StringCatalog
from template import *
from util import *
@@ -654,7 +648,8 @@
self.cookies_by_name[name] = (True, value, expires)
def expire_cookie(self, name):
- self.set_cookie(name, "", datetime(*gmtime(1)[0:6]))
+ dawn_of_time = time.gmtime(1)[0:6]
+ self.set_cookie(name, "", datetime(*dawn_of_time))
def get(self, key):
if key in self.values_by_path:
Modified: mgmt/trunk/wooly/python/wooly/bench.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/bench.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/bench.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,8 +1,8 @@
from xml.parsers.expat import ParserCreate
+from server import ClientSession
+from util import *
from wooly import Session, PageRedirect
-from wooly.server import ClientSession
-from util import *
class BenchmarkHarness(object):
def __init__(self, app):
Modified: mgmt/trunk/wooly/python/wooly/datatable.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/datatable.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/datatable.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,8 +1,8 @@
+from parameters import *
+from table import *
+from util import *
+from widgets import *
from wooly import *
-from wooly.parameters import *
-from wooly.table import *
-from wooly.widgets import *
-from util import *
strings = StringCatalog(__file__)
Modified: mgmt/trunk/wooly/python/wooly/demo.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/demo.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/demo.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,14 +1,10 @@
-import os
-
-from threading import Thread
-from time import sleep
-
+from forms import *
+from pages import HtmlPage
+from resources import StringCatalog
+from server import WebServer
+from util import *
+from widgets import *
from wooly import Application
-from wooly.server import WebServer
-from wooly.pages import HtmlPage
-from wooly.widgets import *
-from wooly.forms import *
-from wooly.resources import StringCatalog
strings = StringCatalog(__file__)
Modified: mgmt/trunk/wooly/python/wooly/pages.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/pages.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/pages.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,11 +1,8 @@
-import os
-
-from datetime import datetime
-
+from parameters import ListParameter
+from resources import StringCatalog
+from util import *
+from widgets import ItemSet
from wooly import *
-from wooly.parameters import ListParameter
-from wooly.resources import StringCatalog
-from wooly.widgets import ItemSet
strings = StringCatalog(__file__)
Modified: mgmt/trunk/wooly/python/wooly/parameters.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/parameters.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/parameters.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,5 +1,4 @@
-from copy import copy
-
+from util import *
from wooly import *
class DictParameter(Parameter):
Modified: mgmt/trunk/wooly/python/wooly/server.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/server.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/server.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,11 +1,7 @@
import socket
-from traceback import print_exc
-from datetime import datetime, timedelta
-from threading import Thread
-from wooly import *
-
from util import *
+from wooly import *
from wsgiserver import CherryPyWSGIServer
log = logging.getLogger("wooly.server")
Modified: mgmt/trunk/wooly/python/wooly/sql.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/sql.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/sql.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,5 +1,3 @@
-from copy import copy
-
from resources import *
from template import *
from util import *
Modified: mgmt/trunk/wooly/python/wooly/tables.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/tables.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/tables.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,6 +1,7 @@
+from parameters import *
+from util import *
+from widgets import *
from wooly import *
-from widgets import *
-from parameters import *
strings = StringCatalog(__file__)
Modified: mgmt/trunk/wooly/python/wooly/util.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/util.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/util.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,13 +1,22 @@
+import htmlentitydefs as entity
import logging
+import math
import os
import random
import sys
import time
+from copy import copy
from cStringIO import StringIO
-from datetime import datetime
+from datetime import datetime, timedelta
+from threading import Thread
from traceback import print_exc
+from urllib import quote, unquote_plus, unquote
+from urlparse import urlsplit
+from xml.sax.saxutils import escape
+from parsley.collectionsex import *
+
def unique_id():
bits0 = random.getrandbits(32)
bits1 = random.getrandbits(32)
@@ -16,24 +25,6 @@
return "%08x-%08x-%08x-%08x" % (bits0, bits1, bits2, bits3)
-try:
- from collections import defaultdict
-except ImportError:
- class defaultdict(dict):
- def __init__(self, default_factory=None):
- super(dict, self).__init__()
-
- self.default_factory = default_factory
-
- def __getitem__(self, key):
- try:
- super(dict, self).__getitem__(key)
- except KeyError:
- if self.default_factory is None:
- raise
- else:
- return self.default_factory()
-
class Writer(object):
def __init__(self):
self.writer = StringIO()
@@ -47,3 +38,20 @@
self.writer.close()
return string
+
+def escape_amp(string):
+ return str(string).replace("&", "&")
+
+def escape_entity(string, exceptions=None):
+ if not string:
+ return ""
+ t = ""
+ ex = exceptions or list()
+ for i in string:
+ if ord(i) in entity.codepoint2name and \
+ i not in ex:
+ name = entity.codepoint2name.get(ord(i))
+ t += "&" + name + ";"
+ else:
+ t += i
+ return t
Modified: mgmt/trunk/wooly/python/wooly/widgets.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/widgets.py 2010-10-08 19:33:55 UTC (rev 4378)
+++ mgmt/trunk/wooly/python/wooly/widgets.py 2010-10-08 19:43:07 UTC (rev 4379)
@@ -1,11 +1,7 @@
-from math import ceil
-import htmlentitydefs as entity
-from xml.sax.saxutils import escape
-
from parameters import *
from resources import *
+from util import *
from wooly import *
-import urllib
strings = StringCatalog(__file__)
@@ -351,11 +347,11 @@
def get_page_count(self, session):
count = self.get_count(session)
- return int(ceil(count / float(self.page_size)))
+ return int(math.ceil(count / float(self.page_size)))
def get_pageset_count(self, session):
page_count = self.get_page_count(session)
- return int(ceil(page_count / float(self.pageset_size)))
+ return int(math.ceil(page_count / float(self.pageset_size)))
def __link(self, href, content, class_=""):
return "<a href=\"%s\"%s>%s</a>" % \
@@ -493,20 +489,3 @@
def render_tag(self, session, action):
return action[2] and "a" or "span"
-
-def escape_amp(string):
- return str(string).replace("&", "&")
-
-def escape_entity(string, exceptions=None):
- if not string:
- return ""
- t = ""
- ex = exceptions or list()
- for i in string:
- if ord(i) in entity.codepoint2name and \
- i not in ex:
- name = entity.codepoint2name.get(ord(i))
- t += "&" + name + ";"
- else:
- t += i
- return t