218
218
# Make sure filename doesn't start with a slash
219
219
if filename[0] == '/':
220
220
filename = filename[1:]
221
path = save_location + filename
221
save_path = save_location + filename
223
223
# Check to see if this file exists
224
224
branch = get_wiki_branch_for_project(project_name)
225
225
filestore = BranchFileStore(branch.get_bzrlib_branch())
226
226
resource_factory = ResourceFactory(filestore)
227
resource = resource_factory.get_resource_at_path(path)
227
resource = resource_factory.get_resource_at_path(save_path)
229
229
#This file already exists.
230
230
if resource.file_resource is not None:
231
231
h.flash("This file already exists.")
232
return formencode.htmlfill.render(self.new_file(project_name), defaults=request.params)
232
return formencode.htmlfill.render(self.new_file(project_name, path=path), defaults=request.params)
234
234
# This is a directory.
235
235
if resource.dir_resource is not None:
236
236
h.flash("A directory already exists with this name.")
237
return formencode.htmlfill.render(self.new_file(project_name), defaults=request.params)
237
return formencode.htmlfill.render(self.new_file(project_name, path=path), defaults=request.params)
239
save_path += '/+save'
240
240
# Are there any checks that need to be performed on the path???
241
return redirect(h.url(controller='wiki', action='wiki', project_name=project_name, path=path, content=content, description=description))
241
return redirect(h.url(controller='wiki', action='wiki', project_name=project_name, path=save_path, content=content, description=description))
243
def load_template(self, filename):
243
def load_page_template(self, filename):
244
244
"""Loads a template in json format."""
245
245
template = Template.get_one(name=filename)