Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.
| File cp3tg.diff,
13.2 KB
(added by fredlin, 5 years ago) |
|
workable patch for trunk (but many fuctions are breaken)
|
-
|
|
|
|
| 38 | 38 | "TurboJson >= 0.9.9", |
| 39 | 39 | "TurboCheetah >= 0.9.5", |
| 40 | 40 | "TurboKid >= 0.9.9", |
| 41 | | "Genshi >= 0.3.3", |
| 42 | | "CherryPy >= 2.2.1,<3.0.0alpha", |
| | 41 | "Genshi >= 0.3.5", |
| | 42 | "CherryPy >= 3.0.0rc1", |
| 43 | 43 | "SQLObject >= 0.7.1,<=0.7.99", |
| 44 | | "simplejson >= 1.3", |
| | 44 | "simplejson >= 1.4", |
| 45 | 45 | "elementtree >= 1.2.6", |
| 46 | 46 | "PasteScript >= 1.0", |
| 47 | 47 | "cElementTree >= 1.0.5", |
| … |
… |
|
| 49 | 49 | "setuptools >= 0.6c3", |
| 50 | 50 | "RuleDispatch", |
| 51 | 51 | "ConfigObj >= 4.3.2", |
| 52 | | "nose >= 0.9"], |
| | 52 | "nose >= 0.9.1"], |
| 53 | 53 | packages=find_packages(), |
| 54 | 54 | include_package_data=True, |
| 55 | 55 | exclude_package_data={"thirdparty" : ["*"]}, |
-
|
|
|
|
| 9 | 9 | from turbogears import toolbox |
| 10 | 10 | |
| 11 | 11 | root = toolbox.Toolbox() |
| 12 | | cherrypy.root = root |
| | 12 | #cherrypy.root = root |
| | 13 | cherrypy.tree.mount(root) |
| 13 | 14 | print "Toolbox Development Mode" |
| 14 | 15 | cherrypy.config.update({"global" : { |
| 15 | 16 | "server.socketPort" : 7654, |
| … |
… |
|
| 20 | 21 | "logDebugInfoFilter.on" : False |
| 21 | 22 | }}) |
| 22 | 23 | |
| 23 | | cherrypy.server.start() |
| | 24 | #cherrypy.server.start() |
| | 25 | cherrypy.server.quickstart() |
| | 26 | cherrypy.engine.start() |
-
|
|
|
|
| 112 | 112 | }}) |
| 113 | 113 | |
| 114 | 114 | if not self.noopen: |
| 115 | | cherrypy.server.start_with_callback(self.openbrowser) |
| | 115 | #cherrypy.server.start_with_callback(self.openbrowser) |
| | 116 | cherrypy.server.quickstart(server=None); |
| | 117 | cherrypy.engine.start_with_callback(self.openbrowser) |
| 116 | 118 | else: |
| 117 | | cherrypy.server.start() |
| | 119 | #cherrypy.server.start() |
| | 120 | cherrypy.server.quickstart() |
| | 121 | cherrypy.engine.start() |
| 118 | 122 | |
| 119 | 123 | |
| 120 | 124 | commands = None |
-
|
|
|
|
| 150 | 150 | |
| 151 | 151 | def config_defaults(): |
| 152 | 152 | current_dir_uri = os.path.abspath(os.getcwd()) |
| 153 | | if not current_dir_uri.startswith("/"): |
| 154 | | current_dir_uri = "/" + current_dir_uri |
| 155 | 153 | defaults = {'current_dir_uri' : current_dir_uri} |
| 156 | 154 | return defaults |
| 157 | 155 | |
| … |
… |
|
| 207 | 205 | configure_loggers(configdict) |
| 208 | 206 | config.update(configdict) |
| 209 | 207 | |
| 210 | | def get(key, default_value=None, return_section=False, path = None): |
| | 208 | #def get(key, default_value=None, return_section=False, path = None): |
| | 209 | def get(key, default_value=None): |
| 211 | 210 | """Retrieves a config value""" |
| 212 | | value = config.get(key, default_value, return_section, path) |
| | 211 | #value = config.get(key, default_value, return_section, path) |
| | 212 | value = config.get(key, default_value) |
| 213 | 213 | if value and key == 'sqlobject.dburi' and os.name == "nt": |
| 214 | 214 | value = re.sub('///(\w):', '///\\1|', value) |
| 215 | 215 | return value |
-
|
|
|
|
| 18 | 18 | |
| 19 | 19 | unicodechars = re.compile(r"([^\x00-\x7F])") |
| 20 | 20 | |
| 21 | | if config.get("session_filter.on",None) == True: |
| 22 | | if config.get("session_filter.storage_type",None) == "PostgreSQL": |
| | 21 | if config.get("tools.sessions.on",None) == True: |
| | 22 | if config.get("tools.sessions.storage_type",None) == "PostgreSQL": |
| 23 | 23 | import psycopg2 |
| 24 | | config.update({'session_filter.get_db':psycopg2.connect(psycopg2.get('sessions.postgres.dsn'))}) |
| | 24 | config.update({'tools.sessions.get_db':psycopg2.connect(psycopg2.get('sessions.postgres.dsn'))}) |
| 25 | 25 | # support for mysql/sqlite/etc here |
| 26 | 26 | |
| 27 | 27 | def _process_output(output, template, format, content_type, mapping, fragment=False): |
| … |
… |
|
| 342 | 342 | |
| 343 | 343 | def flash(message): |
| 344 | 344 | """Set a message to be displayed in the browser on next page display.""" |
| 345 | | cherrypy.response.simple_cookie['tg_flash'] = tg_util.to_utf8(message) |
| 346 | | cherrypy.response.simple_cookie['tg_flash']['path'] = '/' |
| | 345 | cherrypy.response.cookie['tg_flash'] = tg_util.to_utf8(message) |
| | 346 | cherrypy.response.cookie['tg_flash']['path'] = '/' |
| 347 | 347 | |
| 348 | 348 | def _get_flash(): |
| 349 | 349 | """Retrieve the flash message (if one is set), clearing the message.""" |
| 350 | | request_cookie = cherrypy.request.simple_cookie |
| 351 | | response_cookie = cherrypy.response.simple_cookie |
| | 350 | request_cookie = cherrypy.request.cookie |
| | 351 | response_cookie = cherrypy.response.cookie |
| 352 | 352 | |
| 353 | 353 | def clearcookie(): |
| 354 | 354 | response_cookie["tg_flash"] = "" |
-
|
|
|
|
| 7 | 7 | from sqlobject.dbconnection import ConnectionHub, Transaction, TheURIOpener |
| 8 | 8 | |
| 9 | 9 | import cherrypy |
| 10 | | from cherrypy.filters.basefilter import BaseFilter |
| | 10 | #from cherrypy.filters.basefilter import BaseFilter |
| 11 | 11 | |
| 12 | 12 | import dispatch |
| 13 | 13 | from turbogears import config, errorhandling |
| … |
… |
|
| 329 | 329 | so_joins(sqlclass.__base__, joins) |
| 330 | 330 | return joins |
| 331 | 331 | |
| 332 | | class EndTransactionsFilter(BaseFilter): |
| | 332 | #class EndTransactionsFilter(BaseFilter): |
| | 333 | class EndTransactionsFilter(object): |
| 333 | 334 | def on_end_resource(self): |
| 334 | 335 | if _use_sa(): |
| 335 | 336 | session.clear() |
-
|
|
|
|
| 10 | 10 | |
| 11 | 11 | import pkg_resources |
| 12 | 12 | import cherrypy |
| 13 | | from cherrypy import _cputil |
| | 13 | #from cherrypy import _cputil |
| 14 | 14 | from formencode.variabledecode import NestedVariables |
| 15 | | from cherrypy._cpwsgi import wsgiApp, CPHTTPRequest |
| 16 | | from cherrypy._cpwsgiserver import CherryPyWSGIServer |
| | 15 | #from cherrypy._cpwsgi import wsgiApp, CPHTTPRequest |
| | 16 | #from cherrypy._cpwsgiserver import CherryPyWSGIServer |
| 17 | 17 | |
| 18 | | from turbogears import config, scheduler |
| | 18 | from turbogears import config, scheduler, util |
| 19 | 19 | from turbogears.view import loadBaseTemplates |
| 20 | 20 | from turbogears.database import hub_registry, EndTransactionsFilter |
| 21 | 21 | |
| … |
… |
|
| 72 | 72 | sys.exit(3) # force reload |
| 73 | 73 | time.sleep(freq) |
| 74 | 74 | |
| 75 | | cherrypy.lib.autoreload.reloader_thread = reloader_thread |
| | 75 | #cherrypy.lib.autoreload.reloader_thread = reloader_thread |
| 76 | 76 | |
| 77 | 77 | webpath = "" |
| 78 | 78 | |
| … |
… |
|
| 147 | 147 | This adds the "tg_js" configuration to make MochiKit accessible. |
| 148 | 148 | It also turns on stdlib logging when in development mode. |
| 149 | 149 | """ |
| 150 | | config.update({"/tg_static" : |
| | 150 | """config.update({"/tg_static" : |
| 151 | 151 | { |
| 152 | 152 | "static_filter.on" : True, |
| 153 | 153 | "static_filter.dir" : |
| 154 | 154 | os.path.abspath(pkg_resources.resource_filename(__name__, "static")), |
| 155 | 155 | 'log_debug_info_filter.on' : False, |
| | 156 | }""" |
| | 157 | config.update({"/tg_static" : |
| | 158 | { |
| | 159 | "tools.staticdir.on" : True, |
| | 160 | "tools.staticdir" : |
| | 161 | os.path.abspath(pkg_resources.resource_filename(__name__, "static")), |
| 156 | 162 | } |
| 157 | 163 | }) |
| 158 | | config.update({"/tg_js" : |
| | 164 | """config.update({"/tg_js" : |
| 159 | 165 | { |
| 160 | 166 | "static_filter.on" : True, |
| 161 | 167 | "static_filter.dir" : |
| 162 | 168 | os.path.abspath(pkg_resources.resource_filename(__name__, "static/js")), |
| 163 | 169 | 'log_debug_info_filter.on' : False, |
| 164 | | } |
| | 170 | }""" |
| | 171 | config.update({"/tg_js" : |
| | 172 | { |
| | 173 | "tools.staticdir.on" : True, |
| | 174 | "tools.staticdir" : |
| | 175 | os.path.abspath(pkg_resources.resource_filename(__name__, "static")), |
| | 176 | } |
| 165 | 177 | }) |
| 166 | | cherrypy.config.environments['development']['log_debug_info_filter.on'] = False |
| | 178 | #cherrypy.config.environments['development']['log_debug_info_filter.on'] = False |
| 167 | 179 | |
| 168 | | if config.get("decoding_filter.on", path="/") is None: |
| | 180 | """if config.get("decoding_filter.on", path="/") is None: |
| 169 | 181 | config.update({"/": { |
| 170 | 182 | "decoding_filter.on" : True, |
| 171 | 183 | "decoding_filter.encoding" : config.get( |
| 172 | 184 | "kid.encoding", "utf8") |
| 173 | | }}) |
| | 185 | }})""" |
| | 186 | if config.get("tools.decode.on") is None: |
| | 187 | config.update({"/": { |
| | 188 | "tools.decode.on" : True, |
| | 189 | "tools.decode.encoding" : config.get( |
| | 190 | "kid.encoding", "utf8") |
| | 191 | }}) |
| 174 | 192 | |
| 175 | 193 | loadBaseTemplates() |
| 176 | 194 | global webpath |
| … |
… |
|
| 221 | 239 | ext= entrypoint.load() |
| 222 | 240 | if hasattr(ext, "start_extension"): |
| 223 | 241 | ext.start_extension() |
| | 242 | #pass |
| 224 | 243 | |
| 225 | 244 | for item in call_on_startup: |
| 226 | 245 | item() |
| … |
… |
|
| 253 | 272 | scheduler._stop_scheduler() |
| 254 | 273 | log.info("Scheduler stopped") |
| 255 | 274 | |
| 256 | | old_object_trail = _cputil.get_object_trail |
| | 275 | """old_object_trail = _cputil.get_object_trail |
| 257 | 276 | |
| 258 | 277 | # hang on to object trail to use it to find an app root if need be |
| 259 | 278 | def get_object_trail(object_path=None): |
| … |
… |
|
| 264 | 283 | pass |
| 265 | 284 | return trail |
| 266 | 285 | |
| 267 | | _cputil.get_object_trail = get_object_trail |
| | 286 | _cputil.get_object_trail = get_object_trail""" |
| 268 | 287 | |
| 269 | | class SimpleWSGIServer(CherryPyWSGIServer): |
| 270 | | """A WSGI server that accepts a WSGI application as a parameter.""" |
| | 288 | """class SimpleWSGIServer(CherryPyWSGIServer): |
| | 289 | ""A WSGI server that accepts a WSGI application as a parameter."" |
| 271 | 290 | RequestHandlerClass = CPHTTPRequest |
| 272 | 291 | |
| 273 | 292 | def __init__(self): |
| … |
… |
|
| 288 | 307 | request_queue_size = conf( |
| 289 | 308 | "server.socket_queue_size"), |
| 290 | 309 | ) |
| 291 | | |
| | 310 | """ |
| 292 | 311 | def start_server(root): |
| 293 | | cherrypy.root = root |
| | 312 | """cherrypy.root = root |
| 294 | 313 | if config.get("tg.fancy_exception", False): |
| 295 | 314 | cherrypy.server.start(server=SimpleWSGIServer()) |
| 296 | 315 | else: |
| 297 | | cherrypy.server.start() |
| | 316 | cherrypy.server.start()""" |
| | 317 | cfg = util.load_project_config() |
| | 318 | cherrypy.tree.mount(root, config=cfg) |
| | 319 | #cherrypy.tree.mount(root) |
| | 320 | cherrypy.server.quickstart() |
| | 321 | cherrypy.engine.start() |
| | 322 | |
| 298 | 323 | |
| 299 | | if startTurboGears not in cherrypy.server.on_start_server_list: |
| 300 | | cherrypy.server.on_start_server_list.append(startTurboGears) |
| | 324 | if startTurboGears not in cherrypy.engine.on_start_engine_list: |
| | 325 | cherrypy.engine.on_start_engine_list.append(startTurboGears) |
| 301 | 326 | |
| 302 | | if stopTurboGears not in cherrypy.server.on_stop_server_list: |
| 303 | | cherrypy.server.on_stop_server_list.append(stopTurboGears) |
| | 327 | if stopTurboGears not in cherrypy.engine.on_stop_engine_list: |
| | 328 | cherrypy.engine.on_stop_engine_list.append(stopTurboGears) |
| 304 | 329 | |
| 305 | 330 | call_on_startup = [] |
| 306 | 331 | call_on_shutdown = [] |
-
|
|
|
|
| 8 | 8 | from turbogears import controllers |
| 9 | 9 | |
| 10 | 10 | import cherrypy |
| 11 | | from cherrypy.lib.cptools import serveFile |
| | 11 | #from cherrypy.lib.cptools import serveFile |
| | 12 | from cherrypy.lib.static import serve_file |
| 12 | 13 | |
| 13 | 14 | import pygettext |
| 14 | 15 | import msgfmt |
| … |
… |
|
| 283 | 284 | |
| 284 | 285 | if 'If-Modified-Since' in cherrypy.request.headers: |
| 285 | 286 | del cherrypy.request.headers['If-Modified-Since'] # see ticket #879 |
| 286 | | return serveFile(path,"application/x-download","attachment") |
| | 287 | #return serveFile(path,"application/x-download","attachment") |
| | 288 | return serve_file(path,"application/x-download","attachment") |
| 287 | 289 | lang_file = turbogears.expose()(lang_file) |
| 288 | 290 | |
| 289 | 291 | def string_collection(self,files=[]): |
-
|
|
|
|
| 74 | 74 | <pre> |
| 75 | 75 | tg-admin toolbox -c %s |
| 76 | 76 | </pre> |
| 77 | | """% (cherrypy.request.remoteAddr,cherrypy.request.remoteAddr) |
| | 77 | """% (cherrypy.request.remote.ip,cherrypy.request.remote.ip) |
| 78 | 78 | noaccess = turbogears.expose()(noaccess) |
-
|
|
|
|
| 6 | 6 | |
| 7 | 7 | import cherrypy |
| 8 | 8 | import pkg_resources |
| 9 | | from cherrypy.filters.basefilter import BaseFilter |
| | 9 | #from cherrypy.filters.basefilter import BaseFilter |
| 10 | 10 | |
| 11 | 11 | import turbogears |
| 12 | 12 | |
| … |
… |
|
| 67 | 67 | # Temporary until tg-admin can call create_extension_model |
| 68 | 68 | create_extension_model() |
| 69 | 69 | # Install Filter into the root filter chain |
| 70 | | if not hasattr(cherrypy.root, "_cp_filters"): |
| | 70 | """if not hasattr(cherrypy.root, "_cp_filters"): |
| 71 | 71 | cherrypy.root._cp_filters= [] |
| 72 | | cherrypy.root._cp_filters.append( filter ) |
| | 72 | cherrypy.root._cp_filters.append( filter )""" |
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | def shutdown_extension(): |
| … |
… |
|
| 104 | 104 | self.is_new= is_new |
| 105 | 105 | |
| 106 | 106 | |
| 107 | | class VisitFilter(BaseFilter): |
| | 107 | #class VisitFilter(BaseFilter): |
| | 108 | class VisitFilter(object): |
| 108 | 109 | ''' |
| 109 | 110 | A filter that automatically tracks visitors. |
| 110 | 111 | ''' |
Download in other formats: