我正在撰写的一些Google App Engine代码出现了一个奇怪的错误.
我的程序包含一些这样的代码:
import datetime
...
class Action(db.Model):
visibleDate = db.DateTimeProperty()
...
getActionQuery = Action.gql("WHERE user = :user AND __key__ = :key", user = user, key = self.request.get("key"))
theAction = getActionQuery.get()
....
theAction.visibleDate = datetime.datetime.strptime(self.request.get("visibleDate"), "%Y/%m/%d")
Run Code Online (Sandbox Code Playgroud)
然而,这会产生以下错误:
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 509, in __call__
handler.post(*groups)
File "/Users/redbird/Developer/betterdo-it/main.py", line 132, in post
theAction.visibleDate = datetime.datetime.strptime(self.request.get("visibleDate"), "%Y/%m/%d"),
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 472, in __set__
value = self.validate(value)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 2308, in validate
(self.name, self.data_type.__name__))
BadValueError: Property visibleDate … 这是使用Reportlab为我生成pdf的代码.
现在,它只是在浏览器中显示pdf,并且在resonse.header ['Content-Disposition']中包含'attachment'后,它会下载pdf.
但我想要的是浏览器中的rint选项,它甚至允许您选择打印机.可能吗 ?
data = "raghav"
p = canvas.Canvas(self.response.out)
p.drawString(50, 700, data)
p.showPage()
self.response.headers['Content-Type'] = 'application/pdf'
self.response.headers['Content-Disposition'] = 'attachment;filename=testpdf.pdf'
p.save()
Run Code Online (Sandbox Code Playgroud) 我创建了一个Cassandra键空间跟踪器:
CREATE KEYSPACE tracker WITH replication = {
'class': 'SimpleStrategy',
'replication_factor': '3'
};
Run Code Online (Sandbox Code Playgroud)
然后我可以在这个键空间中成功创建一个表:
cqlsh:tracker> CREATE TABLE tracker.click_windows (
... visitor_id text,
... created_at timeuuid,
... click_id text,
... ended_at timeuuid,
... expires_at timeuuid,
... processed_at timeuuid,
... window_size int,
... PRIMARY KEY (visitor_id, created_at)
... ) WITH CLUSTERING ORDER BY (created_at DESC) AND
... bloom_filter_fp_chance=0.010000 AND
... caching='KEYS_ONLY' AND
... comment='' AND
... dclocal_read_repair_chance=0.000000 AND
... gc_grace_seconds=864000 AND
... read_repair_chance=0.100000 AND
... replicate_on_write='true' AND
... populate_io_cache_on_flush='false' AND
... compaction={'class': …Run Code Online (Sandbox Code Playgroud) 我想做的是改变我的主管,尽最大努力让孩子继续跑步,但是如果他们的碰撞率超过强度就放弃.这样,其余的孩子继续跑步.但是,对于现有的管理程序配置,这似乎是不可能的,因此看起来我唯一的选择可能是实现我自己的主管,这样我就可以在收到时以这种方式行事EXIT.
有没有办法在不编写自己的主管的情况下实现这样的自定义OTP管理程序行为?
我正在编写一个java程序来输出2的指数幂(顺便说一下,我不能使用Math.pow()),但是在2 ^ 31和2 ^ 32我得到了别的东西.另外,我不打算接受负整数.
我的代码:
class PrintPowersOf2 {
public static void main (String[] args) {
printPowersOf2(10);
printPowersOf2(5);
printPowersOf2(2);
printPowersOf2(-5);
printPowersOf2(30);
printPowersOf2(32);
}
public static void printPowersOf2 (int x) {
for(int i=0;i<x+1;i++) {
int y = exponent (i);
System.out.print(y);
if(!(i == x)) {
System.out.print(" ");
}
}
System.out.println();
}
static int exponent(int power) {
int output = 1;
for (int z=0; z<power; z++)
output *= 2;
return output;
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的输出是:
1 2 4 8 16 32 64 …Run Code Online (Sandbox Code Playgroud) 我开始使用睡衣了,我遇到了一些烦恼.我必须导入很多东西才能使脚本运行良好.例如,要制作一个我需要的按钮
from pyjamas.ui.Button import Button
Run Code Online (Sandbox Code Playgroud)
然后我可以使用Button.注意
import pyjamas.ui.Button
Run Code Online (Sandbox Code Playgroud)
然后使用Button.Button不起作用(在构建JavaScript时导致错误,至少在0.7pre1中).有没有人比穿着睡衣的人在他们的网站上有更好的方法来做一个穿着睡衣的导入语句?从我的角度来看,他们的方式是可行的,但是很丑陋且过于复杂,特别是当你想要使用十几个或更多ui组件时.
在 Ruby 中,我有一个测试,它是Postgres(实际上是 Greenplum)数据库中的子类ActiveSupport::TestCase并通过子类访问表。ActiveRecord对于特定的测试,我需要在表中填充大约一百万行,但我并不真正关心其中有什么。我可以做类似的事情
for i in 1...1000000 do
MyTable.create(:column1 => 'value', :column2 => 'value')
end
Run Code Online (Sandbox Code Playgroud)
但这需要很长时间才能运行。我可以通过将其包装在事务中来使其更快一点,这样就create不会每次都创建一个新事务,但这只会节省很多时间。
有没有一些好的方法可以做到这一点,这样我就不必在表中执行大量的虚假值插入?
(注意:尝试假装该表包含一百万条记录的存根是行不通的,因为我稍后需要与实际行进行交互;对于这个特定的测试,我只是不关心它们是什么)
python ×3
activerecord ×1
cassandra ×1
coding-style ×1
cql ×1
cql3 ×1
cqlsh ×1
datetime ×1
elixir ×1
erlang ×1
erlang-otp ×1
greenplum ×1
http-headers ×1
import ×1
java ×1
pdf ×1
postgresql ×1
pyjamas ×1
reportlab ×1
ruby ×1