472,993 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

In a bit of a pickle here :)

Hi, Im an old C++ salt who is doing his first large project using
python/wxPython. Fantastically productive are python and wxWindows.
If you could bear with me, I have a couple of questions for people who
have implemented python projects with similar characterstics. I'm
building a client/server app where the client is a windows or linux
desktop and the back end is pyhton middleware (im going to write)
running on linux with a postgres SQL back end.

I started out using the typical client/server approach starting with
my data model. The more i've used python, the more i've gotten to
think I really dont need a relational data model at all. All the
middlware does is serve up pickled python objects to my desktop via
sockets. The desktop model contains all of the logic as my app runs
in an offline briefcase model. So I came up with the idea of just
storing all of the python objects in the postgres database pickled in
a blob field. Im sure about ten thousand other people came up with
this idea before me. The only other data stored in the table will be
the id of the object and the last time the object was modified. I may
also store a CRC for resolution conflict. For instance, if a client
tries to change an object that was also changed by someone else since
they last received it, the server would throw an exception. Are there
any holes with this approach? Is there a better approach? I have to
stress that I cannot use remoting like pyro because the laptop will be
offline most of the day. They will resync with the server at most a
few times a day.

I have one other question about the pickle system. If I add new
attributes to an object and try to unpickle an old version will it
work? How do you handle versioning of objects with pickle?

My last questions involve using sockets as a transport. If I use
python to exchange data via sockets on the server, will my server be
susceptible to buffer overflow attacks? Because I may need to support
handhelds with no SSL capability, I may need to expose a socket to the
internet unsecured. Any idea what the best approach would be to
keeping the bad people out in this instance? How should I secure my
middleware if I cannot support SSL?

If I have to I will only support SSL or running sockets over SSH.

Thanks so much for helping out.
Jul 18 '05 #1
9 2014
Larry goodman wrote:
I started out using the typical client/server approach starting with
my data model. The more i've used python, the more i've gotten to
think I really dont need a relational data model at all. All the
middlware does is serve up pickled python objects to my desktop via
sockets. The desktop model contains all of the logic as my app runs
in an offline briefcase model. So I came up with the idea of just
storing all of the python objects in the postgres database pickled in
a blob field. Im sure about ten thousand other people came up with
this idea before me. The only other data stored in the table will be
the id of the object and the last time the object was modified. I may
also store a CRC for resolution conflict. For instance, if a client
tries to change an object that was also changed by someone else since
they last received it, the server would throw an exception. Are there
any holes with this approach? Is there a better approach? I have to
stress that I cannot use remoting like pyro because the laptop will be
offline most of the day. They will resync with the server at most a
few times a day. I have one other question about the pickle system. If I add new
attributes to an object and try to unpickle an old version will it
work? How do you handle versioning of objects with pickle?

Warning: I have no experience with such a kind of problems.

