Appengine model filtering problem
I've got an entity class:
class User(db.Model):
local = db.Text开发者_C百科Property(required=True)
jid = db.TextProperty(required=True)
Later in code I'm checking if a user exists:
def parseMessageFromJid(self, message, mesFrom) :
#user = User.all().filter(' jid', mesFrom.lower().strip()).get()
user = db.GqlQuery("SELECT * FROM User " +
"WHERE jid = :1",
mesFrom.lower().strip()).get()
if user is None :
if message.body.strip().lower().find("register") != 0 :
message.reply(HELP_MSG)
elif message.body.strip().lower().find("register") == 0 :
uname = message.body.strip().replace("register ", "", 1).replace(" ", "") + "@mybot.com"
user = User(jid=mesFrom,local=uname)
user.put()
message.reply("Ok. You are now registered.")
else :
# User registered, proceed
self.send_to_bots(message, user.local)
I tried both approaches: gql and the commented code. Both approaches return None
, althought the user is there: I can see it in my console and it is there when I do User.all()
. What am I missing here?
TextProperty
is not indexed.
Use StringProperty
精彩评论