base, base_module_publish, kernel: improve module publication

- allow including source
- fix GPL-2
- module are active=False by default
- add license in module object

bzr revid: ced-841334c96cd7b358eb44970adbde75b2bc7b971e
This commit is contained in:
ced
2007-07-30 13:34:59 +00:00
parent de25bb420a
commit 5d2d3a07f2
4 changed files with 103 additions and 76 deletions
@@ -10,7 +10,7 @@
<wizard
string="Export module"
model="ir.module.module"
name="base.module.export"
name="base_module_publish.module_export"
id="wizard_base_module_export"/>
</data>
@@ -41,14 +41,15 @@ intro_form = '''<?xml version="1.0"?>
</form>'''
intro_fields = {
'text': {'string':'Introduction', 'type':'text', 'readonly':True, 'default': lambda *args: """
'text': {'string':'Introduction', 'type':'text', 'readonly':True,
'default': lambda *args: """
This system will automatically publish the selected module to the
Tiny ERP official website. You can use it to quickly publish a new
module or update an existing one (new version).
Make sure you read the publication manual and modules guidelines
before continuing:
http://tinyerp.com
http://www.tinyerp.com
Thank you for contributing !
"""},
@@ -67,59 +68,69 @@ check_form = '''<?xml version="1.0"?>
<form string="Module publication">
<separator string="Verify your module information" colspan="4"/>
<notebook>
<page string="General">
<field name="name"/>
<field name="version"/>
<field name="author"/>
<field name="website" widget="url"/>
<field name="shortdesc"/>
<field name="operation"/>
<field name="category"/>
<field name="licence"/>
<field name="url_download"/>
<label colspan="2" string="(Keep empty for an auto upload of the module)"/>
<field name="docurl"/> <label colspan="2" string="(empty to keep existing value)"/>
<field name="demourl"/> <label colspan="2" string="(empty to keep existing value)"/>
<field name="image"/> <label colspan="2" string="(support only .png files)"/>
</page><page string="Description">
<field name="description" colspan="4" nolabel="1"/>
</page>
<page string="General">
<field name="name"/>
<field name="version"/>
<field name="author"/>
<field name="website" widget="url"/>
<field name="shortdesc"/>
<field name="operation"/>
<field name="category" colspan="4"/>
<newline/>
<field name="license"/>
<field name="include_src"/>
<newline/>
<field name="url_download" colspan="4" widget="url"/>
<field name="docurl" colspan="4" widget="url"/>
<field name="demourl" colspan="4" widget="url"/>
<field name="image"/>
</page>
<page string="Description">
<field name="description" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>'''
check_fields = {
'name': {'string':'Name', 'type':'char', 'size':64, 'readonly':True},
'shortdesc': {'string':'Small description', 'type':'char', 'size':200, 'readonly':True},
'shortdesc': {'string':'Small description', 'type':'char', 'size':200,
'readonly':True},
'author': {'string':'Author', 'type':'char', 'size':128, 'readonly':True},
'website': {'string':'Website', 'type':'char', 'size':200, 'readonly':True},
'url': {'string':'Download URL', 'type':'char', 'size':200, 'readonly':True},
'image': {'string':'Image file', 'type':'image'},
'image': {'string':'Image file', 'type':'image', 'help': 'support only .png files'},
'description': {'string':'Description', 'type':'text', 'readonly':True},
'version': {'string':'Version', 'type':'char', 'readonly':True},
'demourl': {'string':'Demo URL', 'type':'char', 'size':128},
'docurl': {'string':'Documentation URL', 'type':'char', 'size':128},
'demourl': {'string':'Demo URL', 'type':'char', 'size':128,
'help': 'empty to keep existing value'},
'docurl': {'string':'Documentation URL', 'type':'char', 'size':128,
'help': 'Empty to keep existing value'},
'category': {'string':'Category', 'type':'selection', 'size':64, 'required':True,
'selection': _get_selection
},
'licence': {
'selection': _get_selection},
'license': {
'string':'Licence', 'type':'selection', 'size':64, 'required':True,
'selection': [('GPL', 'GPL'), ('Other proprietary','Other proprietary')],
'default': lambda *args: 'GPL'
'selection': [('GPL-2', 'GPL-2'), ('Other proprietary','Other proprietary')],
'default': lambda *args: 'GPL-2'
},
'include_src': {'string': 'Include source', 'type': 'boolean',
'default': lambda *a: True},
'operation': {
'string':'Operation',
'type':'selection',
'readonly':True,
'selection':[('0','Creation'),('1','Modification')],
},
'url_download': {'string':'Download URL', 'type':'char', 'size':128},
'url_download': {'string':'Download URL', 'type':'char', 'size':128,
'help': 'Keep empty for an auto upload of the module'},
}
upload_info_form = '''<?xml version="1.0"?>
<form string="Module publication">
<separator string="User information" colspan="4"/>
<label align="0.0" string="Please provide here your login on the Tiny ERP website." colspan="4"/>
<label align="0.0" string="If you don't have an access, you can create one http://tinyerp.com." colspan="4"/>
<label string="Please provide here your login on the Tiny ERP website."
align="0.0" colspan="4"/>
<label string="If you don't have an access, you can create one http://www.tinyerp.com/"
align="0.0" colspan="4"/>
<field name="login"/>
<field name="password"/>
<newline/>
@@ -144,22 +155,25 @@ def _get_edit(self, cr, uid, datas, *args):
upload_info_fields = {
'login': {'string':'Login', 'type':'char', 'size':32, 'required':True},
'email': {'string':'Email', 'type':'char', 'size':100, 'required':True},
'password': {'string':'Password', 'type':'char', 'size':32, 'required':True, 'invisible':True},
'password': {'string':'Password', 'type':'char', 'size':32, 'required':True,
'invisible':True},
}
end_form = '''<?xml version="1.0"?>
<form string="Module publication">
<notebook>
<page string="Information">
<field name="text_end" colspan="4" nolabel="1"/>
</page><page string="Result">
<field name="result" colspan="4" nolabel="1"/>
</page>
<page string="Information">
<field name="text_end" colspan="4" nolabel="1"/>
</page>
<page string="Result">
<field name="result" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>'''
end_fields = {
'text_end': {'string':'Summary', 'type':'text', 'readonly':True, 'default': lambda *args: """
'text_end': {'string':'Summary', 'type':'text', 'readonly':True,
'default': lambda *args: """
Thank you for contributing !
Your module has been successfully uploaded to the official website.
@@ -183,7 +197,8 @@ def post_multipart(host, selector, fields, files):
L.append(value)
for (key,fname,value) in files:
L.append('--' + BOUNDARY)
L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, fname))
L.append('Content-Disposition: form-data; name="%s"; filename="%s"'
% (key, fname))
L.append('Content-Type: application/octet-stream')
L.append('')
L.append(value)
@@ -210,11 +225,10 @@ def _upload(self, cr, uid, datas, context):
mod = pool.get('ir.module.module').browse(cr, uid, datas['id'])
download = datas['form']['url_download'] or ''
if not download:
res = module_zip.createzip(cr, uid, datas['id'], context, b64enc=False)
download = 'http://tinyerp.com/download/modules/'+res['module_filename']
result = post_multipart('www.tinyerp.com', '/mtree_upload.php',
res = module_zip.createzip(cr, uid, datas['id'], context,
b64enc=False, src=datas['form']['include_src'])
download = 'http://www.tinyerp.com/download/modules/'+res['module_filename']
result = post_multipart('www.tinyerp.com', '/mtree_upload.php',
[
('login',datas['form']['login']),
('password',datas['form']['password']),
@@ -223,8 +237,6 @@ def _upload(self, cr, uid, datas, context):
('module', res['module_filename'], res['module_file'])
])
# module_file & module_filename
updata = {
'link_name': mod.shortdesc or '',
'new_cat_id': datas['form']['category'],
@@ -236,7 +248,7 @@ def _upload(self, cr, uid, datas, context):
'cust_2': datas['form']['demourl'] or '', # Put here the download url
'cust_3': mod.url or '/',
'cust_4': datas['form']['docurl'] or '',
'cust_5': datas['form']['licence'] or '',
'cust_5': datas['form']['license'] or '',
'cust_6': mod.latest_version or '',
'cust_7': mod.name,
'option': 'com_mtree',
@@ -256,7 +268,8 @@ def _upload(self, cr, uid, datas, context):
files = []
if datas['form']['image']:
files.append(('link_image', 'link_image.png', base64.decodestring(datas['form']['image'])))
files.append(('link_image', 'link_image.png',
base64.decodestring(datas['form']['image'])))
result = post_multipart('www.tinyerp.com', '/index.php', updata.items(), files)
return {'result': result}
@@ -276,11 +289,11 @@ def module_check(self, cr, uid, data, context):
class base_module_publish(wizard.interface):
states = {
'init': {
'actions': [],
'actions': [],
'result': {
'type':'form',
'type':'form',
'arch':intro_form,
'fields':intro_fields,
'fields':intro_fields,
'state':[
('end','Cancel'),
('step1','Continue')
@@ -288,11 +301,11 @@ class base_module_publish(wizard.interface):
}
},
'step1': {
'actions': [module_check,_get_edit],
'actions': [module_check, _get_edit],
'result': {
'type':'form',
'type':'form',
'arch':check_form,
'fields':check_fields,
'fields':check_fields,
'state':[
('end','Cancel'),
('init', 'Previous'),
@@ -303,9 +316,9 @@ class base_module_publish(wizard.interface):
'step2': {
'actions': [],
'result': {
'type':'form',
'type':'form',
'arch':upload_info_form,
'fields':upload_info_fields,
'fields':upload_info_fields,
'state':[
('end','Cancel'),
('step1', 'Previous'),
@@ -316,9 +329,9 @@ class base_module_publish(wizard.interface):
'publish': {
'actions': [_upload], # Action to develop: upload method
'result': {
'type':'form',
'type':'form',
'arch':end_form,
'fields':end_fields,
'fields':end_fields,
'state':[
('end','Close')
]
@@ -8,20 +8,23 @@ from zipfile import PyZipFile, ZIP_DEFLATED
import StringIO
import base64
def _zippy(archive, fromurl, path):
def _zippy(archive, fromurl, path, src=True):
url = os.path.join(fromurl, path)
if os.path.isdir(url):
if path.split('/')[-1]=='.svn':
return False
for fname in os.listdir(url):
_zippy(archive, fromurl, path and os.path.join(path, fname) or fname)
_zippy(archive, fromurl, path and os.path.join(path, fname) or fname, src=src)
else:
if (path.split('.')[-1] not in ['py','pyo','pyc']) or (os.path.basename(path)=='__terp__.py'):
print 'Adding', os.path.join(fromurl, path), 'as', path
if src:
exclude = ['pyo', 'pyc']
else:
exclude = ['py','pyo','pyc']
if (path.split('.')[-1] not in exclude) or (os.path.basename(path)=='__terp__.py'):
archive.write(os.path.join(fromurl, path), path)
return True
def createzip(cr, uid, moduleid, context, b64enc=True):
def createzip(cr, uid, moduleid, context, b64enc=True, src=True):
module_obj=pooler.get_pool(cr.dbname).get('ir.module.module')
module_name = module_obj.browse(cr, uid, moduleid).name
module_version = module_obj.browse(cr, uid, moduleid).latest_version
@@ -31,7 +34,7 @@ def createzip(cr, uid, moduleid, context, b64enc=True):
archname = StringIO.StringIO('wb')
archive = PyZipFile(archname, "w", ZIP_DEFLATED)
archive.writepy(os.path.join(ad,module_name))
_zippy(archive, ad, module_name)
_zippy(archive, ad, module_name, src=src)
archive.close()
val =archname.getvalue()
archname.close()
@@ -31,14 +31,24 @@ import pooler
import module_zip
finish_form ='''<?xml version="1.0"?>
init_form = '''<?xml version="1.0"?>
<form string="Export module">
<separator string="Export module" colspan="4"/>
<field name="include_src"/>
</form>'''
init_fields = {
'include_src': {'string': 'Include sources', 'type': 'boolean',
'default': lambda *a: True,},
}
finish_form = '''<?xml version="1.0"?>
<form string="Finish">
<separator string="Module successfully exported !" colspan="4"/>
<field name="module_file"/>
<newline/>
<field name="module_filename"/>
</form>
'''
</form>'''
finish_fields = {
'module_file': {'string': 'Module .zip file', 'type':'binary', 'readonly':True},
@@ -47,17 +57,18 @@ finish_fields = {
class move_module_wizard(wizard.interface):
def createzip(self, cr, uid, data, context):
return module_zip.createzip(cr, uid, data['id'], context)
return module_zip.createzip(cr, uid, data['id'], context, src=data['form']['include_src'])
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': init_form,
'fields': init_fields, 'state': [('end', 'Cancel'), ('zip', 'Ok')]},
},
'zip': {
'actions': [createzip],
'result': {
'type':'form',
'arch':finish_form,
'fields':finish_fields,
'state':[('end','Close')]
}
'result': {'type': 'form', 'arch': finish_form,
'fields': finish_fields, 'state': [('end', 'Close')]},
}
}
move_module_wizard('base.module.export')
move_module_wizard('base_module_publish.module_export')