문제

그래서 Google App Engine Datastore의 기본 자습서 코드를 실행 중입니다 :

import cgi
import datetime
import urllib
import webapp2

from google.appengine.ext import db
from google.appengine.api import users


class Greeting(db.Model):
    """Models an individual Guestbook entry with an author, content, and date."""
    author = db.UserProperty()
    content = db.StringProperty(multiline=True)
    date = db.DateTimeProperty(auto_now_add=True)


def guestbook_key(guestbook_name=None):
    """Constructs a datastore key for a Guestbook entity with guestbook_name."""
    return db.Key.from_path('Guestbook', guestbook_name or 'default_guestbook')


class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.out.write('<html><body>')
        guestbook_name=self.request.get('guestbook_name')

        # Ancestor Queries, as shown here, are strongly consistent with the High
        # Replication datastore. Queries that span entity groups are eventually
        # consistent. If we omitted the ancestor from this query there would be a
        # slight chance that Greeting that had just been written would not show up
        # in a query.
        greetings = db.GqlQuery("SELECT * "
                                "FROM Greeting "
                                "WHERE ANCESTOR IS :1 "
                                "ORDER BY date DESC LIMIT 10",
            guestbook_key(guestbook_name))

        for greeting in greetings:
            if greeting.author:
                self.response.out.write(
                    '<b>%s</b> wrote:' % greeting.author.nickname())
            else:
                self.response.out.write('An anonymous person wrote:')
            self.response.out.write('<blockquote>%s</blockquote>' %
                                    cgi.escape(greeting.content))

        self.response.out.write("""
          <form action="/sign?%s" method="post">
            <div><textarea name="content" rows="3" cols="60"></textarea></div>
            <div><input type="submit" value="Sign Guestbook"></div>
          </form>
          <hr>
          <form>Guestbook name: <input value="%s" name="guestbook_name">
          <input type="submit" value="switch"></form>
        </body>
      </html>""" % (urllib.urlencode({'guestbook_name': guestbook_name}),
                    cgi.escape(guestbook_name)))


class Guestbook(webapp2.RequestHandler):
    def post(self):
        # We set the same parent key on the 'Greeting' to ensure each greeting is in
        # the same entity group. Queries across the single entity group will be
        # consistent. However, the write rate to a single entity group should
        # be limited to ~1/second.
        guestbook_name = self.request.get('guestbook_name')
        greeting = Greeting(parent=guestbook_key(guestbook_name))

        if users.get_current_user():
            greeting.author = users.get_current_user()

        greeting.content = self.request.get('content')
        greeting.put()
        self.redirect('/?' + urllib.urlencode({'guestbook_name': guestbook_name}))


app = webapp2.WSGIApplication([('/', MainPage),
    ('/sign', Guestbook)],
    debug=True)
.

pycharm 내에서 위의 코드를 실행하려면 'Shift + F10'을 눌러 단지

사이트가 127.0.0.1:8080에서 열리기 전에 다음 로깅을받습니다.

c : \ python27 \ python.exe "C : / 프로그램 파일 / Google / google_appengine / dev_appserver.py ".

경고 2012-03-02 01 : 34 : 41,374 rdbms_mysqldb.py:74] RDBMS API는 mysqldb 라이브러리를로드 할 수 없으므로 사용할 수 없습니다.

정보 2012-03-02 01 : 34 : 41,976 appengine_rpc.py:160] 서버 : appengine.google.com

정보 2012-03-02 01 : 34 : 41,983 appcfg.py:581] 업데이트 확인 SDK에.

정보 2012-03-02 01 : 34 : 44,369 appcfg.py:599] SDK는 최신 상태입니다.

경고 2012-03-02 01 : 34 : 44,371 DataStore_File_stub.py:513] 데이터 저장소 데이터 읽기 C : \ users \ robert \ appdata \ local \ temp \ dev_appserver.datastore

정보 2012-03-02 01 : 34 : 46,295 dev_appserver_multiprocess.py:650] 실행중인 Application Dev ~ HelloWorld에서 포트 8080 : http : // localhost : 8080

정보 2012-03-02 01 : 34 : 46,296 dev_appserver_multiprocess.py:652] 관리 콘솔은 http : // localhost : 8080 / _ah / admin

경고 2012-03-02 01 : 34 : 47,480 py_zipimport.py:139] 열 수 없다 ZipFile C : \ Python27 \ lib \ site-packages \ pyfacebook-1.0a2-py2.7.egg : IOERROR : [errno 13] 파일에 액세스하지 않음 : 'C : \ Python27 \ lib \ site-packages \ pyfacebook-1.0a2-py2.7.egg'

INFO 2012-03-02 01 : 34 : 49,108 DATASTORE_STUB_INDEX.PY:257] 업데이트 C : \ Users \ Robert \ pycharmprojects \ helloworld \ index.yaml

정보 2012-03-02 01 : 34 : 49,148 dev_appserver.py:2865] "GET / HTTP / 1.1 "200 -

정보 2012-03-02 01 : 34 : 49,315 dev_appserver.py:2865] " /favicon.ico http / 1.1 "404 -

참고 로그에는 행이 있습니다.

경고 2012-03-02 01 : 34 : 47,480 py_zipimport.py:139] ZipFile C : \ Python27 \ lib \ site-packages \ pyfacebook-1.0a2-py2.7.egg를 열 수 없습니다. ioError : [errno 13] 파일에 액세스 할 수 없습니다 : 'C : \ Python27 \ lib \ site-packages \ pyfacebook-1.0a2-py2.7.egg'

나는 이것에 대한 합리적인 논리적 설명이 있다고 확신합니다.

도움이 되었습니까?

해결책

I don't know for sure, but it "smells" like a path / installation conflict. Perhaps App Engine is finding the package in a spot where it can't access it (in another python installation, perhaps?). If you can import the package from the interactive python shell, then the file has the right permissions; in that case, check for multiple installations / install paths. In my case, something was installed in the "system" python but not the one App Engine was using.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top