sinacloud / sae-python-dev-guide Goto Github PK
View Code? Open in Web Editor NEWSAE Python开发者手册
Home Page: http://sae.sina.com.cn/doc/python
SAE Python开发者手册
Home Page: http://sae.sina.com.cn/doc/python
谢谢
申请预装zope
可以预装Whoosh么?
localhost:/webapps/tmp/saepythondevguide/examples/blackfire/1$dev_server.py
Traceback (most recent call last):
File "/usr/local/bin/dev_server.py", line 4, in
import pkg_resources
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 2603, in
working_set.require(requires)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: sae-python-dev==1.0testing
如题
导致这段代码失效
class HttpsView(View):
def prepare(self):
super(HttpsView, self).prepare()
if self._finished:
return
request = self.request
# if request.protocol != 'https' and request.headers.get('X-Proto', '') != 'SSL':
# self.send_error(
# 403, message='Forbidden: SSL is required to view this resource protocol %s %s %s'%(
# request.protocol,
# request.headers,
# request.uri
# )
# )
403: Forbidden: SSL is required to view this resource protocol http
global name 'e' is not defined in sae_python_dev-1.0testing-py2.7.egg/sae/storage.py
storage.py
167 def stat(self, domain, key_name):
168 """Get an object's attributes
169
170 Args:
171 domain: The domain from which the obect will be getted.
172 key_name: The name of the object
173 """
174 fullpath = os.path.join(_stor_path, domain, key_name)
175
176 try:
177 st = os.stat(fullpath)
178 except:
179 if e.errno == errno.ENOENT:
180 raise ObjectNotExistsError()
181 else:
182 raise InternalError()
183
184 d = {'name': key_name, 'length': st[6], 'datetime': st[8]}
185
186 return d
fix:
M 178 except Error, e:
我在迁移一些以前的代码到sae , 还有一些我用到的很常用的python的库(包含c文件) , 不知道能否do me a favor ^_^
msgpack
一个跨语言的序列化库 , 非常快
https://pypi.python.org/pypi/msgpack-python/
中文介绍
http://wolfchina.blogbus.com/tag/msgpack/
pysha3
python 3.4的sha3 hash库的独立代码
https://pypi.python.org/pypi/pysha3/0.2.1
中文介绍
http://baike.baidu.com/view/9418874.htm
markupsafe
gae的预装模块, 预装的好处是可以启用他的_speedups.c , 提升性能(因为这个函数在不少模版中调用非常频繁, 影响还是比较大)
https://pypi.python.org/pypi/MarkupSafe
ujson
https://pypi.python.org/pypi/ujson/
号称是python中最好的json解析模块
(pypi页面最后是他的性能对比)
中文介绍
http://blog.csdn.net/lanphaday/article/details/6567408
我查了下,应该是通过Python Docutils把rst的转为html的,但是发现转的过程中有错误:
System Message: ERROR/3 (service.rst, line 671)
Unknown directive type "py:class".
Docutils是0.10
class T(tornado.web.RequestHandler):
def get(self):
kv = sae.kvdb.KVClient()
c = kv.get_by_prefix('t')
self.write(str(c))
返回结果是 :
《generator object _get_by_prefix at 0x14dc500》
'91\r\n{
"status":"\u77ed\u4fe1\u63d0\u4ea4\u6210\u529f",
"sms":
{"mobile":"18911978203",
"msg":"hello.....",
"encoding":"GB2312"
}
每次前面多了一个2位的随机数 ,上面的例子就多了‘91’
saecloud install 可否指定requirements.txt自动安装所有依赖库?或者根据config.yaml指定的libraries自动安装?
http://www.mindrot.org/projects/py-bcrypt/
在处理用户注册密码是要用到这个模块。
http://sae-python.readthedocs.org/en/latest/quickstart.html 这个页面里面,只是touch和修改了index.wsgi,可是教程并没有说要svn add 他们,就直接列出svn commit这条代码了。
建议加上svn add 的相关语句。谢谢。
致 Sina的各位大侠们:
希望可以预装matplotlib这个module,谢谢各位啦。
https://pypi.python.org/pypi/bitarray
用来把IP地址转为binary字符串, 保存到mysql
1、virtualenv文档中有些问题
http://readthedocs.org/docs/sae-python/en/latest/runtime.html#virtualenv
(memorystone)jaime@westeros:/source/app/memorystone/1$ pip freeze > requirements.txt/source/app/memorystone/1$ pip freeze > requirements.sae.txt
(memorystone)jaime@westeros:
(memorystone)jaime@westeros:/source/app/memorystone/1$ vi requirements.sae.txt/source/app/memorystone/1$ diff requirements.txt requirements.sae.txt
(memorystone)jaime@westeros:
第一个pip freeze和第二个完全一样,怎么能diff出different?
2、执行bundle_local.py -r requirements.txt时,提示我,所有刚才在virtualenv环境下安装的packeage,全部都没安装
webpy真是一个全python风格的框架。既然遗漏了??不可原谅的错误!对知识的忽视。:)
我要在setup.py中添加webpy,应该如何做呢?
install_requires = [
'Werkzeug',
#'Django==1.2.7',
#'bottle==0.9.6',
'tornado==2.1.1',
#'Flask==0.7.2',
#'flask-sqlalchemy',
#'Uliweb',
#'jinja2',
'MySQL-python'
],
我开发的app需要用到的pytagcloud需要用到pygame。我在官网上找不到纯python的fallback版本,所以只好来申请预装。谢谢啦~~
谢谢
AttributeError: 'Client' object has no attribute 'getkeys_by_prefix'
即tornado支持通过 x-real-ip 或 x-forwarded-for来获取IP,但前提是需要在你的HTTPServer实例中增加xheaders=True参数,如:http_server = tornado.httpserver.HTTPServer(Application(), xheaders=True),否则通过self.request.remote_ip取到的IP只能是127.0.0.1。
1.1.0中应该弃用了:sae.storage.Client()。
我想知道的是,现在SAE中的python环境中。我们要调用storage到底,是用1.0.3的api呢还是1.1.0的呢? 并且官方的关于storage+python部分的文档也没变啊? 纳闷中.......
出错信息如下 , 我因为用到了不少异步的代码 , 所以不能改为WSGI的模式
TypeError
TypeError: call() takes exactly 2 arguments (3 given)
Traceback (most recent call last)
File "/usr/lib64/python2.7/site-packages/Werkzeug-0.8.3-py2.7.egg/werkzeug/debug/init.py", line 88, in debug_application
app_iter = self.app(environ, start_response)
TypeError: call() takes exactly 2 arguments (3 given)
而每次上传代码调试又很麻烦
所以希望本地开发服务器能够支持tornado模式 , 方便开发调试
非常感谢 ^_^
lxml解压有9M大,里面还有c写的模块,自己放在app根目录下报错。
File "\sinaapp\readstory\1\lxml\cssselect.py", line 8, in
from lxml import etree
ImportError: cannot import name etree
引不到etree,我去lxml目录下看了下,只有
lxml.etree.c
lxml.etree.h
好像引不到
用wsgi的话是可以直接用dev_server.py的,但是在使用index.yaml(sae-python文档上面是这样命名的),但是执行dev_server.py提示没有index.wsgi,我把index.yaml重命名为index.wsgi但是还是报错.
希望可以预装pycrypto,加密中常用,谢谢
sae 北京电信通线路抽风
http://42sso.sinaapp.com
如图
http://huaban.com/pins/70313021/zoom/
IP是:[118.207.147.130] 来自:北京市 电信通
开翻墙后可以正常访问
另外, 请问有运维的电话或邮箱吗?
出现这种紧急线路故障应该联系谁?
would you please add PIL support?
SAE Python 求protobuf 模块
2.1.1
->
2.4.1
有很多改动 , 比如cookie的设置, 现在2.1.1的版本是有些许问题的
求支持wsgi的方式自定義Last-Modified等,AppConfig的expired不夠靈活
我的flask程序在自己的机器上跑的时候是可以自定义Last-Modified的时间戳的。放到SAE上发现被改掉了……永远是200没有304状态了……
看了一下这里用config.yaml设置页面过期时间的说明:
http://sae.sina.com.cn/?m=devcenter&catId=193#anchor_7983aef9f5ded83f84c21b04a4812889
但是这种方法很不灵活,只能根据url匹配,然后设置一段固定的时间。
实际上我的应用的逻辑是知道内容是否过期了的,不是一段固定的过期时间……
比如我能計算出最後一次數據庫操作是在何時,計算出上一次的是否過期了……
我需要Last-Modified和If-Modified-Since语义,以节约流量消耗,并且加快加载速度。
申请预装pyramid
由于用到的一些包,其依赖于lxml模块,希望可以预装下,谢谢!
因为常常需要本地读取excel表,希望厂商能尽快尽快提供。
ImportError at /
cannot import name patterns
Request Method: GET
Request URL: http://benna.sinaapp.com/
Django Version: 1.2.7
Exception Type: ImportError
Exception Value:
cannot import name patterns
Exception Location: /data1/www/htdocs/99/benna/1/mysite/urls.py in , line 3
Python Executable: /usr/local/bin/python
Python Version: 2.7.3
Python Path: ['/data1/www/htdocs/99/benna/1', '/usr/local/sae/python/lib/python27.zip', '/usr/local/sae/python/lib/python2.7', '/usr/local/sae/python/lib/python2.7/plat-linux2', '/usr/local/sae/python/lib/python2.7/lib-tk', '/usr/local/sae/python/lib/python2.7/lib-old', '/usr/local/sae/python/lib/python2.7/lib-dynload', '/usr/local/sae/python/lib/python2.7/site-packages']
Server time: Thu, 13 Dec 2012 23:09:20 +0800
按照教程,出现这个无法载入的错误
我的config文件
name: benna
version: 1
libraries:
handlers:
应该是1.4的啊
这个代码写在哪个文件下面? 是config.yaml????
建议增加pyramid web framework
$dev_server.py
Traceback (most recent call last):
File "/usr/local/bin/dev_server.py", line 5, in
pkg_resources.run_script('sae-python-dev==1.0.3', 'dev_server.py')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 489, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1214, in run_script
exec script_code in namespace, namespace
File "/Library/Python/2.7/site-packages/sae_python_dev-1.0.3-py2.7.egg/EGG-INFO/scripts/dev_server.py", line 190, in
File "/Library/Python/2.7/site-packages/sae_python_dev-1.0.3-py2.7.egg/EGG-INFO/scripts/dev_server.py", line 157, in main
File "/Library/Python/2.7/site-packages/sae_python_dev-1.0.3-py2.7.egg/EGG-INFO/scripts/dev_server.py", line 34, in setup_sae_environ
AttributeError: Values instance has no attribute 'name'
最新从github上下载的代码。
最近用不到,所以想卸载掉,发现没有卸载?
在本地调试时,皮肤文件所在路径为项目的themes/default目录下,非皮肤html文件在templates下。到了sae环境,变成了_themes,并且非皮肤html文件也要求在_themes/default/,比较混换。
具体代码见https://svn.sinaapp.com/flaskthemes/ (应该可以看到吧),版本1,专门做测试用。
http://sae.sina.com.cn/?m=devcenter&catId=199
这里文档
set(key, val, time=0, min_compress_len=0)
设置key的值为val,成功则返回True
time 该key的超时时间,请参阅memcached协议Storage commands: http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt
min_compress_len 启用zlib.compress压缩val的最小长度,如果val的长度大于此值 则启用压缩,0表示不压缩。
这里文档
http://python.sinaapp.com/doc/service.html
class sae.kvdb.KVClient(debug=0)¶
KVDB客户端基于python-memcached,大多数method使用方法相同。 如果不能成功创建KVClient,则抛出 sae.kvdb.Error 异常。
debug 是否输出详细调试、错误信息到日志,默认关闭
set(key, val, min_compress_len=0)
设置key的值为val,成功则返回True
min_compress_len 启用zlib.compress压缩val的最小长度,如果val的长度大于此值 则启用压缩,0表示不压缩。
文档不统一
问题 , KVClient到底有没有time参数, time参数生效吗(过期后会自动删除key)?
使用Flask框架时,在Blueprint中指定template_folder后,在本地测试时能够正确引用到Blueprint指定的template_folder,但是在SAE在线环境中总是引用到了根路径的template_folder,Blueprint的设置在在线环境中不生效.
Can you prepare a Django 1.5 package?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.