Skip to content
Snippets Groups Projects
Commit 78006fc7 authored by Marc Troelitzsch's avatar Marc Troelitzsch Committed by Adam Williamson
Browse files

fix: Automatically initialize `Site` after successful `clientlogin`

This fix ensures that the `Site` object is properly initialized after a
successful `Site.clientlogin`, matching the existing behavior of
`Site.login()`.

Previously, developers needed to manually invoke `Site.site_init()`
after using `clientlogin`, which could lead to unexpected issues,
especially during migration from `login` to `clientlogin`.

For example, the following code works with `Site.login`:

```python
site = mwclient.Site('localhost:8080', path='/', scheme='http')
site.login('username', 'super-secret')
with open('/tmp/image.png', 'rb') as f:
    site.upload(f, 'image.png', 'Some test upload', ignore=True)
```

But when using `Site.clientlogin` without this fix, the code would fail
with `mwclient.errors.InsufficientPermission: image.png`:

```python
site = mwclient.Site('localhost:8080', path='/', scheme='http')
site.clientlogin(username='username', password='super-secret')
with open('/tmp/image.png', 'rb') as f:
    site.upload(f, 'image.png', 'Some test upload', ignore=True)
```
parent c0809796
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment