colander

How to convert a datetime from one arbitrary timezone to another arbitrary timezone

孤街醉人 提交于 2019-12-22 09:51:46
问题 Let's say I receive an arbitrary datetime object in a request, like this, which could be coming from any possible timezone - I don't know which one. For the sake of example, pretend it comes from the East Coast import pytz from colander import iso8601 ... ests1 = iso8601.parse_date('2016-04-01T00:00:00.0000-04:00') pretend ests1 is the object that comes in Using pytz, I can find out a bit about it's timezone etz = ests1.timetz() # 00:00:00-04:00 etzi = ests1.tzinfo # <FixedOffset '-04:00'

Deform/Colander validator that has access to all nodes?

限于喜欢 提交于 2019-12-21 10:32:10
问题 How do you define a custom validator in Deform/Colander that has access to all node values. I need to access the values from two fields in order to decide if a particular value is valid or not? 回答1: Here is an example of interfield validation. http://deformdemo.repoze.org/interfield/ 回答2: To place a validator for all colander fields we can simply do this validator method: def user_DoesExist(node,appstruct): if DBSession.query(User).filter_by(username=appstruct['username']).count() > 0: raise

How to convert a datetime from one arbitrary timezone to another arbitrary timezone

强颜欢笑 提交于 2019-12-05 21:44:27
Let's say I receive an arbitrary datetime object in a request, like this, which could be coming from any possible timezone - I don't know which one. For the sake of example, pretend it comes from the East Coast import pytz from colander import iso8601 ... ests1 = iso8601.parse_date('2016-04-01T00:00:00.0000-04:00') pretend ests1 is the object that comes in Using pytz, I can find out a bit about it's timezone etz = ests1.timetz() # 00:00:00-04:00 etzi = ests1.tzinfo # <FixedOffset '-04:00' datetime.timedelta(-1, 72000)> etzn = ests1.tzname() # '-04:00' # EST edst = ests1.dst() # '0:00:00' Note

Dependent/Cascading inputs using Deform

烈酒焚心 提交于 2019-12-02 03:49:16
问题 I'm trying to do a series of dependent inputs with Deform / Colander / Chameleon / Pyramid and can't find any examples. e.g. Dropdown of Country yields-> Dropdown of State or Province or Division ..etc.. yields-> Dropdown of County or City ... might yield-> Dropdown of City ... Can this be accomplished using Deform? (if it can't, should I look at an alternative form generating solution or go pure html/javascript/ajax/..?) I'm simplifying this to geographic divisions. I'd prefer to send only

Dependent/Cascading inputs using Deform

断了今生、忘了曾经 提交于 2019-12-01 23:35:01
I'm trying to do a series of dependent inputs with Deform / Colander / Chameleon / Pyramid and can't find any examples. e.g. Dropdown of Country yields-> Dropdown of State or Province or Division ..etc.. yields-> Dropdown of County or City ... might yield-> Dropdown of City ... Can this be accomplished using Deform? (if it can't, should I look at an alternative form generating solution or go pure html/javascript/ajax/..?) I'm simplifying this to geographic divisions. I'd prefer to send only the necessary part of the 12 million record database at the time the form is loaded and incrementally

Which one is the correct approach for form validation ? Colander's Schema validation or Deform's form validation?

梦想与她 提交于 2019-12-01 11:20:26
I have just started using Pyramid for one of my projects and I have a case where in I need to validate a form field input, by taking that form field value and making a web-service call to assert the value's correctness. Like for example there is a field called your bank's CUSTOMER-ID. I need to take that(alone) as input and validate at the server level by making a web-service call (like http://someotherdomain/validate_customer_id/?customer_id=<input_value> )lets say. I am using Colander for form schema management and Deform for all form validation logic. I am confused about where I need to

Which one is the correct approach for form validation ? Colander's Schema validation or Deform's form validation?

孤街醉人 提交于 2019-12-01 09:16:51
问题 I have just started using Pyramid for one of my projects and I have a case where in I need to validate a form field input, by taking that form field value and making a web-service call to assert the value's correctness. Like for example there is a field called your bank's CUSTOMER-ID. I need to take that(alone) as input and validate at the server level by making a web-service call (like http://someotherdomain/validate_customer_id/?customer_id=<input_value> )lets say. I am using Colander for