[google-appengine] Unsupported operand type(s)

2009-04-08 Thread Mel T.

Hi,

I come from another language and framework world, thus I am new to
python and gae so please excuse my ignorance.

I get this error when I call a method I added to a db.Model derived
class:

c = Greeting.count + 1
TypeError: unsupported operand type(s) for +=: 'IntegerProperty'
and 'int'

To reproduce that, I simplified my problem to modifying the HelloWorld
Greetings application. I added this to the Greetings class:

  # add a count property to the model
  count = db.IntegerProperty(required=True)

  # add a function that uses the count
  def inc_count(self):
c = Greeting.count + 1


Then, in the sample code further down, in the class Guestbook,
function post(self), I replaced the first line (instantiation of a
Greeting) with this:

  greeting = Greeting(count=4)
  greeting.inc_count()

The call to greeting.inc_count() causes the error pasted above. Why is
that?

--
Mel T.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] unsupported operand type(s) for +=: 'NoneType' and 'int'

2008-10-02 Thread GMan

I am scratching my head at this seemingly simple problem.  All I want
to do is:
1) Take the value of a db.IntegerProperty
2) increment it using a local variable
3) Save the local variable back to the IntegerProperty

class IncrementHolder:
  counter = db.IntegerProperty()


class UserOfIncrementHolder:
   def doSomething(self):
  incrementQueryResult = IncrementHolder.all()  #assume there is
only one of these

  incrementHolderObj = incrementQueryResult.get()

  currCountValue = incrementHolderObj.counter

  currCountValue += 1  ## This is where the error occurs  !!

  incrementHolderObj.put()
 ...


On the error line, i have already tried the following
int(currCountValue)
without success.

What gives???

Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---