If I need to synchronize some data, I'd rather look at version control
systems. IMHO, subversion or cvs seems good enough for this kind of
work. Subversion even have Python bindings (but I didn't play with them).

hope this helps,
anton.

Jul 18 '05 #2
Larry goodman wrote:
Hi, Im an old C++ salt who is doing his first large project using
python/wxPython. Fantastically productive are python and wxWindows.
If you could bear with me, I have a couple of questions for people who
have implemented python projects with similar characterstics. I'm
building a client/server app where the client is a windows or linux
desktop and the back end is pyhton middleware (im going to write)
running on linux with a postgres SQL back end.

I started out using the typical client/server approach starting with
my data model. The more i've used python, the more i've gotten to
think I really dont need a relational data model at all.
...
I have one other question about the pickle system. If I add new
attributes to an object and try to unpickle an old version will it
work? How do you handle versioning of objects with pickle?
If you don't need a relational model, why not consider ZODB/ZEO
(http://zope.org/Wikis/ZODB/FrontPage)? It's the distributed Python object
database that underlies Zope. I've used it successfully for a similar
project. ZODB has transactions/versioning, but client-server syncing is a
trickier, application specific issue.
My last questions involve using sockets as a transport. If I use
python to exchange data via sockets on the server, will my server be
susceptible to buffer overflow attacks? Because I may need to support
handhelds with no SSL capability, I may need to expose a socket to the
internet unsecured. Any idea what the best approach would be to
keeping the bad people out in this instance? How should I secure my
middleware if I cannot support SSL?


Python's strings will protect you from buffer-overflow attacks caused by
sloppy C code reading data into fixed-length buffers, but even then you have
to account for potentially malicious clients sending, for example, megabytes
of data. If you want to limit message sizes, use self-delimiting netstrings
(http://cr.yp.to/proto/netstrings.txt).

It should be easy enough to encrypt your sessions (thus allowing for secure
authentication) by using something like AES. If you control the server and
the clients, SSL is overkill anyway.

HTH,

John
Jul 18 '05 #3
>If you don't need a relational model, why not consider ZODB/ZEO
(http://zope.org/Wikis/ZODB/FrontPage)? It's the distributed Python object
database that underlies Zope. I've used it successfully for a similar
project. ZODB has transactions/versioning, but client-server syncing is a
trickier, application specific issue.
Ill have a look. Sounds terrific.
It should be easy enough to encrypt your sessions (thus allowing for secure
authentication) by using something like AES. If you control the server and
the clients, SSL is overkill anyway.

Sounds great. Thanks for the suggestions.
Jul 18 '05 #4
im looking at the ZODB documentation and I Ran across this:

"The Persistent base class is an ExtensionClass class. As a result, it
not compatible with new-style classes or types in Python 2.2 and up."

Does this mean ZODB wont work with python 2.3?
Jul 18 '05 #5
>No, it means if you want to subclass Persistent, you'll have to make it an
old-style class in ZODBs released to date. This will change in ZODB 3.3
(not yet released).

Sorry but what do you mean by "old-style" class? im new to python.
If i have an other ZODB related questions, ill post to the ZODB list.

thx
Jul 18 '05 #6
Larry goodman wrote:
im looking at the ZODB documentation and I Ran across this:

"The Persistent base class is an ExtensionClass class. As a result, it
not compatible with new-style classes or types in Python 2.2 and up."

Does this mean ZODB wont work with python 2.3?


No, it means the documentation is out of date. ;)

The release notes for ZODB 3.2 at http://www.zope.org/Products/ZODB3.2 say
that it requires 2.2 or up. I downloaded the Windows version for 2.3 and
got it working without a hitch.
Jul 18 '05 #7
Too my knowledge Python 2.3 did not remove "classic" classes, so it
obviously should work. If your using 2.2 and it works, that would be a
second way to answer your question :P.

On Tue, 2003-11-25 at 20:37, Larry goodman wrote:
im looking at the ZODB documentation and I Ran across this:

"The Persistent base class is an ExtensionClass class. As a result, it
not compatible with new-style classes or types in Python 2.2 and up."

Does this mean ZODB wont work with python 2.3?

--
Doveclaw <do******@users.sourceforge.net>
http://horizon2.sourceforge.net
Jul 18 '05 #8
> I have one other question about the pickle system. If I add new
attributes to an object and try to unpickle an old version will it
work? How do you handle versioning of objects with pickle?
Your unpickle will succeed but any new attributes will not be present.
The object will get unpickled with exactly the same attributes it had
when it was pickled. Look at __getstate__() and __setstate__() in the
Python docs - you might be able to fix the unpickled object by
overriding __setstate__().
So I came up with the idea of just
storing all of the python objects in the postgres database pickled in
a blob field. Im sure about ten thousand other people came up with
this idea before me. The only other data stored in the table will be
the id of the object and the last time the object was modified.


What kind of attributes do your objects have? If they point to each
other, or to common objects, then pickling and unpickling can lead to
all sorts of undesirable effects, and you might be better of using a
different solution.

You might want to look at the following (some of which I have never
looked at myself):

1. ZODB (object database of http://www.zope.org/ )
2. MiddleKit in Webware (http://webware.sourceforge.net/ )
3. Twisted (http://www.twistedmatrix.com/ )
4. Metakit (http://equi4.com/metakit.html )

--
Shalabh
Jul 18 '05 #9
>What kind of attributes do your objects have? If they point to each
other, or to common objects, then pickling and unpickling can lead to
all sorts of undesirable effects, and you might be better of using a
different solution.
Yeh im going to have a lot of pointing going on and it confuses me how
I am going to pickle this all. I guess i'll have to store the object
id instead of a reference in the pickle and restore the reference
myself?
You might want to look at the following (some of which I have never
looked at myself):

1. ZODB (object database of http://www.zope.org/ )


This is pretty close to what I need to do.

thx
Jul 18 '05 #10

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

Similar topics

3
by: Michael Hohn | last post by:
Hi, under python 2.2, the pickle/unpickle sequence incorrectly restores a larger data structure I have. Under Python 2.3, these structures now give an explicit exception from...
0
by: Mike P. | last post by:
Hi all, I'm working on a simulation (can be considered a game) in Python where I want to be able to dump the simulation state to a file and be able to load it up later. I have used the standard...
6
by: Jim Lewis | last post by:
Pickling an instance of a class, gives "can't pickle instancemethod objects". What does this mean? How do I find the class method creating the problem?
10
by: crystalattice | last post by:
I'm creating an RPG for experience and practice. I've finished a character creation module and I'm trying to figure out how to get the file I/O to work. I've read through the python newsgroup...
5
by: Chris | last post by:
Why can pickle serialize references to functions, but not methods? Pickling a function serializes the function name, but pickling a staticmethod, classmethod, or instancemethod generates an...
3
by: fizilla | last post by:
Hello all! I have the following weird problem and since I am new to Python I somehow cannot figure out an elegant solution. The problem reduces to the following question: How to pickle a...
2
by: Michele Simionato | last post by:
Can somebody explain what's happening with the following script? $ echo example.py import pickle class Example(object): def __init__(self, obj, registry): self._obj = obj self._registry =...
2
by: Nagu | last post by:
I am trying to save a dictionary of size 65000X50 to a local file and I get the memory error problem. How do I go about resolving this? Is there way to partition the pickle object and combine...
0
by: Nagu | last post by:
I am trying to save a dictionary of size 65000X50 to a local file and I get the memory error problem. How do I go about resolving this? Is there way to partition the pickle object and combine...
1
by: IceMan85 | last post by:
Hi to all, I have spent the whole morning trying, with no success to pickle an object that I have created. The error that I get is : Can't pickle 'SRE_Match' object: <_sre.SRE_Match object at...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.