Create a better preferences/settings system #93

Open
opened 2026-10-05 03:58:33 +02:00 by adam · 5 comments
Owner

Once implemented, issue #158 along with full set/get for network preferences would be included in this implementation.

There should be some kind of list on CZNC, CUser, CIRCNetwork and CChan which include the values which can be set. *admin and *webadmin can be automatically generated from these values. These variable should be enclosed in some class such as CValue.

CValue will contain various virtual methods for checking if a string matches its type, descriptions, titles and any type of field to show in a webadmin. There can be various subclasses for specific types like strings, integers, etc.

Help will also be generated from these values.

Once this is implemented, there should be very little specific code to each "value". When adding new preferences, we should not need to add any code into *admin or *webadmin. There shouldn't be code added to the config read/write system either.

Extra points for allowing modules to use this system to close #125.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Once implemented, issue #158 along with full set/get for network preferences would be included in this implementation. There should be some kind of list on CZNC, CUser, CIRCNetwork and CChan which include the values which can be set. *admin and *webadmin can be automatically generated from these values. These variable should be enclosed in some class such as CValue. CValue will contain various virtual methods for checking if a string matches its type, descriptions, titles and any type of field to show in a webadmin. There can be various subclasses for specific types like strings, integers, etc. Help will also be generated from these values. Once this is implemented, there should be very little specific code to each "value". When adding new preferences, we should not need to add any code into *admin or *webadmin. There shouldn't be code added to the config read/write system either. Extra points for allowing modules to use this system to close #125. ## <bountysource-plugin> Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/671-create-a-better-preferences-settings-system?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github). </bountysource-plugin> <!-- github-sync-id:3977673 -->
Author
Owner

When adding new preferences, we should not need to add any code into *admin or *webadmin

Impossible. There can be specific settings, which would need additional stuff. For example, simple text setting "Timezone". But it also has a drop down list of available time zones...

> When adding new preferences, we should not need to add any code into *admin or *webadmin Impossible. There can be specific settings, which would need additional stuff. For example, simple text setting "Timezone". But it also has a drop down list of available time zones... <!-- github-comment-id:4967522 -->
Author
Owner

Not impossible, take a look at Django for example. There is a django admin application which can generate a complete admin interface from the ORM. We just need to provide a mechanism to have "choices" attached to the type of values.

https://docs.djangoproject.com/en/1.4/ref/contrib/admin/
https://docs.djangoproject.com/en/dev/ref/models/fields/#choices

Not impossible, take a look at Django for example. There is a django admin application which can generate a complete admin interface from the ORM. We just need to provide a mechanism to have "choices" attached to the type of values. ![](https://docs.djangoproject.com/en/1.4/_images/flatfiles_admin.png) https://docs.djangoproject.com/en/1.4/ref/contrib/admin/ https://docs.djangoproject.com/en/dev/ref/models/fields/#choices <!-- github-comment-id:5154189 -->
Author
Owner

In case of Timezone we need to provide "choices" mechanism, yeah. But what else mechanisms do we need to provide?
You can't really enumerate every such mechanism now, that you will satisfied with forever, without any modifications.

In case of Timezone we need to provide "choices" mechanism, yeah. But what else mechanisms do we need to provide? You can't really enumerate every such mechanism now, that you will satisfied with forever, without any modifications. <!-- github-comment-id:5155197 -->
Author
Owner

DarthGandalf, I believe you are over thinking this. the django admin is a great example. each field is a subclass of the generalized 'field' type. and each field subclass handles its own validation. so in your example, you would have a 'timezone' field subclass, which renders itself and validates its own input against whatever methods it needs. All the rest of the application needs to know is that it should call Value.validate() before saving anything. Each field type is also responsible for its own html elements (in django this is further abstracted into widgets, but that would be overkill in this case). So when rendering a webadmin form each field has a method called to return html for its own field.

DarthGandalf, I believe you are over thinking this. the django admin is a great example. each field is a subclass of the generalized 'field' type. and each field subclass handles its own validation. so in your example, you would have a 'timezone' field subclass, which renders itself and validates its own input against whatever methods it needs. All the rest of the application needs to know is that it should call Value.validate() before saving anything. Each field type is also responsible for its own html elements (in django this is further abstracted into widgets, but that would be overkill in this case). So when rendering a webadmin form each field has a method called to return html for its own field. <!-- github-comment-id:6318244 -->
Author
Owner

Hm, ok. Good then.

Hm, ok. Good then. <!-- github-comment-id:6318306 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#93