3
message items {
    message require {
        optional bool require_sex = 1; //
        repeated int32 fate = 2 [packed = true];
    }
    optional int32 sub_type = 1;
    repeated int32 levels = 2 [packed = true];
}

I tried

raw.require.require_sex = 1
raw.require.fate.append(1)
raw.require.fate.extend([2,3])

got an error AttributeError: 'property' object has no attribute 'append'

but the first level repeated field works fine:

raw = down_pb2.items()
raw.levels.append(4)

is this kind of definition not supported?

davyzhang
  • 2,419
  • 3
  • 26
  • 34

1 Answers1

4

You need to create a field using that require type and then access that field in the code.

message items {
    message require {
        optional bool require_sex = 1; //
        repeated int32 fate = 2 [packed = true];
    }
    optional int32 sub_type = 1;
    repeated int32 levels = 2 [packed = true];
    required require sub = 3;
}

then

raw.sub.fate.append(1)
iny
  • 7,339
  • 3
  • 31
  • 36
  • Thanks so much for your answer, I really didn't noticed it's a TYPE not a variable. But the required limit is not really necessarily need here, optional can do the same thing here. Thanks again! – davyzhang Mar 02 '12 at 13:52