def get_plone_site(connection, plone_path=None): """Return plone site.""" container = App() # app = container.unrestrictedTraverse('/') if plone_path: plone_paths = [path for path in plone_path.split(os.sep) if path] for path_name in plone_paths: container = container.get(path_name) plone_site = container if not plone_site: msg = "Error, path '{0}' do not exist".format(plone_path) connection.write(str(msg)) container._p_jar.close() return False if plone_site.meta_type != 'Plone Site': msg = "Error, path {0} is not a plone site, it's {1}".format(plone_path, plone_site.meta_type) connection.write(str(msg)) container._p_jar.close() return False else: return container, plone_site else: result = False for obj in container.values(): if obj.meta_type == 'Folder': # if plonesite come from mount point for plone in obj.values(): if plone.meta_type == 'Plone Site': result = plone else: if obj.meta_type == 'Plone Site' and not result: result = obj return container, result
def last_modified_zope_object_time(dconnection, unix_time=True, plone_path=None): """Get last modified zope object time.""" from zope.globalrequest import setRequest from Testing import makerequest app = App() app = makerequest.makerequest(app) # support plone.subrequest app.REQUEST['PARENTS'] = [app] setRequest(app.REQUEST) container = app.unrestrictedTraverse('/') undoable_transactions = container.undoable_transactions() if len(undoable_transactions) > 1: last_modified = undoable_transactions[0]['time'] if str2bool(unix_time): dconnection.write(str(last_modified.timeTime())) else: dconnection.write(str(last_modified.ISO())) app._p_jar.close()