Skip to content
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

Change table rule conditions' syntax #22

Open
antisvin opened this issue Apr 26, 2015 · 3 comments
Open

Change table rule conditions' syntax #22

antisvin opened this issue Apr 26, 2015 · 3 comments
Assignees

Comments

@antisvin
Copy link
Collaborator

We should allow to specify conditions in a more natural form, i.e. right now conditions have to be given as key__op : value but I would prefer key op value:

if:
   - key == 5
   - key > 5
   - key <= 5
   #etc.

The generic format would be:
attr1.[...].attrN [op value]

If [op value] is ommitted, this is equivalent to specifying [== True]

Currently operators that are supported are:

  • bool conversion
  • comparison
  • string operators (contains/icontains)

Key supports lookup for:

  • attr
  • dictionary

Also, I think we should emulate django templates' behavior an call attrs if they are callable. This means that we'll have support for simple function calls (with no arguments). Actually passing parameters can't be expressed in the C-exp bit specification, so it would require a substantial rewrite.

@antisvin antisvin self-assigned this Apr 26, 2015
@miraculixx
Copy link
Owner

👍 This is great. Thanks.

Actually passing parameters can't be expressed in the C-exp bit specification, so it would require a substantial rewrite.

how about my earlier proposal, along the lines of C(funcname__fn=args)?

@antisvin
Copy link
Collaborator Author

But we need to have results on the right, so we can't have args there. To be more specific, let's look for a way to define math.sqrt(foo) > 2. I don't think this can be done elegantly.

I have an idea that can work, will open a separate issue - don't want to derail discussion for this one.

@antisvin
Copy link
Collaborator Author

Written proposal in #23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants