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

Add setitem, delitem to Field #290

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

dourvaris
Copy link
Contributor

Just for syntax sugar so you can del(form['something']) or for multi part forms:

try:
    appstruct = form['section'].validate_pstruct(pstruct['section'])
exceptValidationFailure as e:
    form['something'] = e.field
    return form.render()

   field['name'] = Field()
   del(field['name'])
@miohtama
Copy link
Contributor

miohtama commented Jun 2, 2016

Thank you for your pull request.

I am the new Deform project maintainer. I apologize the issue of this pull request not being commented earlier. Deform project is again under activate maintenance.

This is issue tracker / pull request clean to prepare a new release.

I am willing to merge this pull request. However to maintain the high standard of documentation in Pylons project I hope if you can cover this feature

  • In API documentation or narrative documentation
  • With the use case example why to use this and how to use

... and we are good to go!

As I am not the author of this feature or do not have prior discussion about the feature, I cannot document or communicate how it should be used.

If this is an abandon pull request and there is no new feedback I will close this pull request in 30 days.

@miohtama
Copy link
Contributor

miohtama commented Nov 19, 2016

Ping. Still interested to champion still pull request. If not I'll consider closing it.

@dourvaris
Copy link
Contributor Author

It should already be documented in the API via the docstrings - is the api.rst not autogenerated?

@miohtama
Copy link
Contributor

miohtama commented Jan 31, 2017

Can you please add a documentation (either docstring or narrative)

  • This is the use case and this is why you want to do this

  • This is how you use it, with a code example

A good example is like one in the comment of this pull request, with little bit more background story, but it belongs to documentation not to the Github.

This is more to advertise the feature that people find it and know "hey I can do even this with Deform."

@stevepiercy
Copy link
Member

Hi @dourvaris, I've taken on the role of maintainer of Deform. I'd like to follow up on this PR and merge for release.

First if you have not already done so, would you please sign https://github.com/Pylons/deform/blob/master/CONTRIBUTORS.txt? I did not see your name in there.

Second, can you verify my understanding of this PR as follows? I would add this to the Deform narrative documentation.

Add to Common Needs

Given a declared Colander Schema and its creation:

class Person(colander.MappingSchema):
    name = colander.SchemaNode(colander.String())
    age = colander.SchemaNode(colander.Integer(),
                              validator=colander.Range(0, 200))

schema = Person()

You can set (add) or delete a Colander schema node as follows.

schema.__setitem__("eye_color")
schema.__delitem__("eye_color")

For convenience this PR implements these methods from Colander, but instead on the Deform form object, as follows.

set(form["eye_color"])
del(form["eye_color"])

Finally, if it is not too much trouble, would you please rebase your PR on the master branch and push those changes?

I look forward to your response. Thank you!

@stevepiercy stevepiercy modified the milestones: 3.1.0, 3.0.0 Aug 23, 2020
Base automatically changed from master to main January 19, 2021 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants