google app engine - Adding methods to GAE database class -


i messing around gae. want place database object in 1 file , call another. here db object:

import webapp2 import os import jinja2 import json import logging import main     google.appengine.ext import db   class user(db.model):     user_name = db.stringproperty(required = true)     hashed_password = db.stringproperty(required = true)     email = db.emailproperty(required = true)     created_dttm = db.datetimeproperty(auto_now_add = true)     last_modified = db.datetimeproperty(auto_now = true)     coords = db.geoptproperty(required = false)       # def as_dict(self):         # time_fmt = '%c'         # d = {                  # 'subject':self.subject,                 # 'content':self.content,                 # 'created':self.created_dttm.strftime(time_fmt),                 # 'last_modified': self.last_modified.strftime(time_fmt)             # }         # return d        def isvalueunique(self,column,value):         result = none         q = user.all()         q.filter(column, value)         result = q.get()         return result 

i cannot instantiate db because thinks i'm trying store data.

i want call isvalueunique method file so:

import webapp2 import os import jinja2 import json import logging import main  import database import validation  google.appengine.ext import db    class signup(main.handler):     def post(self):         user_username = self.request.get("username")         user_email = self.request.get("email")         user_pass = self.request.get("password")         user_verify = self.request.get("verify")         valid = validation.valid()         error1=""         error2=""         error3=""         error4=""           q = database.user.all()         q.filter("username =", user_username)         result = q.get()         if result:             error1="username taken"         if (not valid.valid_user(user_username)) , (not error1):             error1 = "enter valid username"         if not valid.valid_password(user_pass):             error2 = "enter valid password"         if not valid.valid_pass_match(user_pass,user_verify):             error3 = "passwords must match"          # email validation         email=valid.valid_email(user_email)         if not email:             error4 = "invalid email"             email=""         elif not database.user.isvalueunique("email",email):             error4 = "email in use, please sign in"             email="" 

i error: elif not database.user.isvalueunique("email",email):

typeerror: unbound method isvalueunique() must called user instance first argument (got str instance instead)

i can't instantiate user said. work around here?

database.user.isvalueunique("email",email)

this attempting call method on database.user class, isvalueunique instance method.

if decorate isvalueunique @staticmethod you'll farther.

where trying instantiate user?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -