views:

186

answers:

1

I have a simple model object with

profilename = db.StringProperty()

and when I get a string with "Some More" and try to

put

it in model it throws exception

Property profilename is not multi-line

Is space equivalent to newline or I have missed something here? It is

put ting

for single word strings without spaces.

+3  A: 

The check's being done at application level, specifically in StringProperty.validate -- the code in question (which you can find in your SDK's sources in ext/db/init.py) is:

if not self.multiline and value and value.find('\n') != -1:
  raise BadValueError('Property %s is not multi-line' % self.name)

so there's no way it can be triggered unless a \n has indeed found its way into the value you're passing in. To help you debug the issue, use

logging.info('value is: %r', value)

just before the put that's giving you problems -- what do you see in the logs as a result? The %r format specifier shows the repr of your string, so you'll be able to observe where's the pesky \n that shouldn't ever be there, and, from that info, debug the issue.

Alex Martelli
strangely if I change stringproperty attribute multiline=true it does not complain. Thx for the input though, I will check again and see.
dhaval
@dhaval, of course it won't complain about newlines for a multiline string property -- that's what it being multiline is _about_;-).
Alex Martelli