[Product-Developers] Newbie: Control panels (Aspelli's book, chapter 12)

Asbjørn Andersen asbjorn at oberon.no
Mon Jan 19 12:44:22 UTC 2009


Did you find a solution for this? I'm having the same issue...

Regards, Asbjørn Andersen


Aaron Turner wrote:
> 
> I am trying to work out what I am doing wrong and I am tearing my hair out
> and I hope one of you could help me, for which I'd be very grateful. 
> 
> I am following Aspelli's book, chapter 12, but I am cutting down his code
> to a smaller product to just handle the a database connection, to make the
> code more reusable.
> 
> But when I go to the site root and type in what should be the url of the
> control panel, it complains that it cannot adapt.
> 
> Time  	2008/03/12 21:30:20.309 GMT
> User Name (User Id) 	admin (admin)
> Request URL 
> http://localhost:8085/testing/@@activecollab-database-controlpanel
> Exception Type 	TypeError
> Exception Value 	('Could not adapt', <PloneSite at /testing>,
> <InterfaceClass
> Products.ActiveCollabConnector.settings.IDatabaseSettings>)
> 
> Traceback (innermost last):
> 
>     * Module ZPublisher.Publish, line 119, in publish
>     * Module ZPublisher.mapply, line 88, in mapply
>     * Module ZPublisher.Publish, line 42, in call_object
>     * Module zope.formlib.form, line 769, in __call__
>     * Module Products.Five.formlib.formbase, line 55, in update
>     * Module zope.formlib.form, line 732, in update
>     * Module plone.fieldsets.form, line 30, in setUpWidgets
>     * Module zope.formlib.form, line 374, in setUpEditWidgets
> 
> TypeError: ('Could not adapt', <PloneSite at /testing>, <InterfaceClass
> Products.ActiveCollabConnector.settings.IDatabaseSettings>)
> 
> with the config being:
> 
>  <adapter
>   	for 		= "Products.CMFPlone.interfaces.IPloneSiteRoot"
>   	provides	= "Products.ActiveCollabConnector.settings.IDatabaseSettings"
>   	factory		= ".controlpanel.database_settings"
>   	/>
> 
> for 
> 
> class IDatabaseSettings(Interface):
>     """Database connection settings.
>     """
>     
>     drivername = schema.ASCIILine(title		= u"Driver name",
>                                   description	= u"The database driver
> name",
>                                   default	= 'mysql',
>                                   required	= True)
> 
> ... as per Aspelli's book
> 
> 
> class DatabaseSettings(Persistent):
>     """Database connection settings
>     
>     We use raw fields here so that we can more easily use a zope.formlib
>     form in the control panel to configure it. This is registered as a
>     persistent local utility, with name 'optilux.reservations', which is
>     then used by collective.lead.interfaces.IDatabase to find connection
> settings.
>     """
>     
>     implements(IDatabaseSettings)
>     
>     drivername 	= 'mysql'
>     hostname 	= 'localhost'
>     port 	= None
>     username 	= ''
>     password 	= None
>     database 	= ''
> 
> def database_settings(context):
> 	return getUtility(IDatabaseSettings)
> 
> 
> 
> class DatabaseControlPanel(ControlPanelForm):
> 	form_fields 	= form.FormFields(IDatabaseSettings)
> 	form_name 	= u"ActiveCollab Database settings"
> 	label 		= u"ActiveCollab Database settings"
> 	description 	= u"Please enter the appropriate connection settings for
> ActiveCollab"
> 	
> 	def _on_save(self):
> 		db = getUtility(IDatabase, name='ActiveCollab')
> 		db.invalidate()
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Newbie%3A-Control-panels-%28Aspelli%27s-book%2C-chapter-12%29-tp356745p2181071.html
Sent from the Product Developers mailing list archive at Nabble.com.





More information about the Product-Developers mailing list