[MIG][10.0] auth_session_timeout - #580
Conversation
002d954 to
e50a728
Compare
| @@ -1,23 +0,0 @@ | |||
| # Translation of Odoo Server. | |||
There was a problem hiding this comment.
@pedrobaeza - I could have sworn I saw the removal of PO files from migrations somewhere, but I now can't remember where. Am I being stupid here, or are these actually supposed to be removed?
There was a problem hiding this comment.
You need to remove POT files, not PO ones. Having PO files, although outdated, allow to reuse the sentences that haven't changed. Next Transifex synchronization will wipe out the non existing terms comparing with the newest POT file.
@atchuthan proposed in OCA/maintainer-tools#232 that we should avoid the commits that updates the languages in the migration process, but I'm evaluating if this is a good idea at all.
There was a problem hiding this comment.
Thanks for the explanation @pedrobaeza - I think that the issue that you linked is the one that made me think this way. I'll add back 😄
41fd23c to
85182ac
Compare
bed5b78 to
9f80777
Compare
|
Coverage added in all but Ready for review |
| Usage | ||
| ===== | ||
|
|
||
| Setup the session parameters as described above. |
There was a problem hiding this comment.
You might want to move the above section in this one.
There was a problem hiding this comment.
I thought about it, but I'm honestly torn. They are more of a configuration instruction vs usage. Maybe instead I add Use system like normal in place of the note to configure using instructions?
|
+1 |
9f80777 to
3807cce
Compare
|
Good to merge? |
yajo
left a comment
There was a problem hiding this comment.
Just a little thing, not requirement.
| _inherit = 'ir.config_parameter' | ||
|
|
||
| @api.model | ||
| @tools.ormcache(skiparg=0) |
There was a problem hiding this comment.
What should be the cache key? skiparg is deprecated. Better use @tools.ormcache("self.env.db") IMHO.
There was a problem hiding this comment.
OK so I'm a bit confused here & I am pretty sure this is what is causing the current error.
What are we going for with this cache? Do you maybe have an example of some other code that does something similar, or would mind giving a quick breakdown for me? My google-fu is turning up zilch here.
| session = http.request.session | ||
| session_store = http.root.session_store | ||
| ConfigParam = http.request.env['ir.config_parameter'] | ||
| delay, urls = ConfigParam.get_session_parameters(db) |
There was a problem hiding this comment.
No need for the db parameter anymore, right?
|
Thanks for the reviews @yajo & @nilshamerlinck - both points fixed. |
|
Bots still ❌ |
e914399 to
21e6177
Compare
| cr.close() | ||
| return delay, urls | ||
| @api.model | ||
| @tools.ormcache('self.env.db') |
There was a problem hiding this comment.
@lasley, about #580 (comment) (I answer here so this does not get hidden)...
I learned the hard way to use ormcache when developing website_sale_wishlist. It turns out it's a pretty neat tool. It creates a key by the arguments you pass to it, and stores the method result in a cache attached to your current self.env, so further calls to the method return the cached result instead of executing the method again and again.
It's most useful when a method is CPU-expensive, is called quite often, and it returns a predictable result based on the incoming arguments/environment.
In old api, we had the skipargs, which was used to skip a number of arguments and use the rest to make a cache. For instance, if your method had cr, uid, ids, key, context=None and the result was the same no matter the cr, uid, you'd say skipargs=2.
Since v9, we have the new notation where you give the name of the arguments that form the cache key. Since self is always the first argument, you can use that one (and properties of it) to form a key.
When you change your env (like self.with_context(goal="I wanna be a pirate")), cache is empty. This is logical because a different context/cr/uid usually yields different results almost everywhere. However, when you apply cache to a method, it gets a clear_cache() method that you can use later to clear it without having to change your environment.
There was a problem hiding this comment.
Thanks for the excellent explanation @yajo - this totally clarifies what we are going for here & I think points me in the right direction. I'll make the update soon 😄
|
Oops seems I forgot about this. With the excellent explanation @yajo gave regarding the cache, I abstracted that a decent replacement for the It seems OCA/OCB just synced up with odoo/odoo though, so now we're red for other reasons. Oh the joy! |
|
Cherry picked. My bad, I forgot this |
a331714 to
779c01a
Compare
|
I'm getting this error installing this module: |
|
Oops this also reminded me that some of these methods needed to be switched around now that we're not worrying about compat. I'll submit a fix in about 30m |
f9aeace to
6c01b29
Compare
518bf14 to
b1dfeb2
Compare
|
Alright we're ready for a final review here, then I'll squash up |
|
Still no luck with tests 😕 |
8446a1a to
ea711ff
Compare
Yeah got me dude. It seems we're fighting an uphill battle with Travis and I am damned close to just removing tests from multiple PRs until 🍏 |
|
Yup I've got nothing - it's failing on a bunch of modules unrelated to me. The option I see is to remove all tests from this module, but we obviously still have a timebomb on our hands. From a global perspective, this is an issue I am encountering in numerous places. My immediate thought on a solution is that all modules should be tested independently from each other, instead of inline with each other. That covers up incompatibility problems though, so I'm at a loss. |
|
exclude/include is no solution? |
|
It is technically, but we've already done this in Biggest issue though is that only the first test case is available on Runbot, so we miss out on functional review of anything excluded. |
|
Welp exclude is what I went with - better than removing tests. Thanks for reminding me that exists Holger. Hopefully our server-tools split helps with this. Or our MQT redesign. Or something. Furthermore, we are finally 🍏 (+1y1m later 😆 ) |
|
Yikes, It's not fun having tests that get broken when an addon is installed... Well, in any case could you squash the migration commits for merge? |
* Bump versions * Installable to True * Add Usage section to ReadMe w/ Runbot link * `_crypt_context` now directly exposes the `CryptContext` * Change all instances of openerp to odoo * Add test coverage to IrConfigParameter * Add test coverage for res.users * Remove db from `get_session_parameters` method call * Remove deprecated skiparg for ormcache * Fix tests & lint * Switch cache to use self.cr.dbname * Fix ormcache
* Module auth_session_timeout: --------------------------- * Refactor to allow other modules to inherit and augment or override the following: ** Session expiry time (deadline) calculation ** Ignored URLs ** Final session expiry (with possibility to late-abort) * Re-ordered functionality to remove unnecessary work, as this code is called very often. * Do not expire a session if delay gets set to zero (or unset / false) * WIP * Fixed flake8 lint errors * Fixed flake8 lint errors * WIP * WIP * WIP * WIP * WIP * WIP * Module: auth-session-timeout: Refactor ResUser tests to use `unittest.mock` patching * Module: auth_session_timeout: Fixed flake8 lint errors * Module: auth_session_timeout: Fixed flake8 lint errors
* Deprecate backwards compatibility methods that were retained during v9 rework * Upgrade API and rename a few things for PEP-8 * Switch to HttpCase for tests * Switch to isolated build
daad3fa to
00e7930
Compare
|
Squashed! |
Syncing from upstream OCA/server-tools (13.0)
WIP - I need to add test coverage for
res.users_crypt_contextnow directly exposes theCryptContext