即使在 import_transform 之后,Google App Engine BadValueError:db.Text
尝试导入 TextProperty,类似于另一个 Stack Overflow 问题 (http://stackoverflow.com/questions/3434090/app-engine-badvalueerror-on-bulk-data-upload-textproperty-being-construed-as-s)
之后添加 import_transform: db.Text,我仍然收到错误。 Story_html 是一个 TextProperty()
BadValueError: Property story_html is 3132 bytes long; it must be 500 or less. Consider Text instead, which can store strings of any length.
My Bulkloader.yaml 文件。
python_preamble:
- import: base64
- import: re
- import: google.appengine.ext.bulkload.transform
- import: google.appengine.ext.bulkload.bulkloader_wizard
- import: google.appengine.ext.db
- import: google.appengine.api.datastore
- import: google.appengine.api.users
transformers:
- kind: Story connector: csv connector_options:
encoding: utf-8
columns: from_header property_map:
- property: publication
external_name: publication
- property: title
external_name: title
- property: author
external_name: author
- property: date
external_name: date
- property: url
external_name: url
import_transform: db.Link
- property: story_html
external_name: story_html
- property: story_text
external_name: story_text
- property: link_text
external_name: link_text
- property: story_text_word
external_name: story_text_word
- property: story_text_frequency
external_name: story_text_frequency
- property: link_text_word
external_name: link_text_word
- property: link_text_frequency
external_name: link_text_frequency
- property: tags
external_name: tags
- property: companies
external_name: companies
- property: companies_links
external_name: companies_links
我的 Models.py 文件
from google.appengine.ext import db
class Story(db.Model):
publication = db.StringProperty()
title = db.StringProperty()
author = db.StringProperty()
date = db.DateProperty()
url = db.LinkProperty()
story_html = db.TextProperty()
# Processed Attributes
story_text = db.TextProperty()
link_text = db.TextProperty()
# Word Frequency
story_text_word = db.ListProperty(unicode)
story_text_frequency = db.ListProperty(int)
link_text_word = db.ListProperty(unicode)
link_text_frequency = db.ListProperty(int)
tags = db.ListProperty(unicode)
companies = db.ListProperty(unicode)
companies_links = db.ListProperty(unicode)
和我的 loaders.py 文件
import datetime from google.appengine.ext import db
from google.appengine.tools import bulkloader
import re
import models
class StoryLoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'Story',
[('publication', lambda x: x.decode('utf-8')),
('title', lambda x: x.decode('utf-8')),
('author', lambda x: x.decode('utf-8')),
('date', lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date()),
('url', str),
('story_html', lambda x: db.Text(x.decode('utf-8'))),
('story_text', lambda x: db.Text(x.decode('utf-8'))),
('link_text', lambda x: db.Text(x.decode('utf-8')))
('story_text_word', lambda x: x.split('|')),
('story_text_frequency', lambda x: list(eval(x))),
('link_text_word', lambda x: x.split('|')),
('link_text_frequency', lambda x: x.split('|')),
('tags', lambda x: x.split('|')),
('companies', lambda x: x.split('|')),
('companies_links', lambda x: x.split('|'))])
loaders = [StoryLoader]
Attempting to import a TextProperty, similar to another Stack Overflow question (http://stackoverflow.com/questions/3434090/app-engine-badvalueerror-on-bulk-data-upload-textproperty-being-construed-as-s)
After adding the import_transform: db.Text, I still get an error. The story_html is a TextProperty()
BadValueError: Property story_html is 3132 bytes long; it must be 500 or less. Consider Text instead, which can store strings of any length.
My Bulkloader.yaml file.
python_preamble:
- import: base64
- import: re
- import: google.appengine.ext.bulkload.transform
- import: google.appengine.ext.bulkload.bulkloader_wizard
- import: google.appengine.ext.db
- import: google.appengine.api.datastore
- import: google.appengine.api.users
transformers:
- kind: Story connector: csv connector_options:
encoding: utf-8
columns: from_header property_map:
- property: publication
external_name: publication
- property: title
external_name: title
- property: author
external_name: author
- property: date
external_name: date
- property: url
external_name: url
import_transform: db.Link
- property: story_html
external_name: story_html
- property: story_text
external_name: story_text
- property: link_text
external_name: link_text
- property: story_text_word
external_name: story_text_word
- property: story_text_frequency
external_name: story_text_frequency
- property: link_text_word
external_name: link_text_word
- property: link_text_frequency
external_name: link_text_frequency
- property: tags
external_name: tags
- property: companies
external_name: companies
- property: companies_links
external_name: companies_links
My Models.py file
from google.appengine.ext import db
class Story(db.Model):
publication = db.StringProperty()
title = db.StringProperty()
author = db.StringProperty()
date = db.DateProperty()
url = db.LinkProperty()
story_html = db.TextProperty()
# Processed Attributes
story_text = db.TextProperty()
link_text = db.TextProperty()
# Word Frequency
story_text_word = db.ListProperty(unicode)
story_text_frequency = db.ListProperty(int)
link_text_word = db.ListProperty(unicode)
link_text_frequency = db.ListProperty(int)
tags = db.ListProperty(unicode)
companies = db.ListProperty(unicode)
companies_links = db.ListProperty(unicode)
And my loaders.py file
import datetime from google.appengine.ext import db
from google.appengine.tools import bulkloader
import re
import models
class StoryLoader(bulkloader.Loader):
def __init__(self):
bulkloader.Loader.__init__(self, 'Story',
[('publication', lambda x: x.decode('utf-8')),
('title', lambda x: x.decode('utf-8')),
('author', lambda x: x.decode('utf-8')),
('date', lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date()),
('url', str),
('story_html', lambda x: db.Text(x.decode('utf-8'))),
('story_text', lambda x: db.Text(x.decode('utf-8'))),
('link_text', lambda x: db.Text(x.decode('utf-8')))
('story_text_word', lambda x: x.split('|')),
('story_text_frequency', lambda x: list(eval(x))),
('link_text_word', lambda x: x.split('|')),
('link_text_frequency', lambda x: x.split('|')),
('tags', lambda x: x.split('|')),
('companies', lambda x: x.split('|')),
('companies_links', lambda x: x.split('|'))])
loaders = [StoryLoader]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您说您已经设置了
import_transform
,但story_html
属性上没有设置转换。您需要针对每个属性进行设置。You say you've set the
import_transform
, but there's no transform set on thestory_html
property. You need to set it per-property.