learn from admin app i want to create a function in controller to pack
web2py app, it downloaded *.w2p but the models, controllers and views is
empty (no files in there)
e.g.
controllers/default.py
import StringIO
stream = StringIO.StringIO()
from gluon.admin import *
def safe_open(a, b):
if ('w' in b or 'a' in b):
class tmp:
def write(self, data):
pass
def close(self):
pass
return tmp()
return open(a, b)
def safe_read(a, b='r'):
safe_file = safe_open(a, b)
try:
return safe_file.read()
finally:
safe_file.close()
def pack():
app = request.application # admin use get_app() function
try:
if len(request.args) == 1:
#fname = 'web2py.app.%s.w2p' % app
fname = 'web2py.app.%s.compiled.w2p' % app
filename = app_pack(app, request, raise_ex = True)
else:
#fname = 'web2py.app.%s.compiled.w2p' % app
fname = 'web2py.app.%s.w2p' % app
filename = app_pack_compiled(app, request, raise_ex = True)
except Exception, e:
filename = None
if filename:
response.headers['Content-Type'] = 'application/w2p'
disposition = 'attachment; filename=%s' % fname
response.headers['Content-Disposition'] = disposition
return safe_read(filename, 'rb')
else:
session.flash = T('internal error: %s', e)
redirect(URL('default', 'index') )
any idea or thought to achieve it using web2py way?
thanks and best regards,
stifan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.