public
Description: Google's Webkit, ported to Python, ported to Desktops.
Homepage: http://lkcl.net/pyjamas-desktop
Clone URL: git://github.com/lkcl/pyjamas-desktop.git
100644 136 lines (110 sloc) 3.746 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
try:
    from mod_python.util import FieldStorage, Field
    import fred
except ImportError, err:
    print "import error", err
    pass
import zct
import gc
 
from tls import local
 
globals()['l'] = local()
def get_zct():
 
    if hasattr(l, 'z'):
        return l.z
    z = zct.ZCTclass()
    globals()['l'].z = z
    return z
 
class repeated:
    """ this is a wrapper class that will add appropriate global functions
to this module
"""
    def __init__(self, name, content_type='text/html', template=1):
 
        self.name = name
        self.content_type = content_type
        self.template = template
        if hasattr(zct.ZCTclass, name):
            globals()[name] = self.dynamic_content_fn
        else:
            globals()[name] = self.static_content_fn
 
    def static_content_fn(self, req):
        flds = req.form
        REQUEST = {}
        REQUEST.update(flds)
        z = get_zct()
        z.set_options(req)
 
        page = z.linkprocess(REQUEST, self.name)
 
        if page != self.name:
            z.set_browser_info(z.info)
 
            return req.status
 
        if self.template:
            content = z.tmpl(page, REQUEST)
        else:
            content = z.straightload(page)
 
        z.set_browser_info(z.info)
 
        req.content_type = self.content_type
        req.write(str(content))
 
    def dynamic_content_fn(self, req):
        #flds = FieldStorage(req, keep_blank_values=1)
        flds = req.form
        REQUEST = {}
        REQUEST.update(flds)
 
        z = get_zct()
        z.set_options(req)
        req.content_type = self.content_type # default - can be changed by page!
        page = z.linkprocess(REQUEST, self.name)
 
        if page != self.name:
            z.set_browser_info(z.info)
 
            #return req.status
 
        content = getattr(z, page)(REQUEST)
 
        #f = open("/tmp/info.txt", "w")
        #f.write(repr(z.info))
        #f.write(str(content))
        #f.close()
 
        z.set_browser_info(z.info)
        req.write(str(content))
 
# static and dynamic html
for fname in ( 'index', 'menu', 'context', 'home', 'advertising', 'menuads',
        'mainads', 'profilecomms', 'profile', 'register',
        'registerpage', 'login', 'logout',
        'footer', 'legal', 'about', 'userhome',
        'homewelcome', 'introsearch',
        'messages', 'inbox', 'sendmessage', 'showmessage', 'messagesunexpand',
        'forums', 'forumsunexpand', 'forumslist', 'forumedit',
        'forum', 'forummessages', 'forumpost',
        'outbox',
        'logincontext',
        'fromuserstatus',
        'search', 'usersearch', 'tagsearch',
        'usersearchpage', 'quicksearchpage', 'mainsearchpage', 'tagsearchpage',
        'usersearchresults',
        'mainsearchresults', 'searchresults',
        'searchresultspage', 'tagsearchresultspage',
        'searcherror',
        'imagetestpage',
        'imagetest',
        'uploadimage', 'getimage', 'profileimages',
        'publicprofile',
        'testpage',
        'registersuccess',
        'registerwelcome',
        'tagadminlist', 'tagadmin', 'tagadminvalues',
        'tags', 'showtags',
        'veggies', 'besafe', 'besafe_search_engines',
        'termsnconditions', 'copyright',
        'definitions', 'mission', 'vision',
        'forgotten',
        'loginsuccess',
        'faq', 'tour',
        'resizeevent',
        'registersafety'):
    repeated(fname)
 
# css stylesheets
for fname in ( 'style', ):
    repeated(fname, 'text/css')
 
# jaaavascrippt
for fname in ( 'ajax_js' , 'wz_dragdrop_js', 'frame_popup_js',
        'resize_js', 'google_js'):
    repeated(fname, 'text/plain', 0)
 
# iiimages
for fname in ( 'transparentpixel_gif' , 'close_button_gif' ):
    repeated(fname, 'image/gif', 0)