@@ -176,31 +176,33 @@ def not_inside(self, rhs):
176
176
raise Exception ("Unsupported 'not_inside' argument of type " + str (type (rhs )))
177
177
178
178
def __getattr__ (self , name ):
179
- ret = None
180
- em = object .__getattribute__ (self , "em" )
181
- fm_t = Expr2FieldTypeVisitor ().fieldtype (em )
182
-
183
- # This pops 'this expr' off the stack, so we can
184
- # replace it with an extended expression
185
- pop_expr ()
186
-
187
- if fm_t is not None :
188
- if name in fm_t .field_id_m .keys ():
189
- idx = fm_t .field_id_m [name ]
190
- ret = expr (ExprIndexedFieldRefModel (em , [idx ]))
191
- else :
192
- raise Exception ("Field %s not in type %s" % (name , fm_t .name ))
179
+ if not expr_mode ():
180
+ return object .__getattribute__ (self , name )
193
181
else :
194
- fm = Expr2FieldVisitor ().field (em )
182
+ ret = None
183
+ em = object .__getattribute__ (self , "em" )
184
+ fm_t = Expr2FieldTypeVisitor ().fieldtype (em )
195
185
196
- if name in fm .field_id_m .keys ():
197
- idx = fm .field_id_m [name ]
198
- ret = expr (ExprIndexedFieldRefModel (em , [idx ]))
186
+ # This pops 'this expr' off the stack, so we can
187
+ # replace it with an extended expression
188
+ pop_expr ()
189
+
190
+ if fm_t is not None :
191
+ if name in fm_t .field_id_m .keys ():
192
+ idx = fm_t .field_id_m [name ]
193
+ ret = expr (ExprIndexedFieldRefModel (em , [idx ]))
194
+ else :
195
+ raise Exception ("Field %s not in type %s" % (name , fm_t .name ))
199
196
else :
200
- raise Exception ("Composite %s does not contain a field \" %s\" " % (
201
- fm .name , name ))
197
+ fm = Expr2FieldVisitor ().field (em )
202
198
203
- return ret
199
+ if name in fm .field_id_m .keys ():
200
+ idx = fm .field_id_m [name ]
201
+ ret = expr (ExprIndexedFieldRefModel (em , [idx ]))
202
+ else :
203
+ raise Exception ("Composite %s does not contain a field \" %s\" " % (
204
+ fm .name , name ))
205
+ return ret
204
206
205
207
def __getitem__ (self , k ):
206
208
if is_expr_mode ():
@@ -859,15 +861,16 @@ def _id_fields(self, it, parent):
859
861
860
862
fid = 0
861
863
for fn in dir (it ):
862
- fo = getattr (it , fn )
863
- if hasattr (fo , "_int_field_info" ):
864
- fi = fo ._int_field_info
865
- fi .id = fid
866
- fi .parent = it ._int_field_info
867
- fid += 1
864
+ if not fn .startswith ("__" ) and fn not in ("sum" ,"product" ,"size" ):
865
+ fo = getattr (it , fn )
866
+ if hasattr (fo , "_int_field_info" ):
867
+ fi = fo ._int_field_info
868
+ fi .id = fid
869
+ fi .parent = it ._int_field_info
870
+ fid += 1
868
871
869
- if fi .is_composite :
870
- self ._id_fields (fo , fi )
872
+ if fi .is_composite :
873
+ self ._id_fields (fo , fi )
871
874
872
875
def get_model (self ):
873
876
if self ._int_field_info .model is None :
0 commit comments