2010-04-25 1 views
0

안녕하세요, 장거리 패치 앱 엔진 앱을 사용하여/remote_api와 함께 작업하고 있습니다.Google 앱 엔진 remote_api를 사용하여 프로덕션 db 결과 가져 오기

내 온라인 제작 앱에서 로컬로 몇 행을 로컬로 선택하고 싶습니다.

내가 할 수없는 것처럼 보이지만, 모든 것이 잘 인증된다. 수입에 문제가 생기지 않는다.하지만 뭔가를 가져 오려고하면 아무 것도 인쇄하지 않는다. 테스트 파이썬을 로컬 응용 프로그램 디렉토리에 두었습니다.

#!/usr/bin/env python 
# 
import os 
import sys 

# Hardwire in appengine modules to PYTHONPATH 
# or use wrapper to do it more elegantly 
appengine_dirs = ['myworkingpath'] 
sys.path.extend(appengine_dirs) 
# Add your models to path 
my_root_dir = os.path.abspath(os.path.dirname(__file__)) 
sys.path.insert(0, my_root_dir) 

from google.appengine.ext import db 
from google.appengine.ext.remote_api import remote_api_stub 
import getpass 


APP_NAME = 'Myappname' 
os.environ['AUTH_DOMAIN'] = 'gmail.com' 
os.environ['USER_EMAIL'] = '[email protected]' 

def auth_func(): 
return (raw_input('Username:'), getpass.getpass('Password:')) 

# Use local dev server by passing in as parameter: 
# servername='localhost:8080' 
# Otherwise, remote_api assumes you are targeting APP_NAME.appspot.com 
remote_api_stub.ConfigureRemoteDatastore(APP_NAME, 
'/remote_api', auth_func) 

# Do stuff like your code was running on App Engine 
from channel.models import Channel, Channel2Operator 

myresults = mymodel.all().fetch(10) 
for result in myresults: 

print result.key() 

아무런 오류가 없으며 아무 것도 인쇄하지 않습니다. 그래서 remote_api 콘솔 예제 google이 있습니다. myresults를 인쇄 할 때 []를 얻습니다.

답변

2

App Engine 패치는 종류 이름을 끔으로써 ext.db 모듈을 monkeypatches합니다. 스크립트에서 App Engine 패치를 가져 와서 평소처럼 물건을 골탕 먹일 수있는 기회를 주어야합니다. 그렇지 않으면 반환 된 데이터가 표시되지 않습니다.

관련 문제