Brainstorming for context oriented API
Idea
Split up the current Request object into smaller context oriented objects, which are passed down to the methods instead of 'request'. Example: methods working with parser/formatter get passed a RenderContext with appropiate attributes instead of the classic 'request'-object, which held all information at once.
Which contexts should be provided? What is needed to be present on them? Any questions on the implementation?
HTTPContext
Typical responsibilites:
- headers
- input/output streams
- query parameters
- post/forms data
Method in the old API |
Functionality in the new API |
setHttpHeader |
Provided by 'Response'-property |
getUserAgent |
Provided by 'Request'-property |
parse_cookie |
Provided by 'Request'-property |
setURL |
Provided by 'Request'-property |
rewriteRemoteAddr |
? |
rewriteHost |
? |
rewriteURI |
? |
makeURI |
combination of provided 'Request'-properties |
setIsSSL |
Provided by 'Request'-property |
setHost |
Provided by 'Request'-property |
getPathInfo |
Provided by 'Request'-property |
setContentLanguage |
Provided by 'Response'-property |
emit_http_headers |
Provided by 'Response'-property |
getScriptname |
Provided by 'Request'-property |
redirect |
Provided by 'HTTPException'-objects |
MockHTTPContext (for debugging)
- see HTTPContext
- logging on methods
- elaborate exception handling
RenderContext
- output formatter
- what about caching of output? this layer?
Method in the old API |
Functionality in the new API |
loadTheme & initTheme |
? |
redirectedOutput |
? |
write |
returning 'Response'-objects |
normalizePagename |
put into a library package |
setPragma & getPragma |
should be put unto Page objects (is page metadata) => sync with ChristopherDenter |
ScriptContext
- ? (still need some ideas on this one, Armin suggested it in passing)