Commit 86d1b939 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Initial helper methods (used by external sources for example). Work in progress.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25559 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent fb85ecef
......@@ -85,6 +85,51 @@ class UrlMixIn:
url_string = url
self.setUrlString(url_string)
security.declareProtected(Permissions.AccessContentsInformation,
'getURLServer')
def getURLServer(self):
"""
Returns the server part of a URL
XXX - we must add here more consistency checking
based on the protocol of the URL
XXX - regular expressions would be better
"""
url_string = self.getUrlString()
return url_string.split('/')[0].split(':')[0]
security.declareProtected(Permissions.AccessContentsInformation,
'getURLPort')
def getURLPort(self):
"""
Returns the port part of a URL
XXX - we must add here more consistency checking
based on the protocol of the URL
XXX - regular expressions would be better
"""
url_string = self.getUrlString()
server_part_list = url_string.split('/')[0].split(':')
if len(server_part_list) > 1:
return server_part_list[1]
return None
security.declareProtected(Permissions.AccessContentsInformation,
'getURLPath')
def getURLPath(self):
"""
Returns the path part of a URL
XXX - we must add here more consistency checking
based on the protocol of the URL
XXX - regular expressions would be better
"""
url_string = self.getUrlString()
return '/'.join(url_string.split('/')[1:])
class Url(Coordinate, Base, UrlMixIn):
"""
A Url is allows to represent in a standard way coordinates
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment