473,602 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Zope + Python thread safety

Hello !

I have been created a Zope (Python) Product.
But it is must store inner global definitions (some conversion
parameters), what I need to change in only one thread, or only once.

See below.

So: because the Zope is threaded application, the threads are use this
product. Possible in same time.

Question: the python variable setting/checking is thread-safe ?

In Delphi, or C, with threaded application I must acquire/release a lock, when I
check/set/read any variable (except integer), like this (pseudo):

lock=Lock
func ReadVar():strin g;
lock.Enter;
try
Result:=GlobalV ar;
finally
lock.Leave;
end;

proc WriteVar(val:st ring);
lock.Enter;
try
GlobalVar:=val;
finally
lock.Leave;
end;

This way is make the variable using thread-safe, because avoid to
thread A read while thread B is write (and subsections of the
information are confusing by another thread).

My code in python:

A. version)

def __init__(self):
self.Fmts=[['date','%m/%d/%Y'],['time','%H:%M.% S']]
# default is for hungarian

def SetConversionFo rmats(self,Fmts ):
s1=str(Fmts)
s2=str(self.Fmt s)
if (s1<>s2)):
self.Fmts=Fmts

B. version)

def __init__(self):
self.DefFmts=[['date','%Y.%m.% d'],['time','%H:%M.% S']]
# default is for hungarian
self.Fmts=None

def SetConversionFo rmats(self,Fmts ):
if self.Fmts==None : self.Fmts=Fmts
Usage:
updsqlobj=conte xt.updsqlobj()
updsqlobj.SetCo nversionFormats ([['date','%Y.%m.% d'],['time','%H:%M.% S']],True)
updsqlobj.Gener ateUpdateSQL(.. )
updsqlobj.Apply (..)

The Fmts is a list.

I want to set the parameters of Product in only once, but because the
Zope is threaded app, I must thinking in thread-safe programming methods.

Question1:
The code above is thread safe ? (I think, it is not)
Question2:
If it is not thread safe, how to set this variable without global
lock/mutex object ?
Question3:
Or how to I set this object's parameters as property, in Designer
interface of Zope ?

Please help me, if possible !

Thanx for it, and for every advance:

--
Best regards,
fowlertrainer mailto:fo****** *****@anonym.hu
Jul 18 '05 #1
0 1317

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1511
by: Gilles Lenfant | last post by:
Hi, I didn't receive anything from the various Zope mailing lists I should receive. zope@zope.org zope-cmf@zope.org zope-dev@zope.org Other subscribers can confirm or have I got problems ?
27
1996
by: Michele Simionato | last post by:
> Hello, my name is Skip and I am metaclass-unaware. I've been programming in > Python for about ten years and I have yet to write a metaclass. At first I > thought it was just that metaclasses were new to the language, but now as > more and more people use them and proclaim their widespread benefits, I have > come to realize that through years of abuse my brain has become addicted to > classic classes. I began using Python since...
4
2334
by: Jochen Demuth | last post by:
Hi, I am trying to install ZWiki on Zope 2.5.1 / Debian 2.4.20-bf2.4-xfs. First I copied the contents of the ZWiki-0.32.0.tgz to the Products-directory under SOFTWARE_HOME: This is what it contained before: server1:/usr/lib/zope/lib/python/Products# ls ExternalMethod PageTemplates StandardCacheManagers ZSQLMethods Hotfix_2002-06-14 PluginIndexes TemporaryFolder ZopeTutorial
5
2263
by: jsmilan | last post by:
Hi, all; I'm strictly an amateur developer who has dabbled in a half dozen languages on eight or nine systems over 20 years or so. I have never devoted the time or energy to thoroughly learn any one of them, so I have become a true JOATAMON (Jack Of All Trades And Master Of None). I apologize in advance for any truly newb sounding questions. I did Google for this in several places first (Zope.org, Gentoo forums, and Google UseNet...
4
1553
by: Carl | last post by:
Using COM and ADO on Win32, it is very easy to access databases (eg MySql, MS SQL Server, etc) from Python. Does anybody know if it is possible to access databases from Zope (which is written in Python) using COM and ADO? Carl
47
2585
by: Will Stuyvesant | last post by:
Hello all, So Zope still lives, yay. Well, I like that they use Python. <rant> What amazed me is they write that they "added types to the variables and hope that it will be added to the Python project too". Really. ROFL.
21
1591
by: godwin | last post by:
Hi all, I wanna thank Martin for helping out with my ignorance concerning execution of stored procedure with python. Now i have decided to write a web app that googles into my companies proprietary database. I need to know whether zope is good for that job. But even the introduction to zope in the zope book was intimidating. Are there any simple options? If so plz tell me how i can obtain it and study it. I should say that i am new to web...
3
2606
by: krzychu | last post by:
Hi, I have installed brand new platform - Zope-2-7-6, Python 2.4.1, Plone 2.0.5, OS Debian 1:3.3.6-2. After import a old Plone site from the following platform Zope-2-7-4, Python 2.3.3, Plone 2.0.3 to the new one, I get error when I visit PuthonScript in the ZMI. "invalid syntax (Script (Python), line 1)"
0
7921
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8405
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8270
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1511
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1256
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.