GAE repeat structured properties with nested repeating structured properties

I get this error using NDB in google and python engine: can't repeat StructuredProperty No, which has duplicate properties.

This is "No" because I get an error in the process of creating a new empty character, so I can fill in the properties after creation.

I assume that I do not like that I want my “Symbol” entity to have a “weaponList” property, which is repeated and structured with another “Weapon” object, which also has a repeating structured property that also contains the “curse” entity.

Being on my 5th or so week in Udacity cs253 with Steve Huffman, I think I know enough to be dangerous, so I thought I would confirm that this is a problem and hopefully get a better solution that will achieve my goals .

Basically, I am creating a character management system Dungeons and Dragons-ish, which has some functions for updating real-time messages and characters in GM / player, which I thought would be useful for the growing number of google + RPG players. I have a list of weapons, items, curses and magical effects as separate objects, so I can mix them at will.

Weapons and objects can have any number of curses or good magical effects. Characters can have any number of weapons, yadda yadda. First, I thought that keeping a list of entity keys would be a way. Then I thought that I would have to individually obtain each weapon from the database, and each curse for each weapon ... it seemed like an inefficient way to do this.

In addition, players and GM like to customize things, and it does not lend itself to this. So he hit me, I can have a list of standard materials in one table, and when you “add” it to a symbol, it is copied specifically for that symbol in a repeating structured property, and you can configure hell it doesn’t affect anyone else. or without me doing any extra work.

, , - , , . ?

+3
2

:

StructuredProperty , StructuredProperty StructuredProperty, : , , . LocalStructuredProperty, ( ).

+6

-. - LocalStructureProperty. , ( Google ) , , . , , , , , "". LocalStructuredProperties , . ( ) , - localStructuredProperty , .

, , , NDB json

.

class Character(ndb.Model):
    name = stringProperty()
    weaponList = StructuredProperty(WeaponModel.Weapon, repeated=True)

class WeaponModel(ndb.Model):
    name = stringProperty()
    curseList = StructuredProperty(BufferModel.Curse, repeated=True)

class BufferModel(ndb.Model):
    name = stringProperty()

, : StructuredProperty , .

.

1) datastore db ( ndb) List

weaponList = ListProperty (WeaponModel.Weapon)// , ,

, Listproperty (, , ), . .

weaponList = ListProperty (db.key)

. , , - , - public private.

. - , - - json NDB?

- :

aCurse = getcurse
aJsonCurse = json.dump(aCurse)
aWeapon = getWeapon(curseList=[aJsonCurse])
aJsonWeapon = json.dump(aWeapon)


aCharacter.weaponList = [aJsonWeapon]

. json, json, json . , -, , .

, , . LocalStructured , , , , , - . , , - , .

, .

+3

All Articles