作弊穿越

发布于 2024-10-24 05:47:00 字数 549 浏览 4 评论 0原文

我正在开发一个 plone4 网站,每个用户都有一个可排序的物品库存。 ATFolder 的folder_content 视图非常适合此目的。唯一的问题是,而不是像这样的 URL:

/site/user/inventory

或这样的

/site/inventory/user

URL 应该是:

/site/inventory

我想过几种解决方案,但每个解决方案都有自己的疑问。

  • 根据经过身份验证的用户,使库存内容动态化。我什至不知道这在飞机上是否可行。
  • 以某种方式欺骗横向机制,因此 /site/inventory 渲染 /site/inventory/user。
  • 在渲染视图之前更改上下文。再次,不知道是否可以。
  • 将库存作为 ATCTContent 的子类,将库存数据作为用户注释存储,并自行开发订购代码。这是我试图避免的选择。

你会怎么办?

谢谢。

I'm developing a plone4 site on which every user have a sortable inventory of items. The ATFolder's folder_content view is ideal for this. The only problem is that instead of an URL like this:

/site/user/inventory

or this

/site/inventory/user

the url should be:

/site/inventory

I've thought in several solution, but each one have its own doubts.

  • Make the inventory content dynamic, depending on the authenticated user. I don't even know if this is possible on plone.
  • Somehow to cheat the transversal mechanism, so /site/inventory render /site/inventory/user.
  • Change the context before rendering the view. Again, don't know if possible.
  • Make inventory a subclass of ATCTContent, store the inventory data as annotation on the user and develop the ordering code all by myself. This is the option I'm trying to avoid.

What would you do?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉酒的小男人 2024-10-31 05:47:00

好吧,定义一个 inventory 视图然后使用经过身份验证的用户来呈现其内容将很容易,这可以是对存储在 /site/users/user 的有序文件夹的简单委托/文件夹。

您必须记住的一件事是用户身份验证发生在遍历之后。这意味着当实例化视图时(调用它的 __init__ 方法),尚未确定用户,因为这是在遍历期间发生的。在视图 __call__ 中或从其模板中查找您的用户。

Well, it'll be easy to define a inventory view that then uses the Authenticated User to render it's contents, which could be a simple delegation to an ordered folder that is stored at /site/users/user/folder.

The one thing that you have to remember is that user authentication happens after traversal. This means that when a view is instantiated (it's __init__ method is called) there is no user determined yet because that happens during traversal. Look up your user in the view __call__ or from it's template instead.

固执像三岁 2024-10-31 05:47:00

让文件夹内容显示不是该文件夹内容的内容是crraaaaAAAAzytalk。 :) 不要这样做。每个用户都有一个文件夹 ( /inventory/user ) 或创建一个名为 inventory.html 的自定义视图。你可以使 /inventory sho /inventory user 但这是尝试使 Plone 成为非克隆事物的第一步,而这种方式是一个痛苦的世界。

我不知道为什么你不能直接将其命名为/inventory/user?看起来很容易。然后通过仪表板链接在用户视图中粘贴一个操作,就完成了! :-)

Plone 是一个内容管理系统。使用它,因为它应该被使用,你会很高兴。试图强迫它做它不想要的事情就像试图用装饰艺术雕塑建造一辆跑车。它最终可能看起来很棒,但运行起来可能不太好。 :-)

Having folder contents show contents that are not the contents of the folder is crraaaaAAAAzytalk. :) Don't do it. Either have a folder per user ( /inventory/user ) or make a custom view called inventory.html. You can make /inventory sho /inventory user but that is one step towards trying to make Plone to non-ploneish things, and that way lies a world of pain.

I don't know why you couldn't just call it /inventory/user? Seems easy enough. Then stick an action in the user viewlet, by the dashboard link, and your done! :-)

Plone is a content management system. Use it for that, as it's supposed to be used, and you'll be happy. Trying to force it to do things it doesn't want is like trying to build a sportscar out of a art deco sculpture. It might end up looking awesome, but it won't run very well. :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文