def add(self, *args, **kwargs):
assert self.resp is None, "<STR_LIT>"<EOL>entity, av_pairs, args = None, [], list(args)<EOL>if len(args):<EOL><INDENT>if isinstance(args[<NUM_LIT:0>], int): <EOL><INDENT>"<STR_LIT>"<EOL>entity = E(args[<NUM_LIT:0>], tx=self)<EOL><DEDENT>elif isinstance(args[<NUM_LIT:0>], E):<EOL><INDENT>"<STR_LIT>"<EOL>if args[<NUM_LIT:0>]._tx is self:<EOL><INDENT>entity  = args[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>if int(args[<NUM_LIT:0>]) > <NUM_LIT:0>:<EOL><INDENT>"<STR_LIT>"<EOL>entity = E(int(args[<NUM_LIT:0>]), tx=self)<EOL><DEDENT>args[<NUM_LIT:0>] = None<EOL><DEDENT><DEDENT>"<STR_LIT>"<EOL>if entity is not None or args[<NUM_LIT:0>] in (None, False, <NUM_LIT:0>):<EOL><INDENT>v = args.pop(<NUM_LIT:0>)<EOL><DEDENT><DEDENT>"<STR_LIT>"<EOL>if entity is None:<EOL><INDENT>entity       = E(self.ctmpid, tx=self)<EOL>self.ctmpid -= <NUM_LIT:1><EOL><DEDENT>"<STR_LIT>"<EOL>if len(args) == <NUM_LIT:0> and kwargs: <EOL><INDENT>for a,v in kwargs.items():<EOL><INDENT>self.addeav(entity, a, v)<EOL><DEDENT><DEDENT>"<STR_LIT>"<EOL>if len(args):<EOL><INDENT>assert len(args) % <NUM_LIT:2> == <NUM_LIT:0>, "<STR_LIT>" % args<EOL>for first, second in pairwise(args):<EOL><INDENT>if not first.startswith('<STR_LIT::>'): <EOL><INDENT>first = '<STR_LIT::>' + first<EOL><DEDENT>if not first.endswith('<STR_LIT:/>'):<EOL><INDENT>"<STR_LIT>"<EOL>if isinstance(second, list):<EOL><INDENT>for v in second:<EOL><INDENT>self.addeav(entity, first, v)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.addeav(entity, first, second)<EOL><DEDENT>continue<EOL><DEDENT>elif isinstance(second, dict):<EOL><INDENT>"<STR_LIT>"<EOL>for a,v in second.items():<EOL><INDENT>self.addeav(entity, "<STR_LIT>" % (first, a), v)<EOL>continue<EOL><DEDENT><DEDENT>elif isinstance(second, (list, tuple)):<EOL><INDENT>"<STR_LIT>"<EOL>for a,v in pairwise(second):<EOL><INDENT>self.addeav(entity, "<STR_LIT>" % (first, a), v)<EOL>continue<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" % (first,second))<EOL><DEDENT><DEDENT><DEDENT>"<STR_LIT>"<EOL>return entity<EOL>
Accumulate datums for the transaction

        Start a transaction on an existing db connection
        >>> tx = TX(db)

        Get get an entity object with a tempid
        >>> ref = add()
        >>> ref = add(0)
        >>> ref = add(None)
        >>> ref = add(False)

        Entity id passed as first argument (int|long)
        >>> tx.add(1, 'thing/name', 'value')

        Shorthand form for multiple attributes sharing a root namespace
        >>> tx.add(':thing/', {'name':'value', 'tag':'value'})

        Attributes with a value of None are ignored
        >>> tx.add(':thing/ignored', None)

        Add multiple datums for an attribute with carinality:many
        >>> tx.add(':thing/color', ['red','white','blue'])