Comments (5)
{ "name": "Rule Name", "order": 999, "conditions": [ [ { "name": " Condition1 name", "if": "plugin", "operator": "=", "compare": "chat" }, { "operator": "AND", }, { "name": " Condition2 name", "if": "jsonData['zone']", "operator": "=", "compare": "2" } ], [ { "name": " Condition3 name", "if": "plugin", "operator": "=", "compare": "chat" }, { "operator": "OR", }, { "name": " Condition4 name", "if": "jsonData['zone']", "operator": ">", "compare": "2" } ] ] "then": "python code", "end": True }
from lisa.
Should work with something like this for the interface : http://www.youtube.com/watch?v=2VwHQUMu6fE
from lisa.
I will go without json document (only a string containing python code).
This will allow the user to code directly his rule in python.
I will need to parse the code to do a visual representation of the code. But can be implemented later.
from lisa.
Trying to understand the JSON example
The second example you give is ambiguous. The way I understand it is:
(Cond1 AND Cond 2) OR (Cond3 OR Cond4)
In this case the syntax would be a bit redundant. Do you need an explicit operator? Why not something like that?
{
"name": "Rule Name",
"order": 999,
"conditions": [
[
{
"name": " Condition1 name",
"if": "plugin",
"operator": "=",
"compare": "chat"
},
{
"name": " Condition2 name",
"if": "jsonData['zone']",
"operator": "=",
"compare": "2"
}
],
[
{
"name": " Condition3 name",
"if": "plugin",
"operator": "=",
"compare": "chat"
}
],
[
{
"name": " Condition4 name",
"if": "jsonData['zone']",
"operator": ">",
"compare": "2"
}
]
]
"then": "python code",
"end": True
}
This would represent the equivalent (OR is associative):
(Cond1 AND Cond2) OR Cond3 OR Cond4
A few remarks about it:
- why would you feed the numerical "compare" values as strings (
"2"
)? - I don't understand what the "end" property is about.
Beyond JSON
If you consider dropping the JSON representation for python, keep in mind the security implications this may have. Usually you don't want to give the user the ability to inject arbitrary code that will run through eval()
. And it's not worth the hassle trying to sanitize your output manually.
That being said, if you persist on having the python representation, maybe you can provide examples we could work with for prototyping?
I didn't have much more time to look into it today, but I have an idea of a simple prototype of a rule engine. I'll show you some more tomorrow. However my number one advice is to keep parsing to a minimum; you have python libraries that are thoroughly tested to deal with common formats like JSON or CSV, take advantage of them. Parsing can be a bitch...
from lisa.
This issue is a little old and your comment too, sorry for not replying earlier. We discussed about it in real life so I put a little bit informations here before closing this issue.
I will go with python code. Yes the user will be able to inject his own python code, playing with a jsonInput or a jsonOutput document.
But as not everyone know python, I will go with this project : https://code.google.com/p/blockly/.
Each plugin will provide his own blocks adding to those shipped by default with LISA.
The goal is to generate python for simple rule in a graphical way, but let advanced user writting directly their own python code.
There's a lot of work to do on this part, but it will be great I think !
Anyway thanks a lot @RahMu for your help/advices.
from lisa.
Related Issues (20)
- Improve the plugin system HOT 1
- Write Documentation HOT 2
- Dynamic cron timer
- LISA 1.1
- Create singleton for Task Scheduler
- Intent in json input
- Add the server version on the web interface
- Plugin API : sending notifications to a client HOT 1
- Create a singleton to handle the configuration file
- "zone" in JSON input and output HOT 1
- The json file is removed when installing a plugin HOT 3
- Create a version file HOT 1
- Use sockjs to replace autobahn HOT 1
- Translations on frontend
- Problem with Django 1.7 HOT 2
- accents
- microphone HOT 1
- lisa
- Re-write API with Django-REST
- http://www.lisa-project.net down HOT 2
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 lisa.