anvil.LiveObjectProxy

Is there a SIMPLE and QUICK way to append/remove items from an anvil.LiveObjectProxy?

If this is a multiple-link column, then this may help:

Awesome, was able to get that to work. Is there a way to add the item to the front of the list?

Well, consider how you might construct such a list in everyday Python.

If x is a list, how would you construct a new list with 7 at the head of it?

Lists can be joined, so I’d be inclined to try [ 7 ] + x.

Ok, I had tried that, but wasn’t having luck. Had to convert the live object list to a list() in order to make that work.

def update_items(items, item, add=True, insert=True):
  if add:
    item = anvil.server.call('add_item', item)
    print(f"Add: {item}")
    if insert:
      items = [item] + list(items) # CONVERT THE ITEMS TO A LIST()
    else:
      items += [item]
  else:
    print(f"Remove: {item}")
    item = anvil.server.call('remove_item', item)
    items = [r for r in items if r != item]
      
  _items = items
  return _items

Now it is working well. Trying to find a fast way to refresh repeating panels and such.

Thanks for the help!

1 Like