ctypes argument by reference

2011-12-28 Thread gaetan
Hi
I try to write a python backend for pamcan-g2, for that I should write a 
callback for *trans_cb_conv

In python I've write :
trans_cb_event = CFUNCTYPE(ctypes.c_char_p,ctypes.c_void_p,POINTER(ctypes.c_int)
...
def fpm_trans_conv(event,pkg,response):
foo...
response=1
and for call the callback
if trans_init(pm_trans,flags, trans_cb_event(fpm_progress_event), 
trans_cb_conv(fpm_trans_conv), None) == -1 :
foo...

Into libpacman response is a C int pointer :
...
QUESTION(trans, PM_TRANS_CONV_LOCAL_UPTODATE, local, NULL, NULL, resp);
...

but resp=0 howto pass response by reference instead by value ?

If you would more informations/code :
the .h is here : 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=blob_plain;f=lib/libpacman/pacman.h;hb=HEAD
the python code here : 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-tweak.git;a=blob_plain;f=py-pacman/py-pacman.py;hb=4abed4ee445f009387a3a51957e231c010c123bb

trans_cb_event line 315
fpm_trans_conv line 676
pacman_trans_init callback 708
-- 
http://mail.python.org/mailman/listinfo/python-list


Pickling an extension type subclasses problems

2010-02-05 Thread Gaetan de Menten
Hi all,

I am trying to write an (optional!) C extension for SQLAlchemy, and I
am struggling to make an extension type picklable *and* using the same
format as the pure Python version (so that computers with the C
extension can unpickle pickles from computers without it and
vice-versa). Also the extension type (MyBase in the example code
below) only serves as a base class for the type that get pickled
(MyPythonType). MyPythonType also has further subclasses and those
should be picklable too.

My setup is as follow:

On the Python side:


try:
from cextension import MyBase
except ImportError:
class MyBase(object):
__slots__ = ('a', 'b', 'c')
def __init__(self, a, b, c):
self.a, self.b, self.c = a, b, c

def __getstate__(self):
...

def __setstate__(self, state):
...
...


class MyPythonType(MyBase):
...

On the .c side:
===
I implemented a reduce method, which returns

Py_BuildValue((O(s)N), Py_TYPE(self), __state__, state);

and in my BaseRowProxy_init method, I check the number of arguments,
whether the __state__ marker is present and unpack the state if it
is. This makes the type nicely pickleable, but this is obviously not
the same pickle format as the Python version.

What would you recommend in this kind of situation? I'm a bit tired of
trial and error... My last hope is to define __reduce__ on the Python
side too, and make it use a module-level reconstructor function as
follow:

def mypythontype_reconstructor(cls, state):
obj = object.__new__(cls, state):

return obj

Will this work? Any other idea?

Thanks in advance,
-- 
Gaëtan de Menten
-- 
http://mail.python.org/mailman/listinfo/python-list


Elixir 0.7.1 released

2009-11-16 Thread Gaetan de Menten
I am very pleased to announce that version 0.7.1 of Elixir
(http://elixir.ematia.de) is now
available. As always, feedback is very welcome, preferably on Elixir
mailing list.

This release packs a few interesting new features (abstract classes
and a new collection
type providing explicit relative resolution of target entities) and
some bug fixes. It is a safe
upgrade from the 0.7.0 release.

The full list of changes can be seen at:
http://elixir.ematia.de/trac/browser/elixir/tags/0.7.1/CHANGES

What is Elixir?
-

Elixir is a declarative layer on top of the SQLAlchemy library. It is
a fairly thin wrapper, which provides the ability to create simple
Python classes that map directly to relational database tables (this
pattern is often referred to as the Active Record design pattern),
providing many of the benefits of traditional databases without losing
the convenience of Python objects.

Elixir does not intend to replace SQLAlchemy's core features, and
instead focuses on providing a simpler syntax for defining model
objects when you do not need the full expressiveness of
SQLAlchemy's manual mapper definitions.

Mailing list


http://groups.google.com/group/sqlelixir/about

-- 
Gaëtan de Menten
http://openhex.org
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Elixir 0.5.1 released!

2008-02-08 Thread Gaetan de Menten
I am very pleased to announce that version 0.5.1 of Elixir
(http://elixir.ematia.de) is now available. As always, feedback is
very welcome, preferably on Elixir mailing list.

This is mostly a bug fixes release (especially for people using
inheritance), but we have also a few minor new features, including a
new plugin for managing entities as (ordered) lists, enhanced support
for custom base classes and an alternate (nicer) syntax to define
synonym properties.

The full list of changes can be seen at:
http://elixir.ematia.de/trac/browser/elixir/tags/0.5.1/CHANGES

What is Elixir?
-

Elixir is a declarative layer on top of the SQLAlchemy library. It is
a fairly thin wrapper, which provides the ability to create simple
Python classes that map directly to relational database tables (this
pattern is often referred to as the Active Record design pattern),
providing many of the benefits of traditional databases without losing
the convenience of Python objects.

Elixir is intended to replace the ActiveMapper SQLAlchemy extension,
and the TurboEntity project but does not intend to replace
SQLAlchemy's core features, and instead focuses on providing a simpler
syntax for defining model objects when you do not need the full
expressiveness of SQLAlchemy's manual mapper definitions.

Mailing list


http://groups.google.com/group/sqlelixir/about

-- 
Gaëtan de Menten
http://openhex.org
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Elixir 0.5.0 released!

2007-12-09 Thread Gaetan de Menten
I am very pleased to announce that version 0.5.0 of Elixir
(http://elixir.ematia.de)
is now available. As always, feedback is very welcome, preferably on Elixir
mailing list.

This is mostly a bug fixes release, but we have also had some pretty
important changes to the default values for options. Please look at
http://elixir.ematia.de/trac/wiki/Migrate04to05 for detailed
upgrade notes.

The full list of changes can be seen at:
http://elixir.ematia.de/trac/browser/elixir/tags/0.5.0/CHANGES

What is Elixir?
-

Elixir is a declarative layer on top of the SQLAlchemy library. It is
a fairly thin wrapper, which provides the ability to create simple
Python classes that map directly to relational database tables (this
pattern is often referred to as the Active Record design pattern),
providing many of the benefits of traditional databases without losing
the convenience of Python objects.

Elixir is intended to replace the ActiveMapper SQLAlchemy extension,
and the TurboEntity project but does not intend to replace
SQLAlchemy's core features, and instead focuses on providing a simpler
syntax for defining model objects when you do not need the full
expressiveness of SQLAlchemy's manual mapper definitions.

Mailing list


http://groups.google.com/group/sqlelixir/about


-- 
Gaëtan de Menten
http://openhex.org
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Elixir 0.4.0 released!

2007-10-29 Thread Gaetan de Menten
I am very pleased to announce that version 0.4.0 of Elixir is now
available. As always, feedback is very welcome, preferably on Elixir
mailing list.

Highlights for this release
-

- Implemented a new attribute-based syntax to declare fields and relationships,
  which is much closer to what is found in other Python ORM's.

- Full support for SQLAlchemy 0.4

- Implemented polymorphic single-table inheritance as well as polymorphic and
  non-polymorphic multi-table (aka joined table) inheritance.

- Added versioning extension to keep track to all changes to your entities by
  storing them in a secondary table.

- Extended documentation (tutorial and others).

Please see http://elixir.ematia.de/trac/wiki/Migrate03to04 for detailed
upgrade notes.

The full list of changes can be seen at:
http://elixir.ematia.de/trac/browser/elixir/tags/0.4.0/CHANGES

What is Elixir?
-

Elixir is a declarative layer on top of the SQLAlchemy library. It is
a fairly thin wrapper, which provides the ability to create simple
Python classes that map directly to relational database tables (this
pattern is often referred to as the Active Record design pattern),
providing many of the benefits of traditional databases without losing
the convenience of Python objects.

Elixir is intended to replace the ActiveMapper SQLAlchemy extension,
and the TurboEntity project but does not intend to replace
SQLAlchemy's core features, and instead focuses on providing a simpler
syntax for defining model objects when you do not need the full
expressiveness of SQLAlchemy's manual mapper definitions.

Mailing list


http://groups.google.com/group/sqlelixir/about

-- 
Gaëtan de Menten
http://openhex.org
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Elixir 0.3.0 released!

2007-03-27 Thread Gaetan de Menten
We are pleased to announce that version 0.3.0 of Elixir is now
available. As always, feedback is very welcome, preferably on Elixir
mailing list.

Highlights for this release
-

- Added support for autoloading/reflecting databases with
 has_and_belongs_to_many relationships. See the docs for details.
- Added support for the version_id_col option on entities. This option adds
 a column to the table which will be used to prevent concurrent modifications
 on any row of the entity's table (i.e. it will raise an error if it happens).
- Added an ondelete argument to belongs_to relationships.
- The tablename option can now be given a callable so that people can provide
 their own function to get the table name for an entity.
- Made the provided metadata not threadlocal. This could break things for you
 in some rare case. Please see the (newly created) FAQ file for details about
 this.

- Fixed bug preventing having entities without any statement.
- Fixed typo which broke the use_alter argument on belongs_to relationships.

The full list of changes can be seen at:
http://elixir.ematia.de/svn/elixir/tags/0.3.0/CHANGES

What is Elixir?
-

Elixir is a declarative layer on top of SQLAlchemy. It is a fairly
thin wrapper, which provides the ability to define model objects
following the Active Record design pattern, and using a DSL syntax
similar to that of the Ruby on Rails ActiveRecord system.

Elixir does not intend to replace SQLAlchemy's core features, but
instead focuses on providing a simpler syntax for defining model
objects when you do not need the full expressiveness of SQLAlchemy's
manual mapper definitions.

Mailing list


http://groups.google.com/group/sqlelixir/about


-- 
Gaëtan de Menten
http://openhex.org
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Elixir 0.2.0 released!

2007-03-02 Thread Gaetan de Menten
We are pleased to announce that the second release of Elixir
(http://elixir.ematia.de) is now available. We hope you'll enjoy it.

Highlights for this release
-

- Implemented singletable non-polymorphic inheritance
- Added support to pass non-keyword arguments to tables.
- Added support for deferred columns
- Look at the calling stack frame to ensure that we apply statements
to the proper class.
  We now attach the statement list to the class itself, rather than
attaching it to a global
  list that is neither threadsafe, nor safe when doing nested class definition.
- Fixed foreign key names on MySQL (and possibly other) databases by
  making sure the generated name is unique for the whole database, and not
  only for the table on which it applies.
- Applied patch from Robin Munn to make the code python 2.3 compatible

The full list of changes can be seen at:
http://elixir.ematia.de/svn/elixir/tags/0.2.0/CHANGES

What is Elixir?
-

Elixir is a declarative layer on top of SQLAlchemy. It is a fairly
thin wrapper, which provides the ability to define model objects
following the Active Record design pattern, and using a DSL syntax
similar to that of the Ruby on Rails ActiveRecord system.

Elixir does not intend to replace SQLAlchemy's core features, but
instead focuses on providing a simpler syntax for defining model
objects when you do not need the full expressiveness of SQLAlchemy's
manual mapper definitions.

Mailing list


[EMAIL PROTECTED]

-- 
Gaëtan de Menten
http://openhex.org
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html