NDB中的TextProperty字段获得“=”在每行之后附加 [英] TextProperty field in NDB gets "=" appended after every line

查看:95
本文介绍了NDB中的TextProperty字段获得“=”在每行之后附加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的前端,我使用textarea和submit按钮来创建表单。
在提交时,textarea字段被保存为 ndb.TextProperty()
当我提交多行文本时,数据库中的文本获取 = = 20 每行上的字符。起初我以为他们会随机插入,但似乎每76个字符都会得到一个 = 字符。

这真的很难调试,因为在我的本地主机实例上它工作得很好,但在部署的版本上它却不行。它们都是同步的。同样在我的本地主机实例上,数据存储区实体上的文本字段正确显示了换行符和制表符,但在已部署的版本上,数据存储区字段显示为一个没有换行符或制表符的文本块。

任何人都可以引导我走向正确的方向吗?

解决方案

噢,BlobStoreHandler您在原始问题中没有提及。



好的,你有问题。



我不相信你可以把这两者结合起来。如果您上传到Blobstore,则无法执行其他表单元素,因为上传是针对BlobStore服务的。

来自文档


用户通过提交包含一个
或更多文件输入字段的HTML表单来创建一个blob。您的应用程序调用create_upload_url()
来获取此表单的目标(操作),并在应用程序中传递函数
的处理程序的URL路径。当用户提交
表单时,用户的浏览器将指定的文件直接上传到
Blobstore。 Blobstore重写用户的请求并存储
上传的文件数据,用一个或多个
相应的blob键替换上传的文件数据,然后将重写的请求传递给URL路径中的
处理程序你提供给create_upload_url()。这个
处理程序可以根据blob键进行额外的处理。


所以很难说没有看到你的代码,但我真的怀疑你可以做你想做的事情。


I have very strange case which I wasn't able to debug for a day.

On my front-end I have form with textarea and submit button. On submission, the textarea field gets saved as ndb.TextProperty() When I submit a multiline text, the text in the database gets = or =20 characters on every line. At first I thought they get randomly inserted, but it seems every 76 characters gets one = character.

This gets really hard to debug as on my localhost instance it works perfectly fine, but on the deployed version it doesn't. They are both in sync. Also on my localhost instance the text field on the datastore entity shows correctly the newline and tab characters, but on the deployed version, the datastore field is shown as one text blob without newlines or tabs.

Anyone can guide me to the right direction ?

解决方案

Oh, BlobStoreHandler you didn't mention that in your original question.

Ok there is your problem.

I don't believe you can combine the two. If you are uploading to the Blobstore you can't do other form elements, as the upload is directed to the BlobStore service.

From the docs

The user creates a blob by submitting an HTML form that includes one or more file input fields. Your application calls create_upload_url() to get the destination (action) of this form, passing the function a URL path of a handler in your application. When the user submits the form, the user's browser uploads the specified files directly to the Blobstore. The Blobstore rewrites the user's request and stores the uploaded file data, replacing the uploaded file data with one or more corresponding blob keys, then passes the rewritten request to the handler at the URL path you provided to create_upload_url(). This handler can do additional processing based on the blob key.

So it's difficult to say exactly what is going on without seeing your code, but I seriously doubt you can do what you are trying to achieve.

这篇关于NDB中的TextProperty字段获得“=”在每行之后附加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