~yeliabmas/sloecode/wiki-file-creation

« back to all changes in this revision

Viewing changes to sloecode/controllers/project.py

  • Committer: Sam Bailey
  • Date: 2012-06-22 12:33:18 UTC
  • Revision ID: yeliabmas@gmail.com-20120622123318-uii4owxend3f4q96
Directory view adapter working correctly

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from sloecode.wikkidviewadapters.factory import ViewAdapterFactory
41
41
 
42
42
log = logging.getLogger(__name__)
 
43
factory = ViewAdapterFactory()
43
44
 
44
45
def get_context(path):
45
46
    """
185
186
    def wiki(self, project_name, path=''):
186
187
        """
187
188
        Render the wiki for the project.
 
189
        This includes everything that uses a Wikkid View.
188
190
        """
189
191
 
190
192
        # log.info(request.environ)
207
209
                #Translate bzr user to Wikkid user
208
210
                environ['wikkid.user'] = create_bzr_user_from_author_string("%s <%s>"%(user.name, user.email))
209
211
 
210
 
                factory = ViewAdapterFactory()
211
212
                adapter = factory.get_view_adapter(app, environ)
212
213
 
213
214
                app_request, path = app.preprocess_environ(environ)
235
236
        """
236
237
 
237
238
        #Construct the current sloecode+wikkid path
238
 
        path = 'p/'+project_name+'/wiki/'+path
239
 
 
240
 
        #Strip the trailing / if there is one
241
 
        if path[len(path) - 1] == '/':
242
 
            path = path[:-1]
 
239
        prefix = urllib.unquote(h.url.current())
 
240
        prefix = prefix[:-len("/+newfile")]
 
241
        prefix = prefix[1:]
 
242
        log.info("Prefix: '%s', current url: '%s'", prefix, h.url.current())
243
243
 
244
244
        #Test that the project exists and has a branch called 'wiki'
245
245
        projects = Project.get(name=project_name)
251
251
                return self.render('/wiki/newfile.html',
252
252
                               {'project': existing_project,
253
253
                                'repo': repo,
254
 
                                'path': path})
 
254
                                'path': prefix})
255
255
        abort(404)