comparison MoinMoin/support/werkzeug/utils.py @ 4689:bd3f5ccf6fb6

updated werkzeug
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 19 Apr 2009 00:46:15 +0200
parents c404a1295318
children 7cb92118a93e
comparison
equal deleted inserted replaced
4688:3e4e67bcbedd 4689:bd3f5ccf6fb6
1107 qs = urllib.quote_plus(qs, ':&=') 1107 qs = urllib.quote_plus(qs, ':&=')
1108 return urlparse.urlunsplit((scheme, netloc, path, qs, anchor)) 1108 return urlparse.urlunsplit((scheme, netloc, path, qs, anchor))
1109 1109
1110 1110
1111 def secure_filename(filename): 1111 def secure_filename(filename):
1112 """Pass it a filename and it will return a secure version of it. This 1112 r"""Pass it a filename and it will return a secure version of it. This
1113 filename can then savely be stored on a regular file system and passed 1113 filename can then savely be stored on a regular file system and passed
1114 to :func:`os.path.join`. The filename returned is an ASCII only string 1114 to :func:`os.path.join`. The filename returned is an ASCII only string
1115 for maximum portability. 1115 for maximum portability.
1116 1116
1117 On windows system the function also makes sure that the file is not 1117 On windows system the function also makes sure that the file is not
1508 """ 1508 """
1509 try: 1509 try:
1510 if ':' in import_name: 1510 if ':' in import_name:
1511 module, obj = import_name.split(':', 1) 1511 module, obj = import_name.split(':', 1)
1512 elif '.' in import_name: 1512 elif '.' in import_name:
1513 items = import_name.split('.') 1513 module, obj = import_name.rsplit('.', 1)
1514 module = '.'.join(items[:-1])
1515 obj = items[-1]
1516 else: 1514 else:
1517 return __import__(import_name) 1515 return __import__(import_name)
1518 return getattr(__import__(module, None, None, [obj]), obj) 1516 return getattr(__import__(module, None, None, [obj]), obj)
1519 except (ImportError, AttributeError): 1517 except (ImportError, AttributeError):
1520 if not silent: 1518 if not silent: