Performance: Leverage jinja2's Environment to cache compiled Templates.
This commit is contained in:
parent
3a82f089a2
commit
9affa7753d
30 changed files with 228 additions and 235 deletions
|
|
@ -1,6 +1,4 @@
|
|||
from __future__ import unicode_literals
|
||||
from jinja2 import Template
|
||||
|
||||
from moto.core.responses import BaseResponse
|
||||
from moto.ec2.utils import filters_from_querystring
|
||||
|
||||
|
|
@ -10,19 +8,19 @@ class Subnets(BaseResponse):
|
|||
vpc_id = self.querystring.get('VpcId')[0]
|
||||
cidr_block = self.querystring.get('CidrBlock')[0]
|
||||
subnet = self.ec2_backend.create_subnet(vpc_id, cidr_block)
|
||||
template = Template(CREATE_SUBNET_RESPONSE)
|
||||
template = self.response_template(CREATE_SUBNET_RESPONSE)
|
||||
return template.render(subnet=subnet)
|
||||
|
||||
def delete_subnet(self):
|
||||
subnet_id = self.querystring.get('SubnetId')[0]
|
||||
subnet = self.ec2_backend.delete_subnet(subnet_id)
|
||||
template = Template(DELETE_SUBNET_RESPONSE)
|
||||
template = self.response_template(DELETE_SUBNET_RESPONSE)
|
||||
return template.render(subnet=subnet)
|
||||
|
||||
def describe_subnets(self):
|
||||
filters = filters_from_querystring(self.querystring)
|
||||
subnets = self.ec2_backend.get_all_subnets(filters)
|
||||
template = Template(DESCRIBE_SUBNETS_RESPONSE)
|
||||
template = self.response_template(DESCRIBE_SUBNETS_RESPONSE)
|
||||
return template.render(subnets=subnets)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue