Hi, I'm playing around with devpi themes. My goal is to create a nice theme for my company. I'd like to add extra information to some pages, like the index page or the main page. I added a snippet of code which produces an "index inheritance diagram" on each index page display. Because the company I work for is not that small, these diagrams can get strange. A sample diagram: index inheritance diagram <https://lh3.googleusercontent.com/--9yr5WSohOc/VZ0BL6xN3YI/AAAAAAAAAAs/8wZq4...>. Each box is an index, I intentionally removed all user and index names, except for root/pypi. It's not my indices, please don't judge me for the design :) I'm concerned about performance here. First of all, currently I generate those on display action, which doesn't seem the way to go. Could devpi provide a hook so that I'm able to regenerate a diagram on an index update event? Additionally, I'd like to add more information to an index page and the root pages. So the question is: Could functions in devpi_web.views expose more data in get_index() and root()? Potentially other functions? I know I can always get the data with python snippets in the templates, but it all takes precious time. For instance, in my company, some indices are regular user indices, some of them are project indices. I'd like to sort the list of indices on the root page: display the project ones first, and user indices below. The way I would see this is the custom_data property of an index. The bottom line: I think people could easily create fancier themes if the devpi web views functions exposed more data to the templates, even if that data is not used in the default theme. It would be great to get the full indexconfig json structure for each index in both get_index() and root() functions from devpi_web.views module. Now I'm not sure how much more data others might want to get there. I hope these things make sense. Any thoughts?
On 8 Jul 2015, at 13:33, Andrzej Ostrowski wrote:
Hi,
I'm playing around with devpi themes. My goal is to create a nice theme for my company. I'd like to add extra information to some pages, like the index page or the main page. I added a snippet of code which produces an "index inheritance diagram" on each index page display.
Because the company I work for is not that small, these diagrams can get strange. A sample diagram: index inheritance diagram <https://lh3.googleusercontent.com/--9yr5WSohOc/VZ0BL6xN3YI/AAAAAAAAAAs/8wZq4...>. Each box is an index, I intentionally removed all user and index names, except for root/pypi. It's not my indices, please don't judge me for the design :)
I'm concerned about performance here. First of all, currently I generate those on display action, which doesn't seem the way to go. Could devpi provide a hook so that I'm able to regenerate a diagram on an index update event?
I'm looking into that. For now you could use the _sro method of a stage. It returns a list of stage objects. With something like ','.join(x.name for x in self._sro()) you could build a unique string which you can then hash with something like md5 to build a cache key. Either put the cache into a thread local or onto the filesystem.
Additionally, I'd like to add more information to an index page and the root pages. So the question is: Could functions in devpi_web.views expose more data in get_index() and root()? Potentially other functions? I know I can always get the data with python snippets in the templates, but it all takes precious time.
For instance, in my company, some indices are regular user indices, some of them are project indices. I'd like to sort the list of indices on the root page: display the project ones first, and user indices below.
The way I would see this is the custom_data property of an index.
The bottom line: I think people could easily create fancier themes if the devpi web views functions exposed more data to the templates, even if that data is not used in the default theme. It would be great to get the full indexconfig json structure for each index in both get_index() and root() functions from devpi_web.views module.
Now I'm not sure how much more data others might want to get there. I hope these things make sense.
Any thoughts?
For this you can use regular Pyramid functionality. With the devpiserver_pyramid_configure hook you can write a plugin that adds configuration to Pyramid. It is used by devpi-web itself. One way to add additional things is add_request_method. The request also has access to the context of the view. This is also used by devpi-web. See http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/hooks.html... Another way is the Before Render Event: http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/hooks.html... With that you have access to the dictionary that is returned by a view. It looks like you also have access to more information: http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/templates.... I haven't used this method myself yet, but it looks promising if you need access to all the info as in your example. With these you have access to all the internals, but won't have a guaranteed API. I can't say how stable the various parts will be, we don't want to lock ourself in by promising a stable API at this point. I hope this helps you. Feel free to ask more questions as needed. Regards, Florian Schulze
Many thanks for the tips Florian! There is one thing which is really hard for me to figure out: how do I use the devpiserver_pyramid_configure hook? The documentation is not that great in the devpi-server experimental hooks section. My idea is: Create a python package named something like "company-internal-devpi-web-theme". The package contains python code snippets which are used in customized chameleon templates, all included in the package. The package could be installed with pip, together with devpi-server and devpi-web. And then the devpi server would be started with the --theme flag. Perhaps I missed something obvious, but I don't really see where I could inject my own devpiserver_pyramid_configure hook in such scenario. I don't want to monkeypatch the devpi-web package. With your previous answers, I was thinking about adding a new view with the route "/{user}/{index}/+inheritance_diagram". There are currently 112 indices within my company, I was thinking of adding a route "/+orgchart" which would point to a view with the inheritance graph of all indices. Additionally, I think it would be nice to store some statistics somewhere on the server side to get rid of old and unused indices. People here come and go, and I'm pretty sure that there are "dead" indices that contain packages that have not been used for quite some time. It's not burning, it would be just nice to clean up from time to time. But this is another topic. Sorry if my questions are silly, but I'm new to web development in general. My lack of knowledge extends to pyramid, chameleon, javascript and all that stuff. I must say though, that I'm having a lot of fun with that. :-) Cheers! Andrzej
I made an example theme plugin which implements the hooks for everything you asked about: https://github.com/fschulze/devpi-example-theme This shows all the advanced hooking techniques of devpi and pyramid I talked about. I hope this helps. Feel free to ask more if needed. Regards, Florian Schulze On 29 Jul 2015, at 11:08, Andrzej Ostrowski wrote:
Many thanks for the tips Florian!
There is one thing which is really hard for me to figure out: how do I use the devpiserver_pyramid_configure hook? The documentation is not that great in the devpi-server experimental hooks section.
My idea is: Create a python package named something like "company-internal-devpi-web-theme". The package contains python code snippets which are used in customized chameleon templates, all included in the package. The package could be installed with pip, together with devpi-server and devpi-web. And then the devpi server would be started with the --theme flag.
Perhaps I missed something obvious, but I don't really see where I could inject my own devpiserver_pyramid_configure hook in such scenario. I don't want to monkeypatch the devpi-web package.
With your previous answers, I was thinking about adding a new view with the route "/{user}/{index}/+inheritance_diagram". There are currently 112 indices within my company, I was thinking of adding a route "/+orgchart" which would point to a view with the inheritance graph of all indices. Additionally, I think it would be nice to store some statistics somewhere on the server side to get rid of old and unused indices. People here come and go, and I'm pretty sure that there are "dead" indices that contain packages that have not been used for quite some time. It's not burning, it would be just nice to clean up from time to time. But this is another topic.
Sorry if my questions are silly, but I'm new to web development in general. My lack of knowledge extends to pyramid, chameleon, javascript and all that stuff. I must say though, that I'm having a lot of fun with that. :-)
Cheers! Andrzej
-- You received this message because you are subscribed to the Google Groups "devpi-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to devpi-dev+...@googlegroups.com. To post to this group, send email to devp...@googlegroups.com. Visit this group at http://groups.google.com/group/devpi-dev. For more options, visit https://groups.google.com/d/optout.
is there any way to set a kind of "autoreload" on devpi-server ? I'm currently working on a custom theme and a would avoid to start/stop the server on any change. Thanks in advance Stefano Il giorno sabato 1 agosto 2015 14:01:19 UTC+2, Florian Schulze ha scritto:
I made an example theme plugin which implements the hooks for everything you asked about: https://github.com/fschulze/devpi-example-theme
This shows all the advanced hooking techniques of devpi and pyramid I talked about.
I hope this helps.
Feel free to ask more if needed.
Regards, Florian Schulze
On 29 Jul 2015, at 11:08, Andrzej Ostrowski wrote:
Many thanks for the tips Florian!
There is one thing which is really hard for me to figure out: how do I use the devpiserver_pyramid_configure hook? The documentation is not that great in the devpi-server experimental hooks section.
My idea is: Create a python package named something like "company-internal-devpi-web-theme". The package contains python code snippets which are used in customized chameleon templates, all included in the package. The package could be installed with pip, together with devpi-server and devpi-web. And then the devpi server would be started with the --theme flag.
Perhaps I missed something obvious, but I don't really see where I could inject my own devpiserver_pyramid_configure hook in such scenario. I don't want to monkeypatch the devpi-web package.
With your previous answers, I was thinking about adding a new view with the route "/{user}/{index}/+inheritance_diagram". There are currently 112 indices within my company, I was thinking of adding a route "/+orgchart" which would point to a view with the inheritance graph of all indices. Additionally, I think it would be nice to store some statistics somewhere on the server side to get rid of old and unused indices. People here come and go, and I'm pretty sure that there are "dead" indices that contain packages that have not been used for quite some time. It's not burning, it would be just nice to clean up from time to time. But this is another topic.
Sorry if my questions are silly, but I'm new to web development in general. My lack of knowledge extends to pyramid, chameleon, javascript and all that stuff. I must say though, that I'm having a lot of fun with that. :-)
Cheers! Andrzej
-- You received this message because you are subscribed to the Google Groups "devpi-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to devpi-...@googlegroups.com <javascript:>. To post to this group, send email to dev...@googlegroups.com <javascript:>. Visit this group at http://groups.google.com/group/devpi-dev. For more options, visit https://groups.google.com/d/optout.
Try the CHAMELEON_RELOAD=true environment variable. See http://chameleon.readthedocs.org/en/latest//configuration.html?highlight=cha... Regards, Florian Schulze On 15 Apr 2016, at 12:21, Stefano Apostolico wrote:
is there any way to set a kind of "autoreload" on devpi-server ?
I'm currently working on a custom theme and a would avoid to start/stop the server on any change.
Thanks in advance
Stefano
Il giorno sabato 1 agosto 2015 14:01:19 UTC+2, Florian Schulze ha scritto:
I made an example theme plugin which implements the hooks for everything you asked about: https://github.com/fschulze/devpi-example-theme
This shows all the advanced hooking techniques of devpi and pyramid I talked about.
I hope this helps.
Feel free to ask more if needed.
Regards, Florian Schulze
On 29 Jul 2015, at 11:08, Andrzej Ostrowski wrote:
Many thanks for the tips Florian!
There is one thing which is really hard for me to figure out: how do I use the devpiserver_pyramid_configure hook? The documentation is not that great in the devpi-server experimental hooks section.
My idea is: Create a python package named something like "company-internal-devpi-web-theme". The package contains python code snippets which are used in customized chameleon templates, all included in the package. The package could be installed with pip, together with devpi-server and devpi-web. And then the devpi server would be started with the --theme flag.
Perhaps I missed something obvious, but I don't really see where I could inject my own devpiserver_pyramid_configure hook in such scenario. I don't want to monkeypatch the devpi-web package.
With your previous answers, I was thinking about adding a new view with the route "/{user}/{index}/+inheritance_diagram". There are currently 112 indices within my company, I was thinking of adding a route "/+orgchart" which would point to a view with the inheritance graph of all indices. Additionally, I think it would be nice to store some statistics somewhere on the server side to get rid of old and unused indices. People here come and go, and I'm pretty sure that there are "dead" indices that contain packages that have not been used for quite some time. It's not burning, it would be just nice to clean up from time to time. But this is another topic.
Sorry if my questions are silly, but I'm new to web development in general. My lack of knowledge extends to pyramid, chameleon, javascript and all that stuff. I must say though, that I'm having a lot of fun with that. :-)
Cheers! Andrzej
-- You received this message because you are subscribed to the Google Groups "devpi-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to devpi-...@googlegroups.com <javascript:>. To post to this group, send email to dev...@googlegroups.com <javascript:>. Visit this group at http://groups.google.com/group/devpi-dev. For more options, visit https://groups.google.com/d/optout.
(Sorry if this gets double posted, I had some issues sending this mail) I made an example theme plugin which implements the hooks for everything you asked about: https://github.com/fschulze/devpi-example-theme This shows all the advanced hooking techniques of devpi and pyramid I talked about. I hope this helps. Feel free to ask more if needed. Regards, Florian Schulze On 29 Jul 2015, at 11:08, Andrzej Ostrowski wrote:
Many thanks for the tips Florian!
There is one thing which is really hard for me to figure out: how do I use the devpiserver_pyramid_configure hook? The documentation is not that great in the devpi-server experimental hooks section.
My idea is: Create a python package named something like "company-internal-devpi-web-theme". The package contains python code snippets which are used in customized chameleon templates, all included in the package. The package could be installed with pip, together with devpi-server and devpi-web. And then the devpi server would be started with the --theme flag.
Perhaps I missed something obvious, but I don't really see where I could inject my own devpiserver_pyramid_configure hook in such scenario. I don't want to monkeypatch the devpi-web package.
With your previous answers, I was thinking about adding a new view with the route "/{user}/{index}/+inheritance_diagram". There are currently 112 indices within my company, I was thinking of adding a route "/+orgchart" which would point to a view with the inheritance graph of all indices. Additionally, I think it would be nice to store some statistics somewhere on the server side to get rid of old and unused indices. People here come and go, and I'm pretty sure that there are "dead" indices that contain packages that have not been used for quite some time. It's not burning, it would be just nice to clean up from time to time. But this is another topic.
Sorry if my questions are silly, but I'm new to web development in general. My lack of knowledge extends to pyramid, chameleon, javascript and all that stuff. I must say though, that I'm having a lot of fun with that. :-)
Cheers! Andrzej
-- You received this message because you are subscribed to the Google Groups "devpi-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to devpi-dev+...@googlegroups.com. To post to this group, send email to devp...@googlegroups.com. Visit this group at http://groups.google.com/group/devpi-dev. For more options, visit https://groups.google.com/d/optout.
participants (4)
-
Andrzej Ostrowski
-
Florian Schulze
-
Florian Schulze
-
Stefano Apostolico