- Timestamp:
- 09/26/09 10:45:22 (3 years ago)
- Location:
- Trunk/TurtolCMS
- Files:
-
- 1 removed
- 5 modified
-
BootStrap/AdminPage.py (modified) (1 diff)
-
BootStrap/InitializeCMS.py (modified) (1 diff)
-
Controls (deleted)
-
Core/Context.py (modified) (1 diff)
-
Storage/__init__.py (modified) (1 diff)
-
Types/HtmlPage.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Trunk/TurtolCMS/BootStrap/AdminPage.py
r1369 r1373 27 27 Asset.__init__ (self, '$AdminLayout', ctx, types=['TurtolCMS.Types.HtmlLayout']) 28 28 self['TurtolCMS.Types.HtmlLayout'] = { 29 'docType' : ' xml10trans'29 'docType' : 'html' 30 30 , 'tcmsLogo' : 'none' 31 31 , 'wrapper' : True -
Trunk/TurtolCMS/BootStrap/InitializeCMS.py
r1372 r1373 100 100 class _InitJs (Asset): 101 101 def __init__ (self, ctx): 102 base = ctx.BaseLocation() 102 103 Asset.__init__ (self, '$_InitJs', ctx, types=['TurtolCMS.Types.Widget', 'TurtolCMS.Types.JsLinkWidget']) 103 104 self['TurtolCMS.Types.Widget'] = { 'position': 50, 'container' : 'head'} 104 # FIXME: need baselocation 105 self['TurtolCMS.Types.JsLinkWidget.target'] = [ '/tcms/js/jquery.blockUI.js' 106 , '/tcms/js/initcms.js' 105 self['TurtolCMS.Types.JsLinkWidget.target'] = [ '%s/tcms/js/jquery.blockUI.js' % base 106 , '%s/tcms/js/initcms.js' % base 107 107 ] 108 108 -
Trunk/TurtolCMS/Core/Context.py
r1372 r1373 60 60 ''' 61 61 return self._store.GetAsset (cms=True) 62 63 def BaseLocation (self): 64 return self._params.get ('BaseLocation', '') 62 65 63 66 def LoadInitModule (self, req): -
Trunk/TurtolCMS/Storage/__init__.py
r1372 r1373 220 220 sessobj = None 221 221 try: 222 sessobj = self.Q(Session).filter_by(Session.key= key).one()222 sessobj = self.Q(Session).filter_by(Session.key==key).one() 223 223 except MultipleResultsFound, e: 224 224 # should never happen, if this code is right 225 225 # but if it does, let's delete ALL these sessions 226 sesslist = sql.Q(Session).filter_by(Session.key= key).all()226 sesslist = sql.Q(Session).filter_by(Session.key==key).all() 227 227 for s in sesslist: 228 228 self._session.delete (s) -
Trunk/TurtolCMS/Types/HtmlPage.py
r1369 r1373 62 62 req.write ('\n') 63 63 64 class ContentTypeWidget (Asset): 65 def __init__ (self, charset, ctx): 66 Asset.__init__ (self, '', ctx) 67 self._charset = charset 68 self['TurtolCMS.Types.Widget.position'] = 2 69 70 def Render (self, ctx, req): 71 req.write ('''<meta http-equiv="Content-type" content="text/html;charset=%s" />\n''' % self._charset) 72 64 73 class GeneratorWidget (Asset): 65 74 def __init__ (self, close, ctx): … … 90 99 91 100 def Render (self, ctx, req): 92 # FIXME: need baselocation working 93 req.write ('''<div id="tcms_logo"><img src="/tcms/logo.png"/></div>\n''') 101 req.write ('''<div id="tcms_logo"><img src="%s/tcms/logo.png"/></div>\n''' % ctx.BaseLocation()) 94 102 95 103 class HtmlPage (AssetType): … … 109 117 asset['$.layout'] = asset['parent'] 110 118 119 # Set the asset's doctype 120 asset['$.dtd'] = HtmlPage._DocTypes.get (asset['$.doctype'], None) 121 if asset['$.dtd'] is None: 122 asset['$.dtd'] = HtmlPage._DocTypes.get ('html') 123 111 124 asset['$.layercount'] = 1 112 125 while (asset['$.layout.parent']): … … 119 132 120 133 # Calculate our document type 121 asset['$.doctype'] = asset['$.layout'].get ('TurtolCMS.Types.HtmlLayout.docType', ' xml10trans')134 asset['$.doctype'] = asset['$.layout'].get ('TurtolCMS.Types.HtmlLayout.docType', 'html') 122 135 123 136 # Construct an list of widgets broken down by div … … 151 164 pass # TODO: this should be an error, but how to handle? 152 165 166 # Add the content-type widget 167 divs['head'].addWidget (ContentTypeWidget ('UTF-8', ctx)) 153 168 # Add the generator meta widget 154 divs['head'].addWidget (GeneratorWidget (asset['$.doctype'][:3] == 'xml', ctx)) 155 169 divs['head'].addWidget (GeneratorWidget (asset['$.dtd'][2], ctx)) 156 170 # Add the title widget 157 171 divs['head'].addWidget (TitleWidget (asset['$.title'], ctx)) 158 172 159 173 # gather all our widgets and put them into the divs structure 160 # TODO: collect prereqs from our widgets, reduce and insert into head?161 174 iLayer = asset['$.layercount'] 162 175 layer = asset … … 179 192 @staticmethod 180 193 def Head (ctx, req, asset): 181 req.SetResponseHeader ('Content-Type', 'text/html ')194 req.SetResponseHeader ('Content-Type', 'text/html; charset=UTF-8') 182 195 183 196 @staticmethod … … 185 198 layout = asset['$.layout'] 186 199 187 # Set our doctype 188 dtd = HtmlPage._DocTypes.get (asset['$.doctype'], None) 189 if dtd is None: 190 dtd = HtmlPage._DocTypes.get ('xml10trans') 191 req.write (dtd) 200 # write our dtd 201 req.write (asset['$.dtd'][0]) 192 202 193 203 # Open the html 194 if 'xhtml' in dtd: 195 req.write ('''<html xmlns="http://www.w3.org/1999/xhtml">\n''') 196 else: 197 req.write ('''<html>\n''') 204 req.write (asset['$.dtd'][1]) 198 205 199 206 # render each tagged container … … 211 218 # Raw data begins here 212 219 #========================================================================== 213 _DocTypes = { 'xml10trans' : '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 214 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>\n''' 215 , 'xml10strict' : '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 216 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n''' 217 , 'html40strict' : '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 218 "http://www.w3.org/TR/html4/strict.dtd">\n''' 219 , 'html40trans' : '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 220 "http://www.w3.org/TR/html4/loose.dtd">\n''' 220 # _DocTypes lists the "types" of documents we can output 221 # each entry in the dictionary is a tuple of: 222 # (doctype declaration, html open tag, bool: use xml-style tag closes) 223 _DocTypes = { 'html' : ( '''<!DOCTYPE html>\n''' 224 , '''<html>\n''' 225 , False 226 ) 227 , 'xml10trans' : ( '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 228 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>\n''' 229 , '''<html xmlns="http://www.w3.org/1999/xhtml\n''' 230 , True 231 ) 232 , 'xml10strict' : ( '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 233 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n''' 234 , '''<html xmlns="http://www.w3.org/1999/xhtml\n''' 235 , True 236 ) 237 , 'html40strict' : ( '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 238 "http://www.w3.org/TR/html4/strict.dtd">\n''' 239 , '''<html>\n''' 240 , False 241 ) 242 , 'html40trans' : ( '''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 243 "http://www.w3.org/TR/html4/loose.dtd">\n''' 244 , '''<html>\n''' 245 , False 246 ) 221 247 } 222 248