【问题标题】:Did something try to access my facebook?有什么东西试图访问我的 Facebook 吗?
【发布时间】:2012-03-02 01:46:39
【问题描述】:

所以我正在运行谷歌应用引擎数据存储介绍的基本教程代码:

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

INFO 2012-03-02 01:34:41,983 appcfg.py:581] 检查更新 到 SDK。

INFO 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] 在 8080 端口上运行应用程序 dev~helloworld: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] 无法打开 压缩文件 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] “获取 / 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'

我确信对此有一个合理、合乎逻辑的解释,有人知道吗?

【问题讨论】:

  • 是的 pyfacebook-1.0a2-py2.7.egg 在那个目录中。

标签: python google-app-engine pycharm


【解决方案1】:

我不确定,但它“闻起来”像路径/安装冲突。也许 App Engine 在它无法访问的地方找到了包(也许在另一个 python 安装中?)。如果您可以从交互式 python shell 中导入包,则该文件具有正确的权限;在这种情况下,请检查多个安装/安装路径。就我而言,“系统”python 中安装了一些东西,但不是 App Engine 正在使用的那个。

【讨论】:

    猜你喜欢
    • 2021-11-05
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 2020-08-12
    • 1970-01-01
    • 2015-03-04
    • 1970-01-01
    相关资源
    最近更新 更多