517 rql, qargs, pendingrels, attrcache = cls._cw_build_entity_query(kwargs) |
517 rql, qargs, pendingrels, attrcache = cls._cw_build_entity_query(kwargs) |
518 if rql: |
518 if rql: |
519 rql = 'INSERT %s X: %s' % (cls.__regid__, rql) |
519 rql = 'INSERT %s X: %s' % (cls.__regid__, rql) |
520 else: |
520 else: |
521 rql = 'INSERT %s X' % (cls.__regid__) |
521 rql = 'INSERT %s X' % (cls.__regid__) |
522 created = execute(rql, qargs).get_entity(0, 0) |
522 try: |
|
523 created = execute(rql, qargs).get_entity(0, 0) |
|
524 except IndexError: |
|
525 raise Exception('could not create a %r with %r (%r)' % |
|
526 (cls.__regid__, rql, qargs)) |
523 created._cw_update_attr_cache(attrcache) |
527 created._cw_update_attr_cache(attrcache) |
524 cls._cw_handle_pending_relations(created.eid, pendingrels, execute) |
528 cls._cw_handle_pending_relations(created.eid, pendingrels, execute) |
525 return created |
529 return created |
526 |
530 |
527 def __init__(self, req, rset=None, row=None, col=0): |
531 def __init__(self, req, rset=None, row=None, col=0): |