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

munge and compute seem identical in functionality #5

Open
mahmoudimus opened this issue Aug 16, 2014 · 1 comment
Open

munge and compute seem identical in functionality #5

mahmoudimus opened this issue Aug 16, 2014 · 1 comment
Assignees
Labels

Comments

@mahmoudimus
Copy link
Collaborator

Why are they two semantically different things?

@bninja bninja self-assigned this Aug 16, 2014
@bninja
Copy link
Owner

bninja commented Aug 17, 2014

they are 2 diff things, outline of mapping steps here: https://github.com/bninja/pilo/blob/master/pilo/fields.py#L214-219

compute by default resolves data from a src and parses it. you'll hook that if its computed in a diff way e.g. derived off of other fields.

munge typically does xforms on whatever was computed (e.g. lowcase, apply translation map, etc).

so u'd hook compute if you are altering how its base-line computed and munge if you just want to fiddle with what was computed.

but if easy to call default impl from hook then munge is probably not neccessary, e.g.

class Form(pilo.Form):

    f = pilo.fields.String()

    @f.compute
    def f(self)
        return f.compute().lower()

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

No branches or pull requests

2 participants