【问题标题】:Datastore (ndb) inserting linebreaks into content (type: TextProperty)数据存储区 (ndb) 在内容中插入换行符(类型:TextProperty)
【发布时间】:2012-10-07 02:33:56
【问题描述】:

我有一个看起来像这样的模型:

class Foo(ndb.Model):
    bar = ndb.TextProperty(required=True)
    # other properties

我正在使用 jinja2 进行模板:

{{ bar|safe }}

我“输入”this:

<p>I think it is always going to be challenging planning a wedding in a foreign country. 1234 Weddings was able to pre-arrange everything before our arrival and even meet us at the airport to attend to last minute details.<br> The wedding itself was even more amazing than we could have imagined and flawless. For our day, 1234 Weddings became a part of our family and our memories. We are so greatful for the professional communication and creativity that made our day so special.</p>

ndb 破坏文本,输出this:

<p>I think it is always going to be challenging planning a wedding in a for=
eign country. 1234 weddings was able to pre-arrange everything before our a=
rrival and even meet us at the airport to attend to last minute details.<br=
>The wedding itself was even more amazing than we could have imagined and f=
lawless. For our day, 1234 Weddings became a part of our family and our mem=
ories. We are so greatful for the professional communication and creativity=
 that made our day so special.</p>

这只发生在我部署的站点上。 localhost 上的相同代码不会产生此问题。

可能相关:

  • 我的本地应用引擎没有持久数据存储。
  • bar 最初属于“StringProperty”类型。在将类型更改为“TextProperty”后,我注意到了这个问题,但在更改之前没有进行广泛的测试,因此问题可能在此之前就存在。

任何帮助将不胜感激。
TIA。

【问题讨论】:

  • 如何将文本放入ndb实体中?我了解:当您在放置实体后记录实体时,您会看到“=”。
  • 文本是否与文件上传一起保存? stackoverflow.com/questions/5039813/…
  • @voscausa 是的,没错。此外,将文本放入数据存储区,如下所示: def post(self): bar = self.request.get('bar') if bar: q = Foo() q.bar = bar q.put()
  • @Greg 是的,是的。谢谢你的链接。这是同样的问题。我将按照那里的说明进行操作,看看它会带我去哪里。
  • @Greg 您能否将您的解决方案发布为答案,以便我接受并给予您信任?谢谢

标签: google-app-engine google-cloud-datastore


【解决方案1】:

blobstore 上传处理程序中有一个错误导致同时提交的文本出现编码问题,这里的 cmets 有一个过去对我有用的补丁:http://code.google.com/p/googleappengine/issues/detail?id=2749

【讨论】:

    【解决方案2】:

    这不是 NDB —— 也不是 Datastore 对您的文本做这样的事情。它看起来像是某种内容编码,尤其是quoted-printable,可能由浏览器应用?

    【讨论】:

    猜你喜欢
    • 2014-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-27
    • 2021-12-15
    • 1970-01-01
    相关资源
    最近更新 更多