小编use*_*451的帖子

金字塔返回新会话

我使用Cornice制作RESTful网址.

我安装了pyramid-beaker,并__init__.py在doc中指定了我的include .

而已.然后我在我的观点中这样做了:

p_desc = """Service to post session. """
p = Service(name='p',\
                    path=root+'/1',\
                    description=register_desc)
g_desc = """Service to get session. """
g = Service(name='g',\
                    path=root+'/2',\
                    description=g_desc)

@g.get()
def view2(request):
    print request.session
    return Response()

@p.post()
def view1(request):
    print 'here'
    request.session['lol'] = 'what'
    request.session.save()
    print request.session
    return Response()
Run Code Online (Sandbox Code Playgroud)

这是我的结果

>>> requests.post('http://localhost/proj/1')
<Response [200]>
>>> requests.get('http://localhost/proj/2')
<Response [200]>

Starting HTTP server on http://0.0.0.0:6543
here
{'_accessed_time': 1346107789.2590189, 'lol': 'what', '_creation_time': 1346107789.2590189}
localhost - - [27/Aug/2012 18:49:49] "POST /proj/1 HTTP/1.0" 200 …
Run Code Online (Sandbox Code Playgroud)

python session pyramid cornice

2
推荐指数
1
解决办法
574
查看次数

django中找不到模板

我正在使用django 1.4

Django尝试按以下顺序加载这些模板:

Using loader django.template.loaders.filesystem.Loader:
    /home/user/mysite/template/<WSGIRequest path:/polls/what/, GET:<QueryDict: {}>, POST:<QueryDict: {}>,
Run Code Online (Sandbox Code Playgroud)

使用pwd我看到这个:

/home/user/mysite/template
Run Code Online (Sandbox Code Playgroud)

template I have民意调查中

这就是我的意思 settings.py

TEMPLATE_DIRS = (
    '/home/user/mysite/template',
Run Code Online (Sandbox Code Playgroud)

现在在我看来:

return render_to_response(request, 'polls/index.html',
Run Code Online (Sandbox Code Playgroud)

为什么还在抱怨?

谢谢.

django django-templates

1
推荐指数
1
解决办法
4358
查看次数

Python是静态类型的吗?

我知道Python是动态类型,鸭子类型,也很强大.在某些情况下,为了使用它们,我们必须确保它事先声明为列表或字典...所以我可以说Python也是静态类型语言吗?

python

1
推荐指数
1
解决办法
131
查看次数

LOAD DATA LOCAL INFILE不能跳过列?

我已经搜索了几个小时,但它不起作用.

我有一个总统职位的csv文件.第一行是标题.

Presidency ,President ,Wikipedia Entry,Took office ,Left office ,Party ,Portrait,Thumbnail,Home State
Run Code Online (Sandbox Code Playgroud)

我想创建一个只有一个关系Presidency,PresidentParty.

$sqlquerycreate1 = "CREATE TABLE IF NOT EXISTS `sample1` (
  `Presidency`  VARCHAR(30),
  `President` VARCHAR(30),
  `Party` VARCHAR(30)
)";
mysql_query($sqlquerycreate1);

# download the file off the internet
$file = file_get_contents("http://localhost/sample.csv");
$filepath = "sample.csv";
file_put_contents($filepath, $file);

# load the data into nycgrid table
$pt11 = "LOAD DATA LOCAL INFILE ";
$pt21 = "'C:/xampp/htdocs/test/file/sample.csv' INTO TABLE sample1(Presidency,President,@Wikipedia Entry,@Took office ,@Left office ,Party,@Portrait,@Thumbnail,@Home State) ";
$pt31 = …
Run Code Online (Sandbox Code Playgroud)

php mysql

0
推荐指数
1
解决办法
5678
查看次数

标签 统计

python ×2

cornice ×1

django ×1

django-templates ×1

mysql ×1

php ×1

pyramid ×1

session ×1