Andy,
I'm not aware of any "Pythoncard-specific" way of persisting data, but there
are *several* approaches to persisting data within Python itself. What type
of "info" specifically are you attempting to "write out to a file"? The
persistant approaches I speak of include serializing or "shelving" (also
known as "pickling") your Python objects directly to a file to be later read
in ( http://www.network-theory.co.uk/docs/pytut/tut_58.html), writing data
in your own structure in plain-text files, or writing to a local database,
such as:
SQLite (pysqlite - http://www.initd.org/tracker/pysqlite)
Metakit (http://www.equi4.com/metakit/python.html )
ZODB (http://www.zope.org/Wikis/ZODB) and
(http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html
)
...and others...
I've personally used ZODB in my Pythoncard implementations with *great*
success, although it's a bit "bloated", and has a 2GB cap for each DB (can
be compacted easily though). You can actually create self-persistent aware
classes that wrap the ZODB Persistent class. Any updates done to an object
extending Persistent will automatically be persisted within your ZODB
database. I believe ZODB's "FileStorage" method extends the "Pickle"
implementation build into Python, which is what I currently use... Even for
web-based projects where traffic is known to be light. I may get around to
writing a ZODB interface for Pythoncard one of these days, but I've been
leaning towards JSON these last few months...
Other approaches I've used include JSON (http://www.json.org) to serialize
my (non-cyclical) data into strings using the Javascript Object Notation and
saving them to text files. This is a "cheap" and easy solution which makes
your data available to other systems "natively" without any custom parsing
methods, as is the case with XML-based data persistence. A JSON
parser/serializer has been written for most major languages out there.
You could always just structure your data in plain text files using Python's
built-in file-handling functionality:
http://www.network-theory.co.uk/docs/pytut/tut_56.html
I came across this while Googling links for as well (extends Pickle - Hey,
that sounds dirty!):
http://wiki.w4py.org/pythons-pickle-and-shelve-modules.html
Again, there are several approaches, and I've outlined which ones I've been
content with. Your needs will ultimatley dictate what method is best for
you. Research the capabilities in the approaches I've mentioned to make an
educated decision.
Good luck!
-Sean
On 12/13/06, Andy Ross <dar...@gm...> wrote:
>
> Hello all,
>
> I'm trying to make a program where you input info into the program and I
> wanted to know if there is a component or something that could write out to
> a file to permanently save what the user has inputted.
>
> is there such a component or function specific to pythoncard?
>
> ~Andy
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Pythoncard-users mailing list
> Pyt...@li...
> https://lists.sourceforge.net/lists/listinfo/pythoncard-users
>
>
>
--
Thanks!
Sean
|