即使在 import_transform 之后,Google App Engine BadValueError:db.Text

发布于 2024-12-10 08:06:44 字数 4093 浏览 3 评论 0原文

尝试导入 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

说不完的你爱 2024-12-17 08:06:44

您说您已经设置了 import_transform,但 story_html 属性上没有设置转换。您需要针对每个属性进行设置。

You say you've set the import_transform, but there's no transform set on the story_html property. You need to set it per-property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文