[Product-Developers] Re: Newbie: Control panels (Aspelli's book, chapter 12)
shreya.bhatt at gmail.com
Fri May 16 00:06:58 UTC 2008
Did you try putting in
<include package="collective.lead" />
in the configure.zcml of your module?
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
> Exception Type TypeError
> Exception Value ('Could not adapt', <PloneSite at /testing>,
> 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
> with the config being:
> for = "Products.CMFPlone.interfaces.IPloneSiteRoot"
> provides = "Products.ActiveCollabConnector.settings.IDatabaseSettings"
> factory = ".controlpanel.database_settings"
> class IDatabaseSettings(Interface):
> """Database connection settings.
> drivername = schema.ASCIILine(title = u"Driver name",
> description = u"The database driver
> 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
> 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
> def _on_save(self):
> db = getUtility(IDatabase, name='ActiveCollab')
View this message in context: http://www.nabble.com/Newbie%3A-Control-panels-%28Aspelli%27s-book%2C-chapter-12%29-tp16013224s20094p17264734.html
Sent from the Product Developers mailing list archive at Nabble.com.
More information about the Product-Developers