Comments (5)
go for it.
from anvil-extras.
Maybe there's a way to do it without the need to know the form in advance
Pseudo code:
# Some Form class
from anvil_extras import FormItemListener
class ItemTemplate(ItemTemplateTemplate):
def __init__(self, **properties):
FormItemListener.init(self)
# FormItemListener
_classes = set()
def _item_override(cls):
base_item = super(cls, cls).item
def item_getter(self):
return base_item.__get__(self, cls)
def item_setter(self, item):
item = _cls_for_refreshing_item(item)
item._form = self
base_item.__set__(self, item)
return property(item_getter, item_setter)
def init(form):
cls = type(form)
if cls in _classes:
return
else:
cls.item = _item_override(cls)
_classes.add(cls)
_dict_setitem = dict.__setitem__ # save an attribute lookup on each call to __setitem__
class _D(dict):
def __setitem__(self, key, value):
_dict_setitem(self, key, value)
form = getattr(self, '_form', None)
if form is not None:
form.refresh_data_bindings()
_cls_for_refreshing_item = _D
proof of concept:
https://anvil.works/build#clone:RVJVNFVQDKC6IWLH=DS7FRFDKYMHUPUIN7K5HCNIW
from anvil-extras.
In the proof of concept i've suggest 3 possible apis
# Some Form class
from anvil_extras import FormItemListener
class ItemTemplate(ItemTemplateTemplate):
def __init__(self, **properties):
FormItemListener.init(self)
# Some Form class
from anvil_extras import FormItemListener
class ItemTemplate(FormItemListener.BaseClass, ItemTemplateTemplate):
# Some Form class
from anvil_extras import FormItemListener
class ItemTemplate(ItemTemplateTemplate):
...
FormItemListener.init_class(ItemTemplate) # or equivalent decorator
I think option 1 or 3 are best...
from anvil-extras.
Excellent! I went to bed last night thinking there must be a way to do this with a decorator on the Form class and I wake up to find the code for that has magically appeared!
from anvil-extras.
I'm happy to pick this up from here (but also happy for you to carry on if you prefer).
from anvil-extras.
Related Issues (20)
- Anvil_extras Routing library issue "ExternalError: TypeError: Cannot assign to read only property 'in$repr' of object '[object Object]'" HOT 3
- Mulitselect not firing after changing enabled Status via code HOT 1
- AttributeError: 'MultiSelectDropDown' object has no attribute '_menu_shown' HOT 2
- `self.url_dict` not upated after `routing.set_url_hash(redirect=False)` HOT 1
- NotFoundError raised by Autocomplete()._on_hide
- Any interest in adding my native date/time picker component? HOT 2
- Support foreground (and background) property for MultiSelectDropdown HOT 1
- Make Authorisation module more reusable HOT 2
- Make Navigation module aware of Authorisation module HOT 2
- Any way to fix Quill translate problem? HOT 17
- Autocomplete accept list of tuples (<displayed>,<returned>) HOT 2
- Allow items alias for multi-select box
- Out of date docs/bug in the persistance module HOT 1
- Request for Anvil Extras - Tabs: individually colored tabs HOT 2
- Autocomplete Suggestion Box Cover's Text Box on Mobile HOT 8
- MultiSelectDropDown drops an error message when starting app. HOT 2
- [Tabs] Not showing correctly when overflowing HOT 1
- Routing not working in provided example HOT 3
- Popover Not Working on Disabled TextBox Components HOT 1
- Set the height of a progress bar
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anvil-extras.