class Thread(db.Model):
members = db.StringListProperty()
def user_is_member(self, user):
return str(user) in self.members
Run Code Online (Sandbox Code Playgroud)
和
thread = Thread.get(db.Key.from_path('Thread', int(id)))
is_member = thread.user_is_member(user)
Run Code Online (Sandbox Code Playgroud)
但错误是:
Traceback (most recent call last):
File "D:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 511, in __call__
handler.get(*groups)
File "D:\Program Files\Google\google_appengine\google\appengine\ext\webapp\util.py", line 62, in check_login
handler_method(self, *args)
File "D:\zjm_code\forum_blog_gae\main.py", line 222, in get
is_member = thread.user_is_member(user)
AttributeError: 'NoneType' object has no attribute 'user_is_member'
Run Code Online (Sandbox Code Playgroud)
为什么?
谢谢
我已经创建了.exe文件的快捷方式.
我想添加'.exe'额外参数.(在快捷方式:目标属性)
示例
目标:
"C:\ Documents and Settings\dezigo\My Documents\c#programm\DirectoryScanner\DirectoryScanner\DirectoryScanner\bin\Debug\DirectoryScanner.exe "+额外的parrams(如方法= 1)
如何在我的软件中读取这些参数?(c#)
然后,当启动.exe
检查
if(method == 1)
{
//do something
}
else
{
//do something
}
Run Code Online (Sandbox Code Playgroud) 目前在我的项目中,我们使用全部大写作为常量的命名约定。我想改变它,并且我同意 Pascal Casing,但我的团队领导有一个强有力的论点,即它不会明显区分常量与属性和其他类型。
请帮助我提出任何其他建议。
结果
正如 @Paolo Tedesco 和这里的大多数人所想的那样,我会坚持ALL_CAPS. 无论如何,我现在也没有其他选择,因为 @24x7Programmer 提供的论点无法改变我的团队领导的想法。现在我不能再争论这个小问题了。
谢谢大家的建议。
对于这个问题,这是一个糟糕的标题,但我不太确定一个更好的问题.
我有一个名为Globals的命名空间,其中包含一个类X. 我还有一个名为Globals的课程.当我尝试访问Globals.X.StaticMember时,它尝试访问Globals.X类并抱怨X不存在.我如何引用命名空间Globals - 即:: Globals.X.StaticMember(::不编译).
为什么我得到一个异常调用,NullPointerException如果在Java中没有指针这样的概念?
Vector API定义了4种不同的构造函数:
Vector()
Vector(Collection<? extends E> c)
Vector(int initialCapacity)
Vector(int initialCapacity, int capacityIncrement)
Run Code Online (Sandbox Code Playgroud)
但它们如何运作以及它们用于什么?我为什么要为矢量定义固定容量?即使我将初始容量设置为100,我也可以向向量添加101.项:
Vector<Object> test = new Vector<Object>(100);
for (int i = 0; i < 100; i++) {
test.add(new Object());
}
test.add(new Object());
System.out.println(test.size());
System.out.println(test.capacity());
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,第二个sysout(test.capacity())写入200.为什么此向量中的容量为200?初始容量为100,我没有定义容量增量.
我真的想知道是否有使用这些建筑师的真实世界的例子?
还有一个熟悉的问题:究竟是Vector.get(int position)和Vector.elementAt(int position)之间的区别?我读到在将Vector添加到Collection类之前定义了get方法,因此有必要在以后添加方法elementAt(int position).真的吗?或者还有其他差异吗?
我总是使用以下格式来使用transactionscope.
using(TransactionScope scope = new TransactionScope()){
....
}
有时我想将Transactionscope包装到一个新类,例如DbContext类,我想使用像这样的语句
dbContext.Begin(); ... dbContext.Submit();
似乎transactioncope类需要使用"using"语句来进行处理,我想知道是否还有使用"using".
例如:
public final class R {
public static final class raw {
public static final int yuri=0x7f040000;
}
}
Run Code Online (Sandbox Code Playgroud)
如何通过名称获取资源?不使用R.raw.yuri =(int)
如何从ASP.NET中的数据表/数据视图中选择前n行?目前我使用以下代码,传递表和行数以获取记录.有没有更好的办法?
public DataTable SelectTopDataRow(DataTable dt, int count)
{
DataTable dtn = dt.Clone();
for (int i = 0; i < count; i++)
{
dtn.ImportRow(dt.Rows[i]);
}
return dtn;
}
Run Code Online (Sandbox Code Playgroud) 当我将UISearchBar放入Interface Builder中的视图中,并将其样式更改为Black Opaque时,取消按钮保持不合适的蓝色/灰色并且不会变为黑色.
如何将取消按钮设为黑色?
编辑:它确实像这样工作:
// Assume a UISearchBar searchBar.
NSArray *subviews = [searchBar subviews];
// The index depends on how you configure the searchBar.
UIButton *cancelButton = [subviews objectAtIndex:3];
// Set the style to "normal" style.
[cancelButton setStyle:0];
Run Code Online (Sandbox Code Playgroud)
但该setStyle:方法来自私有框架,因此在向Apple提交应用程序时可能会出现问题.
cocoa-touch background-color uibarbuttonitem uisearchbar ios