Title: Suggestion: Allow lambdas/functions in if_missing values for up-to-date values · Issue #118 · formencode/formencode · GitHub
Open Graph Title: Suggestion: Allow lambdas/functions in if_missing values for up-to-date values · Issue #118 · formencode/formencode
X Title: Suggestion: Allow lambdas/functions in if_missing values for up-to-date values · Issue #118 · formencode/formencode
Description: I have a validator that converts a javascript timestamp into a python datetime object. If the value I send in for the timestamp is missing, I want the value to be set to the most recent date using datetime's utcnow() method. However, if ...
Open Graph Description: I have a validator that converts a javascript timestamp into a python datetime object. If the value I send in for the timestamp is missing, I want the value to be set to the most recent date using ...
X Description: I have a validator that converts a javascript timestamp into a python datetime object. If the value I send in for the timestamp is missing, I want the value to be set to the most recent date using ...
Opengraph URL: https://github.com/formencode/formencode/issues/118
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Suggestion: Allow lambdas/functions in if_missing values for up-to-date values","articleBody":"I have a validator that converts a javascript timestamp into a python datetime object. If the value I send in for the timestamp is missing, I want the value to be set to the most recent date using datetime's `utcnow()` method. However, if I assign the Schema's `if_missing` value to `utcnow()`, the date does not refresh when `to_python()` is called.\n\nMy code that has issues is this:\n\n```\nfrom formencode import Schema, All\nfrom myvalidator import MyValidator\nfrom datetime import datetime as dt\n\nclass MySchema(Schema):\n filter_extra_fields = True\n allow_extra_fields = True\n # start_date = MyValidator(if_missing=lambda: dt.utcnow()) # Doesn't work\n start_date = MyValidator(if_missing=dt.utcnow()) # Date, once read, does not change\n```\n\nWhat are your thoughts and if it is something you'd want, would you accept a pull request if I wrote that functionality?\n\nMuch appreciated.\n","author":{"url":"https://github.com/NucleaPeon","@type":"Person","name":"NucleaPeon"},"datePublished":"2016-09-12T10:26:38Z","url":"https://github.com/formencode/formencode/issues/118"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:eb190f27-6cbb-e8f1-5479-26dbd65278cb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 943C:2BF270:5CC8AE:82F5CE:6B045F85 |
| html-safe-nonce | bbcf890ff67d50ae31fc9d19478a1d0c3006d12a68da0a3640768e9237edb230 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDNDOjJCRjI3MDo1Q0M4QUU6ODJGNUNFOjZCMDQ1Rjg1IiwidmlzaXRvcl9pZCI6Ijc1NTE5NDE4Njk5NTQxNjI1NjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cace7f8d53de501fbe4db75a3d278e1a0d4bc9f04b3f14a0804e2a3b653b4197 |
| hovercard-subject-tag | issue:176342424 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/formencode/formencode/118/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d3200f91c1d326ad7246e20f902f9059841890846181b07a97668a26a690c86f/formencode/formencode/issues/118 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d3200f91c1d326ad7246e20f902f9059841890846181b07a97668a26a690c86f/formencode/formencode/issues/118 |
| og:image:alt | I have a validator that converts a javascript timestamp into a python datetime object. If the value I send in for the timestamp is missing, I want the value to be set to the most recent date using ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NucleaPeon |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6 |
| turbo-cache-control | no-preview |
| go-import | github.com/formencode/formencode git https://github.com/formencode/formencode.git |
| octolytics-dimension-user_id | 1541742 |
| octolytics-dimension-user_login | formencode |
| octolytics-dimension-repository_id | 3733133 |
| octolytics-dimension-repository_nwo | formencode/formencode |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3733133 |
| octolytics-dimension-repository_network_root_nwo | formencode/formencode |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 03e114520787ad27289207f153520ef97461127c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width