Is there anyway to force the pyramid registry to have one instance of 
itself or only of one reference of a signal object?

On Wednesday, November 14, 2018 at 10:42:15 AM UTC-6, 
[email protected] wrote:
>
> We are using pyramid for our insured portal at Unique Insurance.
> We have had great success with pyramid and still use it to this day!
> However we have hit a problem, when we use the pyramid.registry and 
> register an SOAP object to the registry object our server seems to block us 
> because we are making to many connections to the server.
> I have tried using a singleton, which I will try again today. Is there a 
> way in the registry to force it to only create one instance of the object?
>
>  
>
> from pyramid.config import Configurator
>
> from pyramid.authentication import AuthTktAuthenticationPolicy
> from pyramid.authorization import ACLAuthorizationPolicy
> import email.utils
>
> from pyramid.authentication import AuthTktAuthenticationPolicy
> from pyramid.authorization import ACLAuthorizationPolicy
>
> from pyramid.session import SignedCookieSessionFactory
> from sqlalchemy import engine_from_config
> from .models import DBSession, User 
> from .views.utils import email
> from .libpn import PN
> def main(global_config, **settings):
> """ This function returns a Pyramid WSGI application.
> """
> engine = engine_from_config(settings, 'sqlalchemy.')
> DBSession.configure(bind=engine)
>
> User.metadata.bind = engine
>
> authn_policy = AuthTktAuthenticationPolicy("REDACTED")
> authz_policy = ACLAuthorizationPolicy()
> my_session_factory = SignedCookieSessionFactory('REDACTED')
>
> config = Configurator(
> settings=settings,
> authentication_policy=authn_policy,
> authorization_policy=authz_policy,
> )
> config.set_session_factory(my_session_factory)
> config.registry.PN = PN(wsdl_cache_folder=settings['WSDL_CACHE_FOLDER'],
> wsdl_baseurl=settings['WSDL_BASEURL'],
> company_cache=settings['COMPANY_CACHE'])
>
> import logging
> log = logging.getLogger(__name__)
>
> from .pysimplesoap112.client import SoapClient as SoapClient112, 
> SoapFault as SoapFault112, SimpleXMLElement as SimpleXMLElement112
> import requests
> import datetime
> import csv
> import os
> import base64
> import traceback
> import boto3
> import time
> import dateutil.parser
> import pickle
> import io
> from .StaticDataManager import *
> # Set working folder
> workfolder=os.path.dirname(__file__)
> if workfolder:
> os.chdir(workfolder)
>
> class Client:
> def __init__(self):
> self.url = ""
> self.cache_path = ""
> self.client = ""
> def connect(self):
> self.client = SoapClient112(wsdl = self.url, cache = self.cache_path)
>
> class PN:
> def __init__(self, wsdl_cache_folder='', wsdl_baseurl='',
> esign_service_url = '', 
> company_cache=''):
> ts = time.time()
> self.security_token = None
> self.wsdl_cache_folder = wsdl_cache_folder
> self.wsdl_baseurl = wsdl_baseurl
> self.company_cache_filename = company_cache
>
> self.TransactionService = Client()
> self.TransactionService.url = self.wsdl_baseurl+'XXX.svc?wsdl'
> self.TransactionService.cache_path = os.path.join(self.wsdl_cache_folder,
> 'cache_transaction')
> self.TransactionService.connect()
>
> self.LoginService = Client()
> self.LoginService.url = self.wsdl_baseurl+'XXX.svc?wsdl'
> self.LoginService.cache_path = os.path.join(self.wsdl_cache_folder,'XXX')
> self.LoginService.connect()
>
> self.BillingService = Client()
> self.BillingService.url = self.wsdl_baseurl+'XXX.svc?wsdl'
> self.BillingService.cache_path = os.path.join(self.wsdl_cache_folder,'XXX'
> )
> self.BillingService.connect()
>
> self.PolicyService = Client()
> self.PolicyService.url = self.wsdl_baseurl+'XXX.svc?wsdl'
> self.PolicyService.cache_path = os.path.join(self.wsdl_cache_folder,'XXX')
> self.PolicyService.connect()
>
> self.NotesService = Client()
> self.NotesService.url = self.wsdl_baseurl+'XXX.svc?wsdl'
> self.NotesService.cache_path = os.path.join(self.wsdl_cache_folder,'XXX')
> self.NotesService.connect()
>
> self.ClaimsService = Client()
> self.ClaimsService.url = self.wsdl_baseurl+'XXX.svc?wsdl'
> self.ClaimsService.cache_path = os.path.join(self.wsdl_cache_folder,'XXX')
> self.ClaimsService.connect()
>
> self.PrintingService = Client()
> self.PrintingService.url = self.wsdl_baseurl+'XXX.svc?wsdl'
> self.PrintingService.cache_path = os.path.join(self.wsdl_cache_folder,'XXX
> ')
> self.PrintingService.connect()
>
> self.AdministrationService = Client()
> self.AdministrationService.url = self.wsdl_baseurl+'XXX.svc?wsdl'
> self.AdministrationService.cache_path = os.path.join(self
> .wsdl_cache_folder,'XXX')
> self.AdministrationService.connect()
> self.SecurityService = Client()
> self.SecurityService.url = self.wsdl_baseurl+'XXX.svc?wsdl'
> self.SecurityService.cache_path = os.path.join(self.wsdl_cache_folder,'XXX
> ')
> self.SecurityService.connect()
> self.ESignService = Client()
> self.ESignService.url esign_service_url
> self.ESignService.cache_path = os.path.join(self.wsdl_cache_folder,'XXX')
> self.ESignService.connect()
> te = time.time()
> with io.open("timings.log", "a+", encoding="utf-8") as f:
> f.write('%r %2.2f sec \n' % ('cache_file_load', te-ts))
> with io.open("timings.csv", "a+", encoding="utf-8") as f:
> f.write('%s %r, %2.2f \n' % (datetime.datetime.now(), 'cache_file_load', 
> te-ts))
>
>   
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/be2b960d-c58e-4dc2-89e0-77443810fe49%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to