freelanceprogrammers.org Forum Index » Delphi

newbie questions


View user's profile Post To page top
BigDeny Posted: Fri Apr 21, 2006 12:12 am


Joined: 21 Apr 2006

Posts: 13
newbie questions
I have the following code:unit uPersonXmlWrappers;interfaceuses  Windows, Messages, SysUtils, Classes, uBaseXml, uPersonXml, PythonEngine,  WrapDelphi, WrapDelphiClasses, uBaseXmlWrappers;typeTPyDelphiPersonDetails = class (TPyDelphiPersistent)  private    function  GetDelphiObject: TPersonDetails;    procedure SetDelphiObject(const Value: TPersonDetails);  public    class function  DelphiObjectClass : TClass; override;    // Properties    property DelphiObject: TPersonDetails read GetDelphiObject write SetDelphiObject;end;implementation{ Register the wrappers, the globals and the constants }type  TXmlWrappersRegistration = class(TRegisteredUnit)  public    function Name : String; override;    procedure RegisterWrappers(APyDelphiWrapper : TPyDelphiWrapper); override;    procedure DefineVars(APyDelphiWrapper : TPyDelphiWrapper); override;  end;{ TXmlWrappersRegistration }procedure TXmlWrappersRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper);begin  inherited;end;function TXmlWrappersRegistration.Name: String;begin  Result := `Base person info`;end;procedure TXmlWrappersRegistration.RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper);begin  inherited;  APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiPersonDetails);end;{ TPyDelphiPersonDetails }class function TPyDelphiPersonDetails.DelphiObjectClass: TClass;begin  Result := TPersonDetails;end;function TPyDelphiPersonDetails.GetDelphiObject: TPersonDetails;begin  Result := TPersonDetails(inherited DelphiObject);end;procedure TPyDelphiPersonDetails.SetDelphiObject(const Value: TPersonDetails);begin  inherited DelphiObject := Value;end;initialization  RegisteredUnits.Add( TXmlWrappersRegistration.Create );end.Do I need to override Create and Create_With constructors to be able to create PersonDetails object from pythone.g pd = moduleName.PersonDetails()If the answer is yes, then how to create/ overwrite constructors for TCollection and TCollectionItem descendents. Currently I have following code.unit uWebImportWrappers;interfaceuses  Windows, Messages, SysUtils, Classes, uWebImport, PythonEngine,  WrapDelphi, WrapDelphiClasses;typeTPyDelphiWebSearchResult = class (TPyDelphiPersistent)  private    function  GetDelphiObject: TWebSearchResult;    procedure SetDelphiObject(const Value: TWebSearchResult);  public    class function  DelphiObjectClass : TClass; override;    // Properties    property DelphiObject: TWebSearchResult read GetDelphiObject write SetDelphiObject;end;TPyDelphiWebSearchResults = class (TPyDelphiCollection)  private    function  GetDelphiObject: TWebSearchResults;    procedure SetDelphiObject(const Value: TWebSearchResults);  protected  public    class function  DelphiObjectClass : TClass; override;    class procedure RegisterMethods( PythonType : TPythonType ); override;    // Properties    property DelphiObject: TWebSearchResults read GetDelphiObject write SetDelphiObject;end;implementation{ Register the wrappers, the globals and the constants }type  TXmlWrappersRegistration = class(TRegisteredUnit)  public    function Name : String; override;    procedure RegisterWrappers(APyDelphiWrapper : TPyDelphiWrapper); override;    procedure DefineVars(APyDelphiWrapper : TPyDelphiWrapper); override;  end;{ TXmlWrappersRegistration }procedure TXmlWrappersRegistration.DefineVars(APyDelphiWrapper: TPyDelphiWrapper);begin  inherited;end;function TXmlWrappersRegistration.Name: String;begin  Result := `web import`;end;procedure TXmlWrappersRegistration.RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper);begin  inherited;  APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiWebSearchResult);  APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiWebSearchResults);end;{ TPyDelphiWebSearchResult }class function TPyDelphiWebSearchResult.DelphiObjectClass: TClass;begin  Result := TWebSearchResult;end;function TPyDelphiWebSearchResult.GetDelphiObject: TWebSearchResult;begin  Result := TWebSearchResult(inherited DelphiObject);end;procedure TPyDelphiWebSearchResult.SetDelphiObject(const Value: TWebSearchResult);begin  inherited DelphiObject := Value;end;{ TPyDelphiWebSearchResults }class function TPyDelphiWebSearchResults.DelphiObjectClass: TClass;begin  Result := TWebSearchResults;end;function TPyDelphiWebSearchResults.GetDelphiObject: TWebSearchResults;begin  Result := TWebSearchResults(inherited DelphiObject);end;class procedure TPyDelphiWebSearchResults.RegisterMethods(PythonType: TPythonType);begin  inherited;end;procedure TPyDelphiWebSearchResults.SetDelphiObject(const Value: TWebSearchResults);begin  inherited DelphiObject := Value;end;initialization  RegisteredUnits.Add( TXmlWrappersRegistration.Create );end.I`m asking this because currently I`m getting Unbound delphi wrapper of type xxxxxx at xxxxx if I use r = moduleName.PersonDetails() or r =  moduleName.WebSearchResults(WebSearchResult)
Reply with quote
Send private message
View user's profile Post To page top
morgan_martinet Posted: Fri Apr 21, 2006 10:16 pm


