plomino / Plomino

Powerful and flexible web-based application builder
33 stars 37 forks source link

not easy to share code between formulas #726

Open djay opened 8 years ago

djay commented 8 years ago

User problem

Sometimes you want share methods, values and other things between formulas inside a form, or between fields and a form, or between forms. The include system is very clumsy with having create the methods, and how its not obvious that you have to resave any formula to include changes to the include file. You can't use mechanisms like classes to structure your code, or wrap documents to make them easier to use for a particular app. When an app gets bigger the code gets spread around.

Options

single .py per form + imports

hook into import so we can import other forms like

from MyFormB import fieldB_validation

def fieldA_validation(doc):
   return fieldB_validation(doc)

similar to the python via in https://github.com/plomino/Plomino/issues/618. This would also allow arbitrary classes or functions to exist in that file as the developer wishes.

so if you wanted to create a convenience wrapper class you could do it like


class BookStoreModel(object):
   def __init__(self, doc)
      self.doc = doc
  def findBookByAuthor(title):
      ...

def fieldA_validation(doc):
   m = Model(document, ‘jimmysbookstorebook’); 
   if m.findBookByAuthor(x): 
      return False

single .py per DB. Forms as classes.

djay commented 8 years ago

would likely superseded https://github.com/plomino/Plomino/issues/386 which deals with a single python file per form as an import/export format. If the above is implemented, the import/export format should be made as close as possible.

djay commented 8 years ago

@ebrehault I think "single .py per form + imports" is the way to go here. I'm guessing since the code already exists for rapido this would not be too hard?

djay commented 8 years ago

@ebrehault We'd like to work on improving the import format since json is pretty much unworkable for filesystem development. @displacedaussie

What I propose is this

djay commented 8 years ago

@ebrehault I guess my questions are, do you agree this is the right way to go, and if so, how does this work in with the timeline for the IDE?

ebrehault commented 8 years ago

I agree it is the way to go. I am about to merge IDE in master (as an experimental feature), the IDE hasn't impacted the way formulas are stored, but it can be adapted easily to the changes you described.