<s> from uliweb . core . SimpleFrame import expose <EOL> def startup_installed ( sender ) : <EOL> url = sender . settings . GLOBAL . STATIC_URL . rstrip ( '<STR_LIT:/>' ) <EOL> expose ( '<STR_LIT>' % url , static = True ) ( static ) <EOL> def prepare_default_env ( sender , env ) : <EOL> env [ '<STR_LIT>' ] = url_for_static <EOL> def url_for_static ( filename = None , ** kwargs ) : <EOL> from uliweb import settings , application <EOL> from uliweb . core . SimpleFrame import get_url_adapter <EOL> from urlparse import urlparse , urlunparse , urljoin <EOL> import urllib <EOL> domain = application . domains . get ( '<STR_LIT>' , { } ) <EOL> ver = settings . GLOBAL . STATIC_VER <EOL> if ver : <EOL> kwargs [ '<STR_LIT>' ] = ver <EOL> external = kwargs . pop ( '<STR_LIT>' , False ) <EOL> if not external : <EOL> external = domain . get ( '<STR_LIT>' , False ) <EOL> if filename . startswith ( '<STR_LIT:/>' ) : <EOL> if filename . endswith ( '<STR_LIT:/>' ) : <EOL> filename = filename [ : - <NUM_LIT:1> ] <EOL> if kwargs : <EOL> filename += '<STR_LIT:?>' + urllib . urlencode ( kwargs ) <EOL> if external : <EOL> return urljoin ( domain . get ( '<STR_LIT>' , '<STR_LIT>' ) , filename ) <EOL> return filename <EOL> r = urlparse ( filename ) <EOL> if r . scheme or r . netloc : <EOL> x = list ( r ) <EOL> if kwargs : <EOL> x [ <NUM_LIT:4> ] = urllib . urlencode ( kwargs ) <EOL> return urlunparse ( x ) <EOL> else : <EOL> return filename <EOL> kwargs [ '<STR_LIT:filename>' ] = filename <EOL> url_adapter = get_url_adapter ( '<STR_LIT>' ) <EOL> return url_adapter . build ( '<STR_LIT>' , <EOL> kwargs , force_external = external ) <EOL> def static ( filename ) : <EOL> pass </s>
