December 20th, 2004, 04:38 AM
i want to create a file type which is unique to my program, abd they will end in .qea
each one will store text and images, but i have no idea how i can go about doing this - is there a specific method to creating files unique to a program?
December 20th, 2004, 04:54 AM
What a file contains is totally up to you. To associate the file with your executable you will need to access the registry to add the right keys and values.
I've not used them but there are methods in the WIN32 extension package to allow registry editing but I would not use them until you have thoroughly investigated what keys are needed and how they should be manipulated.
December 20th, 2004, 07:02 AM
i know, but i was kindof wondering how i would go about making my unique file frmat containg text and images. my idea was maybe to have all the text at the top, and then the image data after that, each image being seperted by a unique character, so that code could seperate the images after the file has been opened?
December 20th, 2004, 07:14 AM
Well I over design these things on the assumption that if it can happen it will. The simplest way for me would be to add the length of the text at the beginning - then its easy to read off any number of characters.
Originally Posted by yabadabastum
But how about using pickle to save and load your data.
That way you can put all you files data into a dictionary then write it to a file. Then you can unpickle it and recover the dictionary. It does all that mangling and measuring for you
December 20th, 2004, 08:39 AM
looks like i have a few choices
I am not sure whether to store every record as a file - this would give the users an easy way of moving info between computers - or maybe i should use one computer as a database / server, so they can all connect to it.
It's for an estate agent
December 20th, 2004, 08:55 AM
Perhaps you should consider MySQL and pythons database API as the way to go.
If you want a light weight solution using pickle you could try my persistent datatypes module ptypes:
December 20th, 2004, 09:10 AM
hmm i am not too sure about using an actual database server - just a non-server database and something like PYRO. maybe sqllite. i think even mysql is abit too bulky for what i am after.i will check out that link though!
I think maybe i will use mysql for development just so i can use phpmyadmin as a development tool and then switch to something with a smaller footprint when i have all my SQL code in the bag!
December 20th, 2004, 09:24 AM
Another simple method to store "mixed" data (e.g. graphic, text, office documents or whatever) within one file ist to create a zip archive using the zipfile library module. You don't have to bother with text length, file offset or special separation characters, just acces the parts within a zip archive by a unique name. It's no problem to give the zip archive another extension than .zip, and it has the big advantage that you can view the archive content using a zip program like winzip or gzip. I've used this method several times and it works great.
If speed is important and file size doesn't matter, use the same method but with zero compression.
December 20th, 2004, 09:44 AM
I wrote an article for Devshed on using Python with zip files a while back that you might he interested in if you deside to go down this rout:
Hope this helps, enjoy!
December 20th, 2004, 09:47 AM
cheers sb that might be what i am after. I am now debating on whether to do what you suggested or using a database. It comes down to what is gonna be best for the end users i guess - the trouble is - i don't really know what would be best. With files - they could create / edit / ship around and the files would have their own extension / icon, which would be professional and also be great over multiple branches - the files could be emailed about.
but - there is risk that not everyone gets the data that way - if a file is created on 1 computer, it will need to be present on all others computers running the program in the office because the data has to be viewed by everybody working. In that respect the database idea seems great and having files seems pointless!
If i had both - this could lead to confusion because a users files would be updated whenever another user on a different computer updates them!
December 20th, 2004, 10:26 AM
Its probably best to think as a zip file as being a way of grouping files together -- similar to a bundle on the Mac.
There are many advantages to this: as sb said, any zip program will be able to view and or extract the individual files as needed, this will increase compatability with computers/users/clients that don't have your program installed.
Also as mentioned by sb this will still allow you to have a custom file extension (& icon) associated with your program like you wanted .
Now some added by me: it's a lot easier to email someone one file than it is to email them 10 individual files , and you'll be able to take advantage of smaller file sizes. The list goes on...
Ultimately its up to you in which direction you choose to go in but I would be inclined to go with the archive idea.
Good luck ,
December 20th, 2004, 10:34 AM
netytan - you may have been mistaken - i meant one (zip) file per property - so say there are 1000 properties there will be 1000 zip files. Actually now i have said that it looks abit rediculous
December 20th, 2004, 11:00 AM
Mmmmm. What I thought you wanted to do was to have a file that stored a bunch of other files: a few images and some .html files for example then have your program load the files and and so whatever with them; not knowing what it is your program will be doing , but if this is the case then you only need one zip file to store all your other resources.
Am I getting warm here?
Last edited by netytan; December 20th, 2004 at 11:03 AM.
December 20th, 2004, 11:09 AM
ok this is what i am doing - making an admin program to be used in estate agent offices. It's core functionality will be to add / delete properties. Each property will have many details associated with it, and also a few photos. the program will run on each computer in the office - my orignal idea being one computer running as the master - and have a database of image locations and details - and other computers copying to / getting data from this computer.
whatever the solution - each computer in the office will need a full and fully updated set of data to work with.
December 20th, 2004, 11:21 AM
Now I get it, just with your saying properties I assumed you ment something like a property list [properties for the program]. My bad .
Anyway I'm with Grim and the database then. If you're going to have multiple computer gathering data from a central computer on the network its probably better to use a database like MySQL.
This way you don't have to worry about a property being removed on one computer and another computer still thinking it's available or whatever . In-fact this sounds a lot like a web application.