[Pyrex] Re: C-methods in extension types

Lenard Lindstrom len-l at telus.net
Wed Feb 22 03:20:43 CET 2006


Sorry, I missed the part about calling est_mtdb_get_doc outside 
Document. As long as you cdef a reference to Document you can access 
its attributes and C methods. I assume set_doc looks like this:

    cdef set_doc(self, ESTDOC *doc):
        self.doc = doc

Then:

cdef Document New_Doc    # Now the set_doc C method is callable
New_Doc=Document(Void=True)
New_Doc.set_doc(doc)
return New_Doc


Lenard Lindstrom
<len-l at telus.net>


On 21 Feb 2006 at 18:48, Helmut Jarausch wrote:

> This solution is not ideal since the functionality
> which creates this Document (est_mtdb_get_doc)
> belongs to a different (Database) class.
> 
> So I've experimented with a 'cdef'ed member of class
> Document like
> 
> cdef class Document:
> 
>   cdef ESTDOC *doc
> 
>   def __new__(self,Void=False) :
>     if  Void :  pass
>     else :
>       self.doc = est_doc_new()  # this is defined elsewhere
> 
> and then in the other class
> 
>   New_Doc= Document(Void=True)
>   Document.set_doc(New_Doc,doc)
>   return New_Doc
> 
> This leads to a question about 'cdef'ed methods,
> please see my other mail
> 




More information about the Pyrex mailing list