Joined: 29 Apr 2005

Posts: 103
newbie questions
Hi,

Could you send me a sample project demonstrating your troubles at
morgan (@) mmm-experts (dot) com
Note that creating wrappers is only useful if you want to expose
public properties and methods to Python, otherwise you can simply
create an instance of your class and wrap it, like in demo31.
If you need access to a component, you can also use RegisterClass
(TMyComponent) then use the CreateComponent("TMyComponent") function
in Python (see demo31).
Overriding CreateWith methods is only required if you have to submit
parameters to your constructor, like the AOwner argument of a
TComponent.
You can look at the implementation TPyDelphiComponent for this.

Bye,

Morgan


--- In pythonfordelphi@yahoogroups.com, "BigDeny" <bigdeny@...>
wrote:
>
> I have the following code:
>
> unit uPersonXmlWrappers;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, uBaseXml, uPersonXml,
> PythonEngine,
> WrapDelphi, WrapDelphiClasses, uBaseXmlWrappers;
>
> type
> TPyDelphiPersonDetails = class (TPyDelphiPersistent)
> private
> function GetDelphiObject: TPersonDetails;
> procedure SetDelphiObject(const Value: TPersonDetails);
> public
> class function DelphiObjectClass : TClass; override;
> // Properties
> property DelphiObject: TPersonDetails read GetDelphiObject
write
> SetDelphiObject;
> end;
>
> implementation
>
> { Register the wrappers, the globals and the constants }
> type
> TXmlWrappersRegistration = class(TRegisteredUnit)
> public
> function Name : String; override;
> procedure RegisterWrappers(APyDelphiWrapper :
TPyDelphiWrapper);
> override;
> procedure DefineVars(APyDelphiWrapper : TPyDelphiWrapper);
override;
> end;
>
> { TXmlWrappersRegistration }
>
> procedure TXmlWrappersRegistration.DefineVars(APyDelphiWrapper:
> TPyDelphiWrapper);
> begin
> inherited;
> end;
>
> function TXmlWrappersRegistration.Name: String;
> begin
> Result := `Base person info`;
> end;
>
> procedure TXmlWrappersRegistration.RegisterWrappers
(APyDelphiWrapper:
> TPyDelphiWrapper);
> begin
> inherited;
> APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiPersonDetails);
> end;
>
> { TPyDelphiPersonDetails }
>
> class function TPyDelphiPersonDetails.DelphiObjectClass: TClass;
> begin
> Result := TPersonDetails;
> end;
>
> function TPyDelphiPersonDetails.GetDelphiObject: TPersonDetails;
> begin
> Result := TPersonDetails(inherited DelphiObject);
> end;
>
> procedure TPyDelphiPersonDetails.SetDelphiObject(const Value:
> TPersonDetails);
> begin
> inherited DelphiObject := Value;
> end;
>
> initialization
> RegisteredUnits.Add( TXmlWrappersRegistration.Create );
> end.
>
>
> Do I need to override Create and Create_With constructors to be
able to
> create PersonDetails object from python
> e.g pd = moduleName.PersonDetails()
>
> If the answer is yes, then how to create/ overwrite constructors
for
> TCollection and TCollectionItem descendents. Currently I have
following
> code.
>
> unit uWebImportWrappers;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, uWebImport, PythonEngine,
> WrapDelphi, WrapDelphiClasses;
>
> type
> TPyDelphiWebSearchResult = class (TPyDelphiPersistent)
> private
> function GetDelphiObject: TWebSearchResult;
> procedure SetDelphiObject(const Value: TWebSearchResult);
> public
> class function DelphiObjectClass : TClass; override;
> // Properties
> property DelphiObject: TWebSearchResult read GetDelphiObject
write
> SetDelphiObject;
> end;
>
> TPyDelphiWebSearchResults = class (TPyDelphiCollection)
> private
> function GetDelphiObject: TWebSearchResults;
> procedure SetDelphiObject(const Value: TWebSearchResults);
> protected
> public
> class function DelphiObjectClass : TClass; override;
> class procedure RegisterMethods( PythonType : TPythonType );
> override;
> // Properties
> property DelphiObject: TWebSearchResults read GetDelphiObject
write
> SetDelphiObject;
> end;
>
> implementation
>
> { Register the wrappers, the globals and the constants }
> type
> TXmlWrappersRegistration = class(TRegisteredUnit)
> public
> function Name : String; override;
> procedure RegisterWrappers(APyDelphiWrapper :
TPyDelphiWrapper);
> override;
> procedure DefineVars(APyDelphiWrapper : TPyDelphiWrapper);
override;
> end;
>
> { TXmlWrappersRegistration }
>
> procedure TXmlWrappersRegistration.DefineVars(APyDelphiWrapper:
> TPyDelphiWrapper);
> begin
> inherited;
> end;
>
> function TXmlWrappersRegistration.Name: String;
> begin
> Result := `web import`;
> end;
>
> procedure TXmlWrappersRegistration.RegisterWrappers
(APyDelphiWrapper:
> TPyDelphiWrapper);
> begin
> inherited;
> APyDelphiWrapper.RegisterDelphiWrapper
(TPyDelphiWebSearchResult);
> APyDelphiWrapper.RegisterDelphiWrapper
(TPyDelphiWebSearchResults);
> end;
>
> { TPyDelphiWebSearchResult }
>
> class function TPyDelphiWebSearchResult.DelphiObjectClass: TClass;
> begin
> Result := TWebSearchResult;
> end;
>
> function TPyDelphiWebSearchResult.GetDelphiObject:
TWebSearchResult;
> begin
> Result := TWebSearchResult(inherited DelphiObject);
> end;
>
> procedure TPyDelphiWebSearchResult.SetDelphiObject(const Value:
> TWebSearchResult);
> begin
> inherited DelphiObject := Value;
> end;
>
> { TPyDelphiWebSearchResults }
>
> class function TPyDelphiWebSearchResults.DelphiObjectClass: TClass;
> begin
> Result := TWebSearchResults;
> end;
>
> function TPyDelphiWebSearchResults.GetDelphiObject:
TWebSearchResults;
> begin
> Result := TWebSearchResults(inherited DelphiObject);
> end;
>
> class procedure TPyDelphiWebSearchResults.RegisterMethods
(PythonType:
> TPythonType);
> begin
> inherited;
> end;
>
> procedure TPyDelphiWebSearchResults.SetDelphiObject(const Value:
> TWebSearchResults);
> begin
> inherited DelphiObject := Value;
> end;
>
> initialization
> RegisteredUnits.Add( TXmlWrappersRegistration.Create );
> end.
>
> I`m asking this because currently I`m getting Unbound delphi
wrapper of
> type xxxxxx at xxxxx if I use r = moduleName.PersonDetails() or r
=
> moduleName.WebSearchResults(WebSearchResult)
>
Reply with quote
Send private message
View user's profile Post To page top
BigDeny Posted: Sat Apr 22, 2006 11:31 am


Joined: 21 Apr 2006

Posts: 13
newbie questions
--- In pythonfordelphi@yahoogroups.com, "Morgan Martinet" <yahoo@...>
wrote:
>
> Hi,
>
> Could you send me a sample project demonstrating your troubles at
> morgan (@) mmm-experts (dot) com
> Note that creating wrappers is only useful if you want to expose
> public properties and methods to Python, otherwise you can simply
> create an instance of your class and wrap it, like in demo31.
> If you need access to a component, you can also use RegisterClass
> (TMyComponent) then use the CreateComponent("TMyComponent") function
> in Python (see demo31).
> Overriding CreateWith methods is only required if you have to submit
> parameters to your constructor, like the AOwner argument of a
> TComponent.
> You can look at the implementation TPyDelphiComponent for this.
>

Sources are same as I send you for that exception bug.
To simulate it just add one movie to databse then start script editor...

In python interpreter tab use
import movie
r = movie.MovieInfo()

see Variables window for variable r

If you need compiled project then you can get it at
http://xcollect.sf.net

Regards,
Miha
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help