On Sunday, October 7, 2018 at 12:59:58 AM UTC-5, Michael Merickel wrote:
>
> This sounds like an application-global object. These are typically stored
> on the registry at config-time. For example, in your main you could set
> config.registry.foo = contract. The registry is available as
> request.registry and subsequently anything you add to it. You can see lots
> of examples of this in pyramid addons and things like the dbsession_factory
> in the alchemy cookiecutter.
>
Thank you.
I decided to add it at 1st run of the function:
try:
if not request.registry.mycontract:
request.registry.mycontract = Contract()
mycontract=copy.copy(request.registry.mycontract)
...
#rest of the code:
mycontract.add_user()
mycontract.update_terms()
*Sidenote:*
Is there a way to force this object to be "read only" or now allow
modification, to prevent somebody else in some other sections of the code
accidently modifies request.registry.mycontract?
**update run at 0.42755 sec now.
Thanks
Lucas
> On Sat, Oct 6, 2018 at 5:00 PM Lukasz Szybalski <[email protected]
> <javascript:>> wrote:
>
>> Hello,
>> I have an enterprise system that is creating a class but it takes a long
>> time to initiate. About 2 sec, 90K _setitem from pickle. Nothing to
>> profile, since OS cashes the file its as fast as it gets.
>>
>> I'm trying to find a way in pyramid where I can:
>>
>> #store below at start, of the process, let it initiate,
>> #then somehow make it read only,
>> #so that a process can use it later and modify its own copy
>>
>> from enterprise import Contract
>> my= Contract()
>>
>>
>> #rest of the program
>> my2 = copy my (or copy on write, similar how qcow format works)
>> my2.find_contract('abc')
>> my2.add_name('Lucas')
>> return (my2.stuff)
>>
>> I don't seem to be finding the right terminology, or technique to do
>> this, and where to place it in pyramid?
>>
>> Thanks
>> Lucas
>>
>> --
>> http://lucasmanual.com/ <http://lucasmanual.com/blog/>
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pylons-discuss/CAKkTUv3qgT%2BUk0-uvLB1owZEA3W%3D-7XA-wkiyZbteWHPAcO6vg%40mail.gmail.com
>>
>> <https://groups.google.com/d/msgid/pylons-discuss/CAKkTUv3qgT%2BUk0-uvLB1owZEA3W%3D-7XA-wkiyZbteWHPAcO6vg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
--
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/6590645a-7af6-480a-a866-ab1af78e0d42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.