Commit 015387de authored by Jean-Paul Smets's avatar Jean-Paul Smets

Added some default values in dictionnaries.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13567 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b47d8429
...@@ -36,16 +36,17 @@ from base64 import encode ...@@ -36,16 +36,17 @@ from base64 import encode
from mimetools import choose_boundary from mimetools import choose_boundary
from mimetypes import guess_type from mimetypes import guess_type
no_crawl_protocol_list = ['mailto', 'javascript', ]
no_host_protocol_list = ['mailto', 'news', 'javascript',]
default_protocol_dict = { 'Email' : 'mailto',
}
class UrlMixIn: class UrlMixIn:
# Declarative security # Declarative security
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation) security.declareObjectProtected(Permissions.AccessContentsInformation)
no_host_protocol_list = ['mailto', 'news', ]
default_protocol_dict = { 'Email' : 'mailto',
}
security.declareProtected(Permissions.AccessContentsInformation, security.declareProtected(Permissions.AccessContentsInformation,
'asURL') 'asURL')
def asURL(self): def asURL(self):
...@@ -57,12 +58,12 @@ class UrlMixIn: ...@@ -57,12 +58,12 @@ class UrlMixIn:
# A quick fix for all objects which did not # A quick fix for all objects which did not
# define protocol such as email addresses # define protocol such as email addresses
ptype = self.getPortalType() ptype = self.getPortalType()
if UrlMixIn.default_protocol_dict.has_key(ptype): if default_protocol_dict.has_key(ptype):
protocol = UrlMixIn.default_protocol_dict[ptype] protocol = default_protocol_dict[ptype]
else: else:
protocol = 'http' protocol = 'http'
url_string = self.getUrlString() url_string = self.getUrlString()
if protocol in UrlMixIn.no_host_protocol_list or url_string.startswith('//'): if protocol in no_host_protocol_list or url_string.startswith('//'):
return '%s:%s' % (protocol, url_string) return '%s:%s' % (protocol, url_string)
return '%s://%s' % (protocol, url_string) return '%s://%s' % (protocol, url_string)
......
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