Re: MySQLdb and dictcursor

2006-07-28 Thread blank
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote in 
news:[EMAIL PROTECTED]:

>  dictCursor
>   RETURNS the results as a dictionary; it doesn't affect how
> parameters are passed in.

thats how I was using it


> 
>  Normally results are a (list or tuple) where you have to know the
> order of the fields specified in the query:
> 
>  cr.execute("select a, c, b from table")
>  dt = cr.fetchone()
> 
> dt is a (list/tuple) with (a_value, c_value, b_value)
> 
>  With a dictCursor you get
> 
>  dcr.execute("select a, c, b from table")
>  ddt = dcr.fetchone()
> 
> ddt is a dictionary of {"a" : a_value, "b" : b_value, "c" : c_value}
> 
> 
>  MySQLdb nominally uses just the %s placeholder style, but I think 
it
> will also function with %(name)s format...
> 
>  cr.execute(
>   "insert into table (c, a, b) values (%(c)s, %(a)s, %(b)s",
>   ddt)

sounds a lot simpler, ill give it a go later. thanks


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


Re: pre-PEP generic objects

2004-12-03 Thread Remy Blank
Istvan Albert wrote:
> On the other hand, it would be nice to have a module that
> implements various design patterns. The Bunch, the Borg, the Null,
> the Proxy all nicely documented tucked away in their separate
> module. That would feel a lot less like littering the standard name space
> with an class that just "seems"  to be useful.

+1 for a "patterns" module.

-- Remy


Remove underscore and suffix in reply address for a timely response.

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


Re: Loading a file only once into an object and being able to access it from other modules

2004-12-07 Thread Remy Blank
Philippe C. Martin wrote:
> I have a very large XML file that I load into dictionnaries defined in a 
> class 
> located in a module that is imported in many places.
> 
> Since the loading process is very slow, I would like the file not to be 
> loaded 
> on import or class instantiation, but only once (on first import or class 
> instantiation).

What about:

class MyClass:
hugeDict = loadHugeDic("filename.xml")

def __init__(self):
"""hugeDict can be accessed by self.hugeDict"""
...

The function loadHugeDict() will only be called once, when importing the
module for the first time. If you wanted to load it on the first
*instantiation*, you could do:

class MyClass:
hugeDict = None

def __init__(self):
if MyClass.hugeDict is None:
MyClass.hugeDict = loadHugeDic("filename.xml")
...

HTH.
-- Remy


Remove underscore and suffix in reply address for a timely response.

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


ANN: Sydebar 1.0 - A browser sidebar generator for Python documentation

2008-06-04 Thread Remy Blank
Content-Type: text/plain; charset=UTF-8; format=flowed

Content-Transfer-Encoding: quoted-printable



I am pleased to announce the first release of Sydebar, a browser sidebar =



generator for Python documentation. For the impatient, sample outputs=20

for all Python versions ever released can be found here:



   http://c-space.org/download/Sydebar/samples/



The program generates a single, self-contained XHTML file for a specific =



Python documentation URL, which can be local or remote. The generated=20

file is loaded into the sidebar of some popular browsers (tested on=20

Firefox and Opera, Mozilla should work as well), and presents a tabbed=20

interface with one page for each of the following documentation sections:=





  * Tutorial

  * Language reference

  * Library reference

  * Python/C API

  * Extending and embedding

  * Global module index



Each page shows a collapsible tree of chapters, with links opening the=20

corresponding section in the main browser pane. The global module index=20

features an incremental search functionality with fast keyboard navigatio=

n.



Moreover, a search page allows performing searches on various subsets of =



python.org (specific parts of the website, PEPs, newsgroups, PyPI and=20

the issue tracker).



The documentation and PyPI entry can be found here:



   http://c-space.org/software/Sydebar.html

   http://pypi.python.org/pypi/Sydebar



I would like to mention that Sydebar was inspired by python-sidebar from =



