对iterator object的支持

4 views
Skip to first unread message

Chunlin Zhang

unread,
Nov 3, 2015, 2:01:14 AM11/3/15
to uli...@googlegroups.com
https://github.com/SpiderOak/ZipStream 这里有个 web.py 里的例子,但在uliweb里不能用,因为对于zipstream.ZipStream 这样的object不支持,我的理解是这种object因为有__iter__所以是可以当成iterator来用,现在应该是转成字符串了.

limodou

unread,
Nov 6, 2015, 9:19:19 AM11/6/15
to uliweb
我修改了一下uliweb,目前我试了应该是可以的。示例如下:

@expose('/zip')
def zip():
    from zipstream import ZipStream
    path = './apps'
    zip_filename = 'files.zip'
    response.headers['Content-type'] = 'application/zip'
    response.headers['Content-Disposition'] = 'attachment; filename="%s"' % (
        zip_filename,)
    return ZipStream(path)

On Tue, Nov 3, 2015 at 3:01 PM, Chunlin Zhang <zhangc...@gmail.com> wrote:
https://github.com/SpiderOak/ZipStream 这里有个 web.py 里的例子,但在uliweb里不能用,因为对于zipstream.ZipStream 这样的object不支持,我的理解是这种object因为有__iter__所以是可以当成iterator来用,现在应该是转成字符串了.

--
-- ----
Project : https://github.com/limodou/uliweb
doc : http://limodou.github.com/uliweb-doc
---
You received this message because you are subscribed to the Google Groups "Uliweb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uliweb+un...@googlegroups.com.
To post to this group, send email to uli...@googlegroups.com.
Visit this group at http://groups.google.com/group/uliweb.
To view this discussion on the web visit https://groups.google.com/d/msgid/uliweb/CAG2rzAm41a-A%2BKWiOBVxa8SASmWx_BaUSFybgbrEnQ%3DD%3DJciJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
UliWeb <<simple web framework>>: https://github.com/limodou/uliweb
My Blog: http://my.oschina.net/limodou

Chunlin Zhang

unread,
Nov 7, 2015, 3:18:17 AM11/7/15
to uli...@googlegroups.com
验证过可以了,谢谢!

Chunlin Zhang

unread,
Nov 7, 2015, 3:19:51 AM11/7/15
to uli...@googlegroups.com
话说这个 zipstream 不错,可以用在批量打包文件下载上,同时并不在磁盘或者内存中生成zip文件而是直接流式返回

limodou

unread,
Nov 7, 2015, 4:22:15 AM11/7/15
to uliweb
Reply all
Reply to author
Forward
0 new messages