473,323 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

publishing an already instantiated class

J
Hi everyone,

Thanks for your awsome replies. I started replacing Javascript
with python 2 days ago and I already have my first scripts running.
Mainly due to the wealth of information in this blog.

I have a C++ object that is already instantiated and now
I want to give python a reference to it... Basically I have

class X
{
typedef struct
{
PyObject_HEAD
ScnNode* mObject;
} PyStruct;

static PyTypeObject PyType;

static init()
{
PyType_Ready(&PyType) < 0)
Py_INCREF(&PyType);
PyModule_AddObject(sModule, "Node", (PyObject*) &PyType);
}
};

I think that in the constructor of X I now have to make some calls in
order to provide access to this instance from a python script.... I
also think that I only want to get PyObject_New to be called, but not
PyObject_Init, because there I create a new instance of X when it is
instantiated through a script.... Am I on the right track here ?

Cheers
Jochen

Jul 21 '05 #1
1 1089
J
I think I just found my own solution, so I will record it for future
references

I did this in my Constructor of X
{
PyStruct* lObject;
lObject = PyObject_New(PyStruct, &X::PyType);
lObject->mObject = this;
}

What does everyone think about this. I am posting a little bit out of
the hip here,
and should probably investigate my solution a little more.
Nevertheless, it is
a good way to record my experiences...

Cheers
Jochen

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Dev | last post by:
Hello, Why an Abstract Base Class cannot be instantiated ? Does anybody know of the object construction internals ? What is the missing information that prevents the construction ? TIA....
5
by: Felix I. Wyss | last post by:
Good Afternoon, I recently noticed that some very simple methods of a template declared and used in a DLL library get inlined when used by the DLL itself, but not by other DLLs and EXEs. After...
8
by: A P | last post by:
Hi! I'm using ASP.Net Web Matrix on my PC and wanting to publish the files to our server. I try to copy (thru explorer) the files but it didn't work! I receive Runtime Error: Server Error...
1
by: AndrewMBaldwin | last post by:
Ok, this is going to be a long post, so I apologize in advance, but if it was an easy question I would have probably found an answer somewhere out here by now... The short story of this is that...
2
by: yinglcs | last post by:
I have the following code, which use template as the parent class of my other class. But I have "instantiated from here" compile error at this line: class C: public B2<A>. Can some one...
8
by: pirho | last post by:
Not sure if I'm posting this in the right spot, but.... Lets say i have a class for data access that gets instantiated on each page in a web application ( .Net 1.1 ) From inside that class,...
5
by: rmgalante | last post by:
I've been using the VS2005 Publish utility on one of my projects for about six months. I have a large site with hundreds of files, thousands if you include the code behind files. So I thought...
11
by: cj | last post by:
Perhaps someone knows how to do this. When I open a new ASP.NET web service application in VS 2008, it opens with a simple Hello World web service already written. I want to see this work. ...
7
ADezii
by: ADezii | last post by:
There are essentially three techniques for publishing Access Data on the Web. The first technique is static, and does not allow for the dynamic addition or modification to the data, There is no...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.