def handleAdd(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return typeName = self.tileType.__name__ context = self.context # Look up if our context supports tiles, if not # pick default view instead if not ILayoutAware(context, None): default_page_view = getMultiAdapter((context, self.request), name='default_page') default_page = default_page_view.getDefaultPage() context = default_page and context[default_page] or context context = ILayoutAware(context, None) # Traverse to a new tile in the context, with no data tile = context.restrictedTraverse( '@@%s/%s' % (typeName, self.tileId,)) dataManager = ITileDataManager(tile) dataManager.set(data) # Look up the URL - we need to do this after we've set the data to # correctly account for transient tiles tileURL = absoluteURL(tile, self.request) contextURL = absoluteURL(tile.context, self.request) tileRelativeURL = tileURL if tileURL.startswith(contextURL): tileRelativeURL = '.' + tileURL[len(contextURL):] notify(ObjectCreatedEvent(tile)) notify(ObjectAddedEvent(tile, self.context, self.tileId)) IStatusMessage(self.request).addStatusMessage( _(u"Tile created at ${url}", mapping={'url': tileURL}), type=u'info', ) # Calculate the edit URL and append some data in a JSON structure, # to help the UI know what to do. url = getEditTileURL(tile, self.request) tileDataJson = {} tileDataJson['action'] = "save" tileDataJson['mode'] = "add" tileDataJson['url'] = tileRelativeURL tileDataJson['tile_type'] = typeName tileDataJson['id'] = tile.id url = appendJSONData(url, 'tiledata', tileDataJson) self.request.response.redirect(url)
def handleSave(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return typeName = self.tileType.__name__ # Traverse to a new tile in the context, with no data tile = self.context.restrictedTraverse('@@%s/%s' % ( typeName, self.tileId, )) dataManager = ITileDataManager(tile) dataManager.set(data) # Look up the URL - we need to do this after we've set the data to # correctly account for transient tiles tileURL = absoluteURL(tile, self.request) contextURL = absoluteURL(tile.context, self.request) tileRelativeURL = tileURL if tileURL.startswith(contextURL): tileRelativeURL = '.' + tileURL[len(contextURL):] notify(ObjectModifiedEvent(tile)) # Get the tile URL, possibly with encoded data IStatusMessage(self.request).addStatusMessage(_(u"Tile saved", ), type=u'info') # Calculate the edit URL and append some data in a JSON structure, # to help the UI know what to do. url = getEditTileURL(tile, self.request) tileDataJson = {} tileDataJson['action'] = "save" tileDataJson['mode'] = "edit" tileDataJson['url'] = tileRelativeURL tileDataJson['tile_type'] = typeName tileDataJson['id'] = tile.id url = appendJSONData(url, 'tiledata', tileDataJson) self.request.response.redirect(url)
def handleSave(self, action): data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return typeName = self.tileType.__name__ # Traverse to a new tile in the context, with no data tile = self.context.restrictedTraverse('@@%s/%s' % (typeName, self.tileId,)) dataManager = ITileDataManager(tile) dataManager.set(data) # Look up the URL - we need to do this after we've set the data to # correctly account for transient tiles tileURL = absoluteURL(tile, self.request) contextURL = absoluteURL(tile.context, self.request) tileRelativeURL = tileURL if tileURL.startswith(contextURL): tileRelativeURL = '.' + tileURL[len(contextURL):] notify(ObjectModifiedEvent(tile)) # Get the tile URL, possibly with encoded data IStatusMessage(self.request).addStatusMessage(_(u"Tile saved",), type=u'info') # Calculate the edit URL and append some data in a JSON structure, # to help the UI know what to do. url = getEditTileURL(tile, self.request) tileDataJson = {} tileDataJson['action'] = "save" tileDataJson['mode'] = "edit" tileDataJson['url'] = tileRelativeURL tileDataJson['tile_type'] = typeName tileDataJson['id'] = tile.id url = appendJSONData(url, 'tiledata', tileDataJson) self.request.response.redirect(url)
def nextURL(self, tile): # Calculate the edit URL and append some data in a JSON structure, to # help the UI know what to do. tileTypeName = self.tileType.__name__ tileURL = absoluteURL(tile, self.request) contextURL = absoluteURL(tile.context, self.request) tileRelativeURL = tileURL if tileURL.startswith(contextURL): tileRelativeURL = '.' + tileURL[len(contextURL):] tileEditURL = getEditTileURL(tile, self.request) tileDataJSON = {} tileDataJSON['action'] = "save" tileDataJSON['mode'] = "edit" tileDataJSON['url'] = tileRelativeURL tileDataJSON['tile_type'] = tileTypeName tileDataJSON['id'] = tile.id url = appendJSONData(tileEditURL, 'tiledata', tileDataJSON) return url
def handleCancel(self, action): tileDataJson = {} tileDataJson['action'] = "cancel" url = self.request.getURL() url = appendJSONData(url, 'tiledata', tileDataJson) self.request.response.redirect(url)
def handleCancel(self, action): url = appendJSONData(self.context.absolute_url(), '#', {'action': "cancel"}) self.request.response.redirect(url)
def handleCancel(self, action): url = appendJSONData(self.action, '#', {'action': "cancel"}) url = url.replace('@@' + self.name.replace('_', '-') + '/', '@@') self.request.response.redirect(url)
def handleCancel(self, action): url = appendJSONData(self.action, "#", {"action": "cancel"}) url = url.replace("@@" + self.name.replace("_", "-") + "/", "@@") self.request.response.redirect(url)