Yes I did and now I have figured out how to set it up as a product. I
was missing a piece of inicialization code in the Install.py that I'll
paste at the bottom of this message. Now I'm trying to figure out how to
override author.pt (author.cpt?) and personalize form. By using
SQLPASPlugin, all the fields I declare in the select that LoadProperties
uses is immediatly available to the PAS and as such, usable elsewere.
The problem I had was that I wasn't registering it, because I had
nothing on the Install (and there's a little piece of code that needs to
be run once... I learned that now).
So, now, all that's left is to override the personalise_form and author.
I've tried the Zope2 way as described in Mysite and it didn't work, so
now I'm following Martin Aspelli's book and using a paster theme
template as guindance. Must be doing something wrong anyway, because I
can't seem to be able to get it right. Next, I'll try to get the
specialized queries I need to be automatically loaded to SQLPASPlugin so
that I only have to install this product and have a fully modded user
profile.
After this, I'm gonna fully document this and make it available on the
site... I don't think anyone whould have to go through this again :P Any
help on how to override (c)pt files or the SQLPASPlugin config would be
appeciated. If not, I'll just gladly continue to hammer away and try to
shape this into something useful.
PS: You know... plone seems to make it all harder than it should be and
makes me feel stupid, but when you get something to work, it seems like
a victory of sorts.
Thanks for all your help so far.
------------------------- Install.py
-----------------------------------------
from StringIO import StringIO
import transaction
from Acquisition import aq_base
from Products.CMFCore.utils import getToolByName
from ers_public.entidades.config import PROJECTNAME
from ers_public.entidades.MembershipTool import MembershipTool
PRODUCT_DEPENDENCIES = ()
EXTENSION_PROFILES = ()
def install(self, reinstall=False):
"""Install a set of products (which themselves may either use Install.py
or GenericSetup extension profiles for their configuration) and then
install a set of extension profiles.
One of the extension profiles we install is that of this product. This
works because an Install.py installation script (such as this one) takes
precedence over extension profiles for the same product in
portal_quickinstaller.
We do this because it is not possible to install other products during
the execution of an extension profile (i.e. we cannot do this during
the importVarious step for this profile).
"""
portal_quickinstaller = getToolByName(self, 'portal_quickinstaller')
portal_setup = getToolByName(self, 'portal_setup')
for product in PRODUCT_DEPENDENCIES:
if reinstall and portal_quickinstaller.isProductInstalled(product):
portal_quickinstaller.reinstallProducts([product])
transaction.savepoint()
elif not portal_quickinstaller.isProductInstalled(product):
portal_quickinstaller.installProduct(product)
transaction.savepoint()
for extension_id in EXTENSION_PROFILES:
portal_setup.runAllImportStepsFromProfile('profile-%s' %
extension_id, purge_old=False)
product_name = extension_id.split(':')[0]
portal_quickinstaller.notifyInstalled(product_name)
transaction.savepoint()
out = StringIO()
installMembershipTool(self,out)
print >> out, "Installation completed."
return out.getvalue()
def _migrateTool(portal, toolid, name, attrs):
orig=getToolByName(portal, toolid)
portal.manage_delObjects(toolid)
portal.manage_addProduct[PROJECTNAME].manage_addTool(name)
tool = getToolByName(portal, toolid)
#for attr in attrs:
# setattr(tool, attr, aq_base(getattr(aq_base(orig), attr)))
return aq_base(orig)
def installMembershipTool(self, out):
portal = getToolByName(self, 'portal_url').getPortalObject()
if getToolByName(self, 'portal_membership', None) is not None:
_migrateTool(portal, 'portal_membership',
MembershipTool.meta_type,
['_actions'])
out.write('Migrated membership tool to AutoIMember Membership Tool')
else:
portal.manage_addProduct[PROJECTNAME].manage_addTool(MembershipTool.meta_type,
None)
out.write('Added AutoIMember Membership Tool')
Raphael Ritz wrote:
[EMAIL PROTECTED] wrote:
Thanks for your help, but I still seem to be doing something wrong.
The product
is listed on the additional products screen, but when i select it to
install
it, it does nothing. It doesn't install, apparently, because when I
look up the
transverse in the author info, it returns {'username': 'admin',
'description':
'', 'language': '', 'home_page': '', 'location': '', 'fullname': ''},
without
any additional fields.
For instance, in this particular case, I'm trying to get aditional
information
obtained by SQLPASPlugin, which I map via the col_mapping option in this
plugin. For what I understood, this should be enough to allow access
to if from
another part of the site (in fact, I can do just that using
getmemberproperties,
only I want to do it by extending the MembershipTool and registering
fields as
"harmless"), without special permissions.
I've stripped down the producto to a minimum and I basically have:
What you show here is your customization of the member info returned
but did you also add your custom properties in the member *data* tool?
(can be done in ZMI or via GS)
Raphael
-------------------------------
MembershipTool.py--------------------------
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from DateTime import DateTime
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.MembershipTool import MembershipTool as BaseTool
class MembershipTool(BaseTool):
meta_type = "ERS Membership Tool"
title="ERS custom membership tool"
security = ClassSecurityInfo()
plone_tool = 1
security.declarePublic('getMemberInfo')
def getMemberInfo(self, memberId=None):
"""
Return 'harmless' Memberinfo of any member, such as Full name,
Location, etc
"""
if not memberId:
member = self.getAuthenticatedMember()
else:
member = self.getMemberById(memberId)
if member is None:
return None
memberinfo = { 'fullname' : member.getProperty('fullname'),
'description' : member.getProperty('description'),
'location' : member.getProperty('location'),
'language' : member.getProperty('language'),
'home_page' : member.getProperty('home_page'),
'applicationname' :
member.getProperty('applicationname'),
'username' : member.getUserName(),
}
return memberinfo
MembershipTool.__doc__ = BaseTool.__doc__
InitializeClass(MembershipTool)
------------------------------- config.py--------------------------
from Products.CMFCore.permissions import AddPortalContent
ADD_CONTENT_PERMISSION = AddPortalContent
PROJECTNAME = "ERSExtendMemberInfo"
SKINS_DIR = 'skins'
GLOBALS = globals()
------------------------------- __init__.py--------------------------
from Products.CMFCore import utils
from Products.CMFCore.DirectoryView import registerDirectory
from Products.Archetypes.public import process_types, listTypes
from config import SKINS_DIR, GLOBALS, PROJECTNAME
import MembershipTool
registerDirectory(SKINS_DIR, GLOBALS)
tools = (MembershipTool.MembershipTool,)
def initialize(context):
content_types, constructors, ftis = process_types(
listTypes(PROJECTNAME),
PROJECTNAME)
utils.ToolInit(PROJECTNAME + ' Tool',
tools=tools,
product_name=PROJECTNAME,
icon="tool.gif",
).initialize(context)
Thanks for your help, btw ;D
----------------------------------------------------------------
Departamento de Ciencia de Computadores
Faculdade de Ciencias da Universidade do Porto
http://www.dcc.fc.up.pt/
_______________________________________________
Setup mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/setup
_______________________________________________
Setup mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/setup