GithubHelp home page GithubHelp logo

sae-python-dev-guide's People

Contributors

chanfung032 avatar fy0 avatar monkeyxite avatar nkchenz avatar saikidontohu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sae-python-dev-guide's Issues

{文档}处理依赖关系

saecloud install 可否指定requirements.txt自动安装所有依赖库?或者根据config.yaml指定的libraries自动安装?

BUG storage 异常捕获

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:

完善本地KVDB

AttributeError: 'Client' object has no attribute 'getkeys_by_prefix'

短信服务响应,返回格式问题

'91\r\n{
"status":"\u77ed\u4fe1\u63d0\u4ea4\u6210\u529f",
"sms":
{"mobile":"18911978203",
"msg":"hello.....",
"encoding":"GB2312"
}

每次前面多了一个2位的随机数 ,上面的例子就多了‘91’

在Mac os下面运行dev_server.py报AttributeError

$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上下载的代码。

为啥setup.py里面没有webpy的示例??

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'
    ],

问题 , KVClient到底有没有time参数, time参数生效吗? //文档不统一

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)?

can't use sae python on mac os x lion 10.7.3

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

Flask在Blueprint中指定template_folder无效

使用Flask框架时,在Blueprint中指定template_folder后,在本地测试时能够正确引用到Blueprint指定的template_folder,但是在SAE在线环境中总是引用到了根路径的template_folder,Blueprint的设置在在线环境中不生效.

求支持wsgi的方式自定義Last-Modified等,AppConfig的expired不夠靈活

求支持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语义,以节约流量消耗,并且加快加载速度。

申请预装lxml模块

由于用到的一些包,其依赖于lxml模块,希望可以预装下,谢谢!

本地环境(dev_server.py)使用 tornado worker 报错

出错信息如下 , 我因为用到了不少异步的代码 , 所以不能改为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模式 , 方便开发调试

非常感谢 ^_^

请帮忙在 tornado 的 httpserver 加上 xheaders=True 参数

即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。

求预装lxml,pyquery等模块

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

好像引不到

bundle_local.py -r requirements.txt的问题

1、virtualenv文档中有些问题
http://readthedocs.org/docs/sae-python/en/latest/runtime.html#virtualenv

(memorystone)jaime@westeros:/source/app/memorystone/1$ pip freeze > requirements.txt
(memorystone)jaime@westeros:
/source/app/memorystone/1$ pip freeze > requirements.sae.txt
(memorystone)jaime@westeros:/source/app/memorystone/1$ vi requirements.sae.txt
(memorystone)jaime@westeros:
/source/app/memorystone/1$ diff requirements.txt requirements.sae.txt

第一个pip freeze和第二个完全一样,怎么能diff出different?

2、执行bundle_local.py -r requirements.txt时,提示我,所有刚才在virtualenv环境下安装的packeage,全部都没安装

{文档}Django

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:

  • name: "django"
    version: "1.4"

handlers:

  • url: /static
    static_dir: static

应该是1.4的啊

kv.get_by_prefix 不正常。

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》

我在迁移一些以前的代码到sae , 还有一些我用到的很常用的python的库(包含c文件) , 不知道能否do me a favor ^_^

我在迁移一些以前的代码到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

flask-themes 模板路径不一致问题

在本地调试时,皮肤文件所在路径为项目的themes/default目录下,非皮肤html文件在templates下。到了sae环境,变成了_themes,并且非皮肤html文件也要求在_themes/default/,比较混换。

具体代码见https://svn.sinaapp.com/flaskthemes/ (应该可以看到吧),版本1,专门做测试用。

申请预装pygame模块

我开发的app需要用到的pytagcloud需要用到pygame。我在官网上找不到纯python的fallback版本,所以只好来申请预装。谢谢啦~~

现在python headers 拿不到'X-Proto'

导致这段代码失效

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.