def create_user(self, **kwargs): from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper connection = DatabaseWrapper(self.database_settings) cursor = connection.cursor() opts = self.model._meta fields = [f for f in opts.fields if f.name != 'id'] try: kwargs['password'] = utils.make_password_hash(kwargs['password']) values = [kwargs[f.name] for f in fields] except KeyError, e: raise ValueError('Missing field: %s' % e)
def get_query_set(self): qs = BaseGeoManager.get_query_set(self) try: # First, check the global connection dictionary, because this # connection might have already been created. conn = connections[self.connection_name] except KeyError: conn = DatabaseWrapper(self.database_settings) connections[self.connection_name] = conn qs.query.connection = conn return qs
def set_password(self, user_id, raw_password): from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper connection = DatabaseWrapper(self.database_settings) cursor = connection.cursor() password = utils.make_password_hash(raw_password) cursor.execute( "UPDATE %s SET password=%%s WHERE id=%%s" % self.model._meta.db_table, (password, user_id)) connection._commit() connection.close()
def set_password(self, user_id, raw_password): from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper connection = DatabaseWrapper(self.database_settings) cursor = connection.cursor() password = utils.make_password_hash(raw_password) cursor.execute("UPDATE %s SET password=%%s WHERE id=%%s" % self.model._meta.db_table, (password, user_id)) connection._commit() connection.close()