我有使用默认身份验证在TG 2.2.2中编写的应用程序.最后几天,我有登录和退出的问题.在safari中,创建了两个authtkt cookie,一个是"beta.domain.com",另一个是".beta.domain.com".在调用/ logout_handler之后,域"beta.domain.com"的cookie仅被删除,但野生域仍然存在.因此,在重新加载页面后,用户仍然登录.本地主机以及生产时出现问题.
有趣的是,相同的lib版本上的其他应用程序正常工作,以及其他浏览器,没有使用virtualenv.
我真的不知道问题在哪里,所以我会在请求时包含任何配置文件.在开始时,包含app_config.
app_cfg.py
# -*- coding: utf-8 -*-
from tg.configuration import AppConfig
import cafeteria
from cafeteria import model
from cafeteria.lib import app_globals, helpers
base_config = AppConfig()
base_config.renderers = []
base_config.prefer_toscawidgets2 = True
base_config.package = cafeteria
base_config.renderers.append('json')
base_config.renderers.append('mako')
base_config.default_renderer = 'mako'
base_config.use_sqlalchemy = True
base_config.model = cafeteria.model
base_config.DBSession = cafeteria.model.DBSession
# Configure the authentication backend
# YOU MUST CHANGE THIS VALUE IN PRODUCTION TO SECURE YOUR APP
base_config.sa_auth.cookie_secret = "SOMESECRET"
base_config.auth_backend = 'sqlalchemy'
from tg.configuration.auth import TGAuthMetadata …Run Code Online (Sandbox Code Playgroud) 在过去的几年里,我一直在使用Turbogears 1来进行小型网站的原型设计,并且它的使用时间有点长.有关在升级到Turbogears 2或切换到Django之间进行调用的任何建议吗?我很熟悉TG社区的熟悉程度,他们非常敏感,并且使用Django与更大的社区做了相当好的文档.我对内置的CMS功能和Google AppEngine支持非常感兴趣.
有什么建议?
谢谢
.M.
Django是我最喜欢的python web框架.我尝试过其他像pylons,web2py,nevow等.
但我从来没有热情地看过TurboGears.
现在TG2没有测试版,我可以尝试一下.我想知道与Django相比有哪些优点和缺点.
我正在使用python和git编写一个简单的Turbogears2项目,我只是为了好玩而构建的.在某个时刻我想将它部署到Heroku,所以我照常做pip freeze > requirements.txt,我得到这个错误:
Error when trying to get requirement for VCS system Command /usr/bin/git config
remote.origin.url failed with error code 1 in /home/ricardo/myprojs/hellotg22/example,
falling back to uneditable format
Run Code Online (Sandbox Code Playgroud)
并且requirements.txt它产生的,在所有依赖项之间列出,我发现这一行,whi看起来并不好看:
...
decorator==3.4.0
## !! Could not determine repository location
example==0.1dev
...
Run Code Online (Sandbox Code Playgroud)
有没有人知道问题是什么?
无论如何,我已设法获取requirements.txt文件,但我想知道该错误发生了什么.
我一直试图用Turbogears 2来制定管理文件上传的"最佳实践"方法,到目前为止还没有真正找到任何例子.我已经找到了实际上传文件的方法,但我不确定它有多可靠.
另外,获取上传文件名的好方法是什么?
file = request.POST['file']
permanent_file = open(os.path.join(asset_dirname,
file.filename.lstrip(os.sep)), 'w')
shutil.copyfileobj(file.file, permanent_file)
file.file.close()
this_file = self.request.params["file"].filename
permanent_file.close()
Run Code Online (Sandbox Code Playgroud)
所以假设我理解正确,这样的事情会避免核心'命名'问题吗?id = UUID.
file = request.POST['file']
permanent_file = open(os.path.join(asset_dirname,
id.lstrip(os.sep)), 'w')
shutil.copyfileobj(file.file, permanent_file)
file.file.close()
this_file = file.filename
permanent_file.close()
Run Code Online (Sandbox Code Playgroud) 任何人都成功连接到sqlalchemy内的mssql thru pyodbc?我现在正在使用turbogears2,并尝试连接到mssql,在mac os平台上工作.
获得以下错误:
sqlalchemy.exc.DBAPIError: (Error) ('00000', '[00000] [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (0) (SQLDriverConnectW)') None None
Run Code Online (Sandbox Code Playgroud) 我在uWSGI 2.0.3下运行Turbogears.除日志轮换外,一切正常.我从INI文件加载配置:
...
log-maxsize = 104857600
daemonize = /var/log/dumper.log
...
Run Code Online (Sandbox Code Playgroud)
uWSGI在运行时不会旋转日志.如果我停止/启动应用程序,则应用旋转.知道它为什么不旋转文件?
我正在考虑是否应该将Turbogears或Pylons用于我的项目.我知道Turbogears2是基于Pylons的.Turbogears提供的Pylon没有什么?谢谢.
使用turbogears 2.1和sqlalchemy 0.7,来自控制台的查询被注销到stdout.但是我需要降级到0.6并且不再出现.日志记录的文档似乎是相同的,我在changelog中找不到任何内容.如何登录sqlalchemy 0.6?
编辑将DBSession.bind.echo被设置为False.如果我把它设置为True它的工作原理.知道如何正确设置它(我修改了model/__init__.py设置engine.echo = True).
我是从java世界(apache wicket)来的,需要在我的项目中使用python.
我听说过Turbogear2,金字塔(Pylons)或Django,并阅读了一些关于它们的内容.我的第一选择是建立在Pylons之上的TurboGears2,已经打包的工具,但也许有人作为一些建议.
我不需要创建很多内容,如wiki或博客,但代表并访问我的数据库中的某些对象,然后构建一个javascript接口来处理这些数据.
我需要的Web框架对我来说:
良好的文档和/或良好的支持
线程/多进程支持(有很多计算.其中一些占用大量内存,另一些占用处理时间.所以我希望能够完成应用程序.但我认为它更多的是使用python库 和这个问题无关?)
谢谢
我正在使用Alembic 0.8.9,SQLAlchemy 1.1.4,并且我的数据库是MySQL数据库。
我正在更改表和外部列:
在我的数据库中,我将“ 器官 ”表重命名为“ 用途 ”。使用
from alembic import op
def upgrade():
op.rename_table('organs', 'purposes')
Run Code Online (Sandbox Code Playgroud)
之后,我想在另一个表中更新我的ForeignKey:
之前
class Order(DeclarativeBase):
__tablename__ = 'orders'
id = Column(Integer, autoincrement=True, primary_key=True)
organ_id = Column(Integer, ForeignKey('organs.id'))
Run Code Online (Sandbox Code Playgroud)
之后
class Order(DeclarativeBase):
__tablename__ = 'orders'
id = Column(Integer, autoincrement=True, primary_key=True)
purpose_id = Column(Integer, ForeignKey('purposes.id'))
Run Code Online (Sandbox Code Playgroud)
我需要编写一个Alembic迁移脚本来帮助此更改反映在数据库中。如何更改ForeignKey列?
谢谢您的帮助
我是sh脚本的初学者,我需要一些帮助,有人可以帮助我将从Turbogears页面提取的命令行转换为sh脚本,提前感谢.
$ virtualenv --no-site-packages tg2env
$ cd tg2env/
$ source bin/activate
(tg2env)$ pip install tg.devtools
Run Code Online (Sandbox Code Playgroud) turbogears2 ×12
python ×10
turbogears ×4
django ×3
pylons ×3
sqlalchemy ×3
alembic ×1
automation ×1
git ×1
heroku ×1
macos ×1
mysql ×1
pyodbc ×1
pyramid ×1
sh ×1
uwsgi ×1