bzr revid: olt@tinyerp.com-20081215151313-0eibaa7qngqs6fz3
This commit is contained in:
Olivier Laurent 2008-12-15 16:13:13 +01:00
commit 3f5796a6f8
3 changed files with 29 additions and 24 deletions

View File

@ -129,7 +129,7 @@ upload_info_form = '''<?xml version="1.0"?>
align="0.0" colspan="4"/>
<field name="login"/>
<newline/>
<field name="password"/>
<field name="password" password="True"/>
<newline/>
<field name="email"/>
</form>'''
@ -227,18 +227,18 @@ def _upload(self, cr, uid, datas, context):
download = 'http://www.openerp.com/download/modules/'+res['module_filename']
result = post_multipart('www.openerp.com', '/mtree_upload.php',
[
('login',datas['form']['login']),
('password',datas['form']['password']),
('module_name',mod.name)
('login', datas['form']['login']),
('password', datas['form']['password']),
('module_name', str(mod.name))
], [
('module', res['module_filename'], res['module_file'])
])
if result[0] == "1":
if result and result[0] == "1":
raise wizard.except_wizard(_('Error'), _('Login failed!'))
elif result[0] == "2":
elif result and result[0] == "2":
raise wizard.except_wizard(_('Error'),
_('This version of the module is already exist on the server'))
elif result[0] != "0":
elif result and result[0] != "0":
raise wizard.except_wizard(_('Error'), _('Failed to upload the file'))
updata = {

View File

@ -56,21 +56,22 @@ def createzip(cr, uid, moduleid, context, b64enc=True, src=True):
_('Can not export module that is not installed!'))
ad = tools.config['addons_path']
if os.path.isdir(os.path.join(ad, module.name)):
name = str(module.name)
if os.path.isdir(os.path.join(ad, name)):
archname = StringIO.StringIO('wb')
archive = PyZipFile(archname, "w", ZIP_DEFLATED)
archive.writepy(os.path.join(ad, module.name))
_zippy(archive, ad, module.name, src=src)
archive.writepy(os.path.join(ad, name))
_zippy(archive, ad, name, src=src)
archive.close()
val =archname.getvalue()
archname.close()
elif os.path.isfile(os.path.join(ad, module.name + '.zip')):
val = file(os.path.join(ad, module.name + '.zip'), 'rb').read()
elif os.path.isfile(os.path.join(ad, name + '.zip')):
val = file(os.path.join(ad, name + '.zip'), 'rb').read()
else:
raise wizard.except_wizard(_('Error'), _('Could not find the module to export!'))
if b64enc:
val =base64.encodestring(val)
return {'module_file':val, 'module_filename': module.name + '-' + \
return {'module_file':val, 'module_filename': name + '-' + \
(module.installed_version or '0') + '.zip'}

View File

@ -26,14 +26,16 @@ class file_wrapper(StringIO.StringIO):
def close(self, *args, **kwargs):
db,pool = pooler.get_db_and_pool(self.dbname)
cr = db.cursor()
uid =self.uid
val = self.getvalue()
val2 = {
'datas': base64.encodestring(val),
'file_size': len(val),
}
pool.get('ir.attachment').write(cr, uid, [self.ressource_id], val2)
cr.commit()
try:
val = self.getvalue()
val2 = {
'datas': base64.encodestring(val),
'file_size': len(val),
}
pool.get('ir.attachment').write(cr, self.uid, [self.ressource_id], val2)
finally:
cr.commit()
cr.close()
StringIO.StringIO.close(self, *args, **kwargs)
class content_wrapper(StringIO.StringIO):
@ -47,10 +49,12 @@ class content_wrapper(StringIO.StringIO):
def close(self, *args, **kwargs):
db,pool = pooler.get_db_and_pool(self.dbname)
cr = db.cursor()
getattr(self.pool.get('document.directory.content'), 'process_write_'+self.node.content.extension[1:])(cr, self.uid, self.node, self.getvalue())
try:
getattr(self.pool.get('document.directory.content'), 'process_write_'+self.node.content.extension[1:])(cr, self.uid, self.node, self.getvalue())
finally:
cr.commit()
cr.close()
StringIO.StringIO.close(self, *args, **kwargs)
cr.commit()
cr.close()
class abstracted_fs: