Introduction
The python iuserprofile example is extracted from the most popular open source projects, you can refer to the following example for usage.
Programming language: Python
Namespace/package name: ploneintranetuserprofilecontentuserprofile
Example#1File:
stream.pyProject:
mingtak/ploneintranet
def get_statusupdates(self):
''' This will return all the StatusUpdates which are not comments
The activity are sorted by reverse chronological order
'''
container = piapi.microblog.get_microblog()
if self.microblog_context:
# support ploneintranet.workspace integration
statusupdates = container.context_values(
self.microblog_context,
limit=self.count,
tag=self.tag
)
elif IUserProfile.providedBy(self.context):
# Get the updates for this user
statusupdates = container.user_values(
self.context.username,
limit=self.count,
tag=self.tag
)
else:
# default implementation
statusupdates = container.values(
limit=self.count,
tag=self.tag
)
statusupdates = self.filter_statusupdates(statusupdates)
return statusupdates
Example#2File:
indexers.pyProject:
smcmahon/ploneintranet
def friendly_type_name(obj):
"""
Index for the friendly name of any content type
:param obj: The Plone content object to index
:type obj: IContentish
:return: Friendly content type name
:rtype: str
"""
default_name = obj.Type()
# If the object is a file get the friendly name of the mime type
if IFile.providedBy(obj):
mtr = api.portal.get_tool(name='mimetypes_registry')
primary_field_info = IPrimaryFieldInfo(obj)
if not primary_field_info.value:
return default_name
if hasattr(primary_field_info.value, "contentType"):
contenttype = primary_field_info.value.contentType
try:
mimetypeitem = mtr.lookup(contenttype)
except MimeTypeException as msg:
logger.warn(
'mimetype lookup failed for %s. Error: %s',
obj.absolute_url(),
str(msg)
)
return default_name
mimetype_name = mimetypeitem[0].name()
if mimetype_name != contenttype:
return mimetype_name
elif IUserProfile.providedBy(obj):
return 'Person'
return default_name