Edgewall Software

Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#206 closed defect (fixed)

prefix loader should behave like virtual subfolder

Reported by: Waldemar Kornewald <wkornewald@…> Owned by: cmlenz
Priority: major Milestone: 0.5
Component: General Version: 0.4.4
Keywords: Cc:

Description

The current behavior is inconsistent. Let's imagine I load 'sub/bla.html'. Without prefixes, bla.html thinks it's located in the virtual folder 'sub'. If I have 'layout.html' at the root I have to include it via '../layout.html'. OTOH, with prefixes, bla.html thinks it's at the root although it was included as 'sub/bla.html', so I have to include 'layout.html' (without '../' prefix). That's not really consistent.

Also, if you want to include a template in the same folder you have to put the prefix in front: to load sub/blubb.html from sub/bla.html you have to include 'sub/blub.html' instead of just 'blub.html'.

Please make prefixes behave like subfolders.

Attachments (1)

prefixed-virtual-path.diff (2.4 KB) - added by Waldemar Kornewald <wkornewald@…> 16 years ago.
patch that does exactly that

Download all attachments as: .zip

Change History (5)

comment:1 in reply to: ↑ description ; follow-up: Changed 16 years ago by cmlenz

Replying to Waldemar Kornewald <wkornewald@freenet.de>:

The current behavior is inconsistent. Let's imagine I load 'sub/bla.html'. Without prefixes, bla.html thinks it's located in the virtual folder 'sub'. If I have 'layout.html' at the root I have to include it via '../layout.html'. OTOH, with prefixes, bla.html thinks it's at the root although it was included as 'sub/bla.html', so I have to include 'layout.html' (without '../' prefix). That's not really consistent.

That's because it's different behavior. Which is the point of the whole exercise.

Also, if you want to include a template in the same folder you have to put the prefix in front: to load sub/blubb.html from sub/bla.html you have to include 'sub/blub.html' instead of just 'blub.html'.

Are you sure?

Please make prefixes behave like subfolders.

I'm sorry, but if prefixes would behave like subfolders you could just use subfolders.

Changed 16 years ago by Waldemar Kornewald <wkornewald@…>

patch that does exactly that

comment:2 in reply to: ↑ 1 Changed 16 years ago by Waldemar Kornewald <wkornewald@…>

Replying to cmlenz:

Please make prefixes behave like subfolders.

I'm sorry, but if prefixes would behave like subfolders you could just use subfolders.

Nope. I use prefixes to map subfolders to different components of my website. I can't put all templates of all components into one common folder. Just look at Trac. You have a global trac/templates folder, but also trac/ticket/templates, and so on. Now, you solved the problem of name clashes by prefixing all templates with the component name (e.g., ticket_view.html), but that's redundant and unnecessary. It would be much better if you could simply map the component folders as subfolders ('ticket/view.html'). This is DRY and fully consistent with the behavior of real subfolders. Just, we're modeling a virtual folder structure.

For my purposes it would be even more useful if the prefix 'ticket' would only be recognized as a subfolder instead of a general prefix (IOW, prefix: 'ticket/' or more correctly: 'ticket' + os.sep).

comment:3 Changed 16 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from new to closed

Okay, I misunderstood you initially, the prefix loading was indeed broken. It should be fixed by [814].

comment:4 Changed 16 years ago by Waldemar Kornewald

Thanks a lot!

What do you think about also (or instead?) providing a prefix loader that handles folder names instead of simple file name prefixes? IOW the current filename.startswith(prefix) would become filename.startswith(prefix + os.sep).

That way, it would behave like a real component mapper without name clashes. Currently, if you have a 'component' prefix and then try to load 'component_manager.html' or 'component_manager/list.html' it might mistakenly use the 'component' prefix. In most real-world apps we'd have to add os.sep manually, anyway, to prevent name clashes.

Note: See TracTickets for help on using tickets.