-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execution order of ZeroNet plugins #2128
Comments
I think it is right because it is going to check all the folders in the As far as I know this behavior is going to be modified as we are going to explicitly ask to activate plugins inside the config file. You might be able to specify the order then. |
Yes, but it would be better to also allow plugins themselves to define when they should be executed. So something like |
The plugins are loaded alphabetically, but if you subclass the same class multiple times, then the last will be called as it's overrides the previous function (then you can call the previous function using super()) There could be some cases where the order matters, but I think for domain resolver it should note be an issue. |
Do you have the source code of your plugin somewhere ? Maybe we can brainstorm to help you fix your problem. It might be an issue with the |
@HelloZeroNet @rllola There is an issue for my plugin. Plugin
I fixed this with also loading plugin on |
There is no much that we can do to help without your code. And like it was mention for domain name resolver it should not be a problem. Your problem is compatibility with the other |
Here is my plugin: ENS Because there are currently no ZeroNet ENS domains, I modified it for testing to return ZeroHello site address at domain Also, to use it you need to install my version of Web3.py which contains changes that are currently waiting to be merged into Web3.py. Also, you can install some missing Python wheels (if needed) from here. |
Hi, Sorry for the delay. Yeah I get your problem. It is indeed calling the Could you confirm I am one right track ? I am wondering could it be possible instead of creating a new plugin to integrate it to the |
An alternative solution would be to verify that path in |
Actually no need to do anything with https://github.com/HelloZeroNet/ZeroNet/blob/py3/plugins/Zeroname/SiteManagerPlugin.py#L38-L53 I will prepare a PR. And @filips123 you might want to add it too in your SiteManagerPlugin class. |
@rllola Thank you for that. Unfortunately, I will only be able to test this next Sunday, but you can also test this with code I provided.
What do you mean with that? Can you provide now details? Update: Do you mean that I should add the same change as your in my own plugin? |
I bet that's what they meant. |
Yeah. You can see the modification in the PR. It is so people won't have the same problem if we have another domain plugin. No problem. Take your time to test and let us know if it does fix your problem. Example of what you might need to add based on your code :
|
I have added a modification that should make it easier to create domain resolver plugins: 2bdd073 Example Ethname plugin: import re
from Plugin import PluginManager
@PluginManager.registerTo("SiteManager")
class SiteManagerPlugin(object):
# Return: True if the address is .bit domain
def isEthDomain(self, address):
return re.match(r"(.*?)([A-Za-z0-9_-]+\.eth)$", address)
# Resolve domain
# Return: The address or None
def resolveEthDomain(self, domain):
domains = {
"zerohello.eth": "1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D",
"zeroblog.eth": "1BLogC9LN4oPDcruNz3qo1ysa133E9AGg8"
}
return domains.get(domain)
# Turn domain into address
def resolveDomain(self, domain):
return self.resolveEthDomain(domain) or super(SiteManagerPlugin, self).resolveDomain(domain)
# Return: True if the address is domain
def isDomain(self, address):
return self.isEthDomain(address) or super(SiteManagerPlugin, self).isDomain(address) |
@HelloZeroNet My plugin now works with that fixes so I will close this issue. I will soon create PR for the plugin. |
@filips123 One question. Can you verify if it works without |
In which order do ZeroNet plugins execute when registering to core classes?
I tested this and it seems to be in reverse alphabetical order. Is that right?
Because of that, I have a problem with developing the ZeroNet plugin for Ethereum Name Service. It will be called
ENS
so it will be executed somewhere in the middle. This is a problem because plugins that are executed before it won't have resolved domain so they will probably crash. This isn't a problem for NameCoin plugin because it is calledZeroname
so it is executed first.Is it possible to fix this? A quick solution would be to rename my plugin to
ZeroENS
but there should be better handling of plugin order.There needs to be support to specify priority and execution order of plugins.
There need to be a few priority classes reserved for a specific type of plugin:
So I would recommend documenting those three priority classes (maybe more if needed) and represent them with numbers:
Here, the highest number would execute first. Plugins with the same number should be executed in reverse alphabetical order (as currently).
This would allow plugins to categorize into groups, but still allow exceptional plugins to be executed before or after majority or other plugins. Normal plugins should be using one of those three numbers but they would also be able to use other numbers if needed.
The text was updated successfully, but these errors were encountered: