Home | Trees | Index | Help |
|
---|
Package aquarium :: Package util :: Module InternalLibrary |
|
This is the "standard library" for Aquarium's structure.
Classes | |
---|---|
InternalLibrary |
This is the "standard library" for Aquarium's structure. |
Exceptions | |
---|---|
FormValueError |
Subclass ValueError for form errors that shouldn't occur. |
Forward |
Raise an instance of this class to make Aquarium do a forward. |
Function Summary | |
---|---|
Cache the results of f. | |
Clear gettext of stale translations. | |
Clear sys.modules of specific types of modules if one is stale. | |
This is a convenience method for traceback.print_exception. | |
Is math.floor(lastUpdate) < math.floor(currentValue)? | |
Call f with a StringIO instead of an output file. | |
Return true if the given module name is valid. |
Function Details |
---|
cacheByArgs(f, *args)Cache the results of f. Vary by args. The cache will be stored as an attribute of f named _cacheByArgs. Note that everything in args must be hashable (this implies non-modifiable) because args is used as a dictionary key. For this same reason, I can't support **kargs (which would probably be pretty slow anyway). Since the cache is attached to the function, it lives as long as the function does. If you need to throw the cache away on every request, use a new lambda for every request. Use this function very carefully. Make sure you're not over-zealous in your cacheing; some things should not be cached. Also, make sure your cache doesn't just grow infinitely; you should test to make sure you don't create a memory leak. When you do test, remember to turn sessions off, or else you'll mistake the creation of a lot of sessions for a memory leak. |
clearGetTextTranslations()Clear gettext of stale translations. Because translation instances can create a chain of interrelated fallbacks, if even one of them is stale, I clear them all. This setting is controlled by properties.CLEAR_GETTEXT. However, if that is undefined (which is likely since it's only mentioned here), I will use the value: properties.CLEAR_MODULES and properties.USE_GETTEXT |
clearModules()Clear sys.modules of specific types of modules if one is stale. See properties.CLEAR_MODULES. I took this method out of the InternalLibrary class so that you can call it really early, even before you create a Context to pass to InternalLibrary. This function also calls clearGetTextTranslations. HistoryThe problem that this method solves is simple: if I change a file, I don't want to have to restart the server. It's a simple problem, but it's tough to implement right. To prevent repeating mistakes, here's what has failed in the past:
|
getExceptionStr(etype=None, value=None, tb=None, *args, **kargs)This is a convenience method for traceback.print_exception.
Instead of accepting an output file, I'll use a StringIO and then return the results as a string. That's the one bit of convenience I add. |
isModified(lastUpdate, currentValue)Is math.floor(lastUpdate) < math.floor(currentValue)?
math.floor is used because the resolution of time.time() is higher than that of stat[ST_MTIME] on some operating systems / filesystems. |
passStringIO(toArg, f, *args, **kargs)Call f with a StringIO instead of an output file.
When f completes, serialize the StringIO to a string, and return that. This function is really useful when working with traceback.print_exception. |
validModuleName(name)Return true if the given module name is valid. This is valid: foo.bar These are not: .foo.bar, foo..bar, foo/bar, etc. Please note that externally, screens use "/"'s, but this function expects those to have been changed to "."'s. |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Jan 1 16:34:19 2007 | http://epydoc.sf.net |