Goal of this digging is to be able create web with custom lists and web parts programmatically by using SharePoint 2007 API. And I need to raise my hat towards Microsoft. They have done a huge amount of stuff in SharePoint considering even this scenario. You can create almost everything from code in SharePoint (honestly I haven’t found any stuff that could not be done programmatically).
And here is a small tasty nice little code that creates a instance of a web part and adds it to designated page without XML stuff (personally I am not too eager to use XML and I always try to find ways do stuff without it):
SPWeb createdWeb = (yourDesignated SPWeb object);
(yournamespace.foryourwebpart).webpartClass webpartToMainPage = new (yournamespace.foryourwebpart).webpartClass();
SPLimitedWebPartManager manager = createdWeb.GetLimitedWebPartManager("default.aspx", PersonalizationScope.Shared);
manager.AddWebPart(webpartToMainPage, "Left", 0)
I hope that someone gets a new thoughts with this small code.