TextProperty field in NDB gets “=” appended after

2019-08-04 13:20发布

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 ?

2条回答
疯言疯语
2楼-- · 2019-08-04 13:56

I've also had the same problem,

I solved it in a way that isn't elegant, but functional:

I did a replace on the input;

here is the code

input_html_text = unicode(self.request.get('text')).replace('=\r\n', '')
查看更多
爷的心禁止访问
3楼-- · 2019-08-04 13:59

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.

查看更多
登录 后发表回答