Daniel Lundin at Edgewall Software, and even though I didn't borrow any=20

code from there, the layout does bear quite some resemblance.



Feedback is very welcome.



Thanks for reading!

-- Remy




Content-Type: application/pgp-signature; name="signature.asc"

Content-Description: OpenPGP digital signature

Content-Disposition: attachment; filename="signature.asc"



-BEGIN PGP SIGNATURE-

Version: GnuPG v2.0.9 (GNU/Linux)



iEYEARECAAYFAkhFvFEACgkQCeNfIyhvXjISEACgmUXSorHaZ7JjNC2AqTuJtWod

BAgAn3g/97+9cI9m5n2QBpvcmtxQnGB0

=IQ6Q

-END PGP SIGNATURE-


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

Re: ANN: Sydebar 1.0 - A browser sidebar generator for Python documentation

2008-06-04 Thread Remy Blank
(I apologize for the poorly formatted message. Something between my news 
client and the server decided, besides delaying the message for over 17 
hours, to add an empty line for every line of text, which obviously 
messed up some headers. Here's the content again, and hopefully this 
message comes through unaltered.)



I am pleased to announce the first release of Sydebar, a browser sidebar
generator for Python documentation. For the impatient, sample outputs
for all Python versions ever released can be found here:

   http://c-space.org/download/Sydebar/samples/

The program generates a single, self-contained XHTML file for a specific
Python documentation URL, which can be local or remote. The generated
file is loaded into the sidebar of some popular browsers (tested on
Firefox and Opera, Mozilla should work as well), and presents a tabbed
interface with one page for each of the following documentation sections:

  * Tutorial
  * Language reference
  * Library reference
  * Python/C API
  * Extending and embedding
  * Global module index

Each page shows a collapsible tree of chapters, with links opening the
corresponding section in the main browser pane. The global module index
features an incremental search functionality with fast keyboard navigation.

Moreover, a search page allows performing searches on various subsets of
python.org (specific parts of the website, PEPs, newsgroups, PyPI and
the issue tracker).

The documentation and PyPI entry can be found here:

   http://c-space.org/software/Sydebar.html
   http://pypi.python.org/pypi/Sydebar

I would like to mention that Sydebar was inspired by python-sidebar from
Daniel Lundin at Edgewall Software, and even though I didn't borrow any
code from there, the layout does bear quite some resemblance.

Feedback is very welcome.

Thanks for reading!
-- Remy
--
http://mail.python.org/mailman/listinfo/python-list


Re: Exit from os.chroot()

2008-06-04 Thread Remy Blank

Thomas Bellman wrote:

That might not be the best idea...  Suddenly the chroot:ed
program has access to the real /usr/bin; and since it likely is
running as root (it was allowed to call chroot()), it can do bad
things to the things in /usr/bin. 


If a chrooted process is running as root, it can very easily break out 
of the chroot anyway. So...



Also remember, a chroot:ing process should permanently relinquish
its privileges as soon as possible after chroot:ing.  There are
way too many fun things a root-running process can do even when
chroot:ed, like creating device files or setuid binaries.


...this is imperative.


All this is of course assuming that the chroot is done for
security reasons.


But here's something that might be interesting:

  http://kerneltrap.org/Linux/Abusing_chroot

Short story: chroot is not and never has been a security tool.

-- Remy

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


Re: Relative Package Import

2008-07-08 Thread Remy Blank

Robert Hancock wrote:

mypackage/
  __init__.py
  push/
__init__.py
 dest.py
 feed/
   __init__py

 ^
Missing dot here? ---|


In subject.py I have
 from ..push import dest

But i receive the error:
  Caught exception importing module subject:
File "/usr/local/python/lib/python2.5/site-packages/pychecker/
checker.py", line 621, in setupMainCode()
  module = imp.load_module(self.moduleName, file, filename, smt)
File "subject.py", line 1, in ()
  from ..feed import dest


This last line contradicts your statement above...

-- Remy

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