Updated new.py for installing Plone 4 without buildout and added an alternative way to insert POD expressions in POD templates via fields (track-changed text still works).

This commit is contained in:
Gaetan Delannay 2010-10-27 12:06:21 +02:00
parent feca97bda3
commit 50c8a139fc
9 changed files with 1841 additions and 1825 deletions

View file

@ -68,7 +68,7 @@ binaryRex = re.compile(r'[\000-\006\177-\277]')
class Resource:
'''Every instance of this class represents some web resource accessible
through WebDAV.'''
through HTTP.'''
def __init__(self, url, username=None, password=None, measure=False):
self.username = username
@ -94,9 +94,7 @@ class Resource:
else: raise 'Wrong URL: %s' % str(url)
def __repr__(self):
port = ':' + str(self.port)
if self.port == 80: port = ''
return '<Dav resource at %s%s/%s>' % (self.url, port, self.uri)
return '<Dav resource at %s>' % self.url
def updateHeaders(self, headers):
# Add credentials if present
@ -203,12 +201,22 @@ class Resource:
if not uri: uri = self.uri
return self.sendRequest('GET', uri, headers=headers)
def post(self, data, uri=None, headers={}):
'''Perform a HTTP POST on the server.'''
def post(self, data=None, uri=None, headers={}, type='form'):
'''Perform a HTTP POST on the server. If p_type is:
- "form", p_data is a dict representing form data that will be
form-encoded;
- "soap", p_data is a XML request that will be wrapped in a SOAP
message.'''
if not uri: uri = self.uri
# Format the form data and prepare headers
body = DataEncoder(data).encode()
headers['Content-Type'] = 'application/x-www-form-urlencoded'
# Prepare the data to send
if type == 'form':
# Format the form data and prepare headers
body = DataEncoder(data).encode()
headers['Content-Type'] = 'application/x-www-form-urlencoded'
elif type =='soap':
body = data
headers['SOAPAction'] = self.url
headers['Content-Type'] = 'text/xml'
headers['Content-Length'] = str(len(body))
return self.sendRequest('POST', uri, headers=headers, body=body)
# ------------------------------------------------------------------------------

View file

@ -51,7 +51,10 @@ def cleanFolder(folder, exts=extsToClean, verbose=False):
def copyFolder(source, dest, cleanDest=False):
'''Copies the content of folder p_source to folder p_dest. p_dest is
created, with intermediary subfolders if required. If p_cleanDest is
True, it removes completely p_dest if it existed.'''
True, it removes completely p_dest if it existed. Else, content of
p_source will be added to possibly existing content in p_dest, excepted
if file names corresponds. In this case, file in p_source will overwrite
file in p_dest.'''
dest = os.path.abspath(dest)
# Delete the dest folder if required
if os.path.exists(dest) and cleanDest: