我正在使用GAE Python 2.7标准环境创建基于Flask的Web应用程序。当我尝试在application / __ init__py文件和其他文件中导入动物模型时,App Engine SDK引发DuplicatePropertyError。
DuplicatePropertyError: Class AnimalKind already has property animal_set
.
├── README.md
├── requirements.txt
├── src
│ ├── app.yaml
│ ├── application
│ │ ├── __init__.py
│ │ ├── animal_bp
│ │ │ ├── __init__.py
│ │ │ └── views.py
│ │ ├── appengine_config.py
│ │ ├── main.py
│ │ ├── models
│ │ │ ├── __init__.py
│ │ │ ├── base_models.py
│ │ │ ├── common_models.py
│ │ │ └── kind_models.py
│ │ └── settings.py
│ ├── index.yaml
│ ├── lib
service: default
runtime: python27
api_version: 1
threadsafe: true
instance_class: F1
builtins:
- appstats: on
- remote_api: on
libraries:
- name: ssl
version: latest
inbound_services:
- warmup
# [START handlers]
handlers:
- url: /static
static_dir: static
- url: .*
script: run.application.app
# script: main.app
secure: always
# [END handlers]
# -*- coding: utf-8 -*-
import os
import sys
sys.path.insert(1, os.path.join(os.path.abspath('.'), 'lib'))
sys.path.insert(1, os.path.join(os.path.abspath('.'), 'application'))
import application
# -*- coding: utf-8 -*-
import os
from flask import Flask, g, request, session
from werkzeug.debug import DebuggedApplication
from animal_bp.views import animal_bp
from models.common_models import Animal
def create_app():
app = Flask(__name__)
app.config.from_object('application.settings.Local')
app.wsgi_app = DebuggedApplication(app.wsgi_app, evalex=True)
app.register_blueprint(animal_bp)
return app
app = create_app()
from google.appengine.ext import db
from models.kind_models import AnimalKind
class Animal(db.Model):
"""
Animal Model
"""
animal_kind_name = db.ReferenceProperty(AnimalKind)
from google.appengine.ext import db
class AnimalKind(db.Model):
"""
Kind Model
"""
name = db.StringProperty(required=True)
from flask import Blueprint
from models.common_models import Animal
animal_bp = Blueprint('animal_bp', __name__)
@animal_bp.route('/')
def hello():
return 'Hello world1'
例如,如果我删除animal_bp / views.py中的“从models.common_models导入动物”。错误不会出现。当然,当我从application / init。py文件中删除“ from models.common_models import Animal”时,不会引发错误。
我没有任何重复属性,但是由于我的目录结构,初始化过程可能运行了两次。抱歉,这么长的问题,但是任何帮助都将受到欢迎!
我正在使用GAE Python 2.7标准环境创建基于Flask的Web应用程序。当我尝试将动物模型导入application / __ init__py文件和其他文件中时,App Engine SDK会引发...
from google.appengine.ext import db
from models.kind_models import AnimalKind
class Animal(db.Model):
"""
Animal Model
"""
animal_kind_name = db.ReferenceProperty(AnimalKind)