473,322 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

managing properties/configurations

Hi,

Am sure many would have stumbled on this situation while developing an
application in Python which is highly driven by configuration/
properties.

I have an application (obviously written in Python) wherein the
properties change frequently and the program needs to work according
to the new rules. Since , python is scripting language the idea of a
Properties file(analogous to Java) doesnt make sense to me. However,
at the same time i am looking for some mechanism by which the hot-
patches(i.e, properties can be changed) can be applied easily.

Since the patches(mostly properties change) will be mostly be done by
non-programmers, i do not want them to touch the Py codes,but at the
same time alter the behaviour suitably.(Kindly avoid the advice to
teach Python to the non-programmers :D ).

The following is a *very simple example* of the case wherein the
properties(namely 10,30,31,40) are 'hardcoded' - i want this to be
'away' from the code.

def checkCutoff(self,up,down):
.............do some processing........
if (10 <= score <= 30):
result="Bad"
elif (31 <= score <= 40):
result="Good"
.............do some processing........
return result

If i have to have this as a separate script that stores all the
properties, then how do I make the program fetch the new values
without restarting.

Also, i would be interested in providing a GUI for manging the
properties so that the changes can be applied even more easily - but
at any time i do not want to bring down the program and then
restart(all are hot patches).

Regards,
Venkat
Jun 27 '08 #1
4 1065
Or a better example would be:

I have the params in a config file and import this module:
myconfig.py
a=10
b=30
c=31
d=40

import myconfig
def checkCutoff(self,up,down):
.............do some processing........
if (a <= score <= b):
result="Bad"
elif (c <= score <= d):
result="Good"
.............do some processing........
return result

Now when i 'manually' make some changes to the value of a,b,c,d then
the the checkCutoff func should refer to the new values.

-Venkat
Jun 27 '08 #2
On 2008-05-16, Venkatraman.S. <ve******@gmail.comwrote:
Or a better example would be:
Indeed, this is concrete enough to make some suggestions.
I have the params in a config file and import this module:
myconfig.py
a=10
b=30
c=31
d=40
The big problem imho with coding such stuff directly in Python is that you have
no way to extract the data from the code to display it to your users without
exposing them to Python code.

Why not instead throw this in a ConfigParser file like below, and load the data
values from it (each time they have changed?)

[score]
a=10
b=30
c=31
d=40

By picking better names, the config gets much more readable.

The big advantage here is that a config file is something readable and editable
without appearing it to be Python.
If this is too low level for your users, you can use it as a data exchange
format between the processing application and the frontend application where
users can change the values.
import myconfig
def checkCutoff(self,up,down):
.............do some processing........
if (a <= score <= b):
result="Bad"
elif (c <= score <= d):
result="Good"
.............do some processing........
return result

Now when i 'manually' make some changes to the value of a,b,c,d then
the the checkCutoff func should refer to the new values.
Maybe reload the file each time you run the program?
Sincerely,
Albert
Jun 27 '08 #3
On May 16, 7:45 am, "A.T.Hofkamp" <h...@se-162.se.wtb.tue.nlwrote:

Thanks
By picking better names, the config gets much more readable.

The big advantage here is that a config file is something readable and editable
without appearing it to be Python.
If this is too low level for your users, you can use it as a data exchange
format between the processing application and the frontend application where
users can change the values.
The problem being, if i change the config file, then the configobj has
to reload this file again. I do not want to 'refresh' the config obj
per transaction but only when the config params change.
Now when i 'manually' make some changes to the value of a,b,c,d then
the the checkCutoff func should refer to the new values.

Maybe reload the file each time you run the program?
The program is never-ending and do not think in terms of websites here
- probably something like a server/middleware which can never be
brought down.

I was thinking along the terms of an Interrupt driven program, which
when getting a custom interrupts reloads the file - any potential
loopholes/falls that anyone can anticipate?

Regards,
Venkat
Jun 27 '08 #4
On 2008-05-16, Venkatraman.S. <ve******@gmail.comwrote:
The problem being, if i change the config file, then the configobj has
to reload this file again. I do not want to 'refresh' the config obj
per transaction but only when the config params change.
If you have trustable time stamps at your file system, you could check the time
stamp before loading.
I was thinking along the terms of an Interrupt driven program, which
when getting a custom interrupts reloads the file - any potential
loopholes/falls that anyone can anticipate?
Many unix deamons use SIGHUP signal to reload configs.
Maybe that would be an option?
Sincerely,
Albert

Jun 27 '08 #5

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

Similar topics

1
by: Saradhi | last post by:
I am hosing website using ASP on windows2003 standard server in IIS 6.0 sessions are getting expired immediately. Could any one help me in managing sessions in iis 6.0 and ASP?
1
by: Cliff Williams | last post by:
How are people managing multiple, interdependent projects in the same solution? If I have to rebuild my solution file one more time, I think my head is going to spin around and pop off. I've...
4
by: Simon Matthews | last post by:
Hi, I have created multiple .dll's mostly representing libraries used by multiple projects. The dll's are often dependant on each other , for example:- ..dll1 dependant on .dll2 dependant on...
9
by: Chibi | last post by:
I'm writing an application that's bandwidth intense. My available bandwidth is 1.5Mbps (cable modem) and I know I can reach around 1.4Mbps, if not more. The application I am writing right now...
0
by: Sam Martin | last post by:
Hi all, This is the first time i've done this so please bare with me if i use the wrong teminology, etc. I've derived a design from ParentControlDesigner with the intention of being able to...
0
by: Atara | last post by:
Is there a way I can use different references for different configurations of my project? I have different project (and solution) configurations. Do I have to 'Add reference' of all the dll's I...
1
by: Screenbert | last post by:
After finding nothing anywhere in google I am posting this so everyone can benefit by it. The formating is not pretty since I copied it from my word document, but you should benefit by it. ...
0
by: screenbert | last post by:
Managing DHCP Servers using C# They said it was impossible. It couldn't be done. But you can in fact manage DHCP servers using C#. This includes creating and deleting Scopes, SuperScopes,...
2
by: Kenneth Roy | last post by:
I have an application using a grid control. I have set up user settings for each column of the grid to enable the user to determine various properties of those columns. For example whether a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.