Re: How to delete a Python package

2006-07-13 Thread zarrg

Nick Vatamaniuc wrote:
> Skip,
> I agree. Some kind of a manifest or log file would be great and
> probably not that hard to implement.
> Nick

What's wrong with the "record" option of install:
  python setup.py install --record installed_files

Then it's pretty easy to do:
  rm -rf  `cat installed_files`

Hmm, I guess that's easy on *nix.
Maybe setup *should* support uninstall for consistant cross-platform
behavior.

-- George
>
> [EMAIL PROTECTED] wrote:
> > Nick> Uninstall support is hard, you would turn distutils (setup.py)
> > Nick> into a package management system, but wait...!  there are already
> > Nick> package managers that do exactly that (rpm, deb, Windows
> > Nick> Installer).
> >
> > Note that I don't really care about uninstall support, certainly not enough
> > to go through the pain of editing distutils.  I'd be happy if the installer
> > wrote a MANIFEST file that tells me what files and directories it did
> > install.  I'm not as worried about dependencies or overlaps between packages
> > as much as making sure that when I want to get rid of package X I can
> > actually delete all of its files.  I also realize that's not truly package
> > management in the rpm/deb sense, but that would be good enough for me.
> >
> > My message was simply pointing out that telling people "use RPM or DEB" is
> > not really acceptable.  Not everyone uses Linux.  Or Windows.  Or Macs.
> > Python is a cross-platform language.  Through distutils it includes a basic
> > cross-platform installation facility.  It probably ought to also have a
> > corresponding basic cross-platform uninstall facility.
> > 
> > Skip

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to have application-wide global objects

2006-07-13 Thread zarrg
Sanjay wrote:
> Probably a newcomer question, but I could not find a solution.
>
> I am trying to have some singleton global objects like "database
> connection" or "session" shared application wide.
>
> Trying hard, I am not even being able to figure out how to create an
> object in one module and refer the same in another one. "import"
> created a new object, as I tried.

Try the "borg" pattern:
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531
It's very simple and does what you need.  Don't be put off by comments
that "it's not a *real* singleton".

Or, use a module-level object, e.g.:

db.py
class db_conn:
   def __init__(self, dbname, dbhost):
  self.conn = whatever(dbname, dbhost)

conn = db_conn('mydb", "myhost")

app.py
import db
...
cur = db.conn.cursor()
cur.execute("select lkjlkj")

Repeated imports of db by various modules in an application
do *not* rerun the code in db.py .

-- George

-- 
http://mail.python.org/mailman/listinfo/python-list