| 299 | @python_2_unicode_compatible |
| 300 | class AnonymousUser(object): |
| 301 | id = None |
| 302 | pk = None |
| 303 | username = '' |
| 304 | is_staff = False |
| 305 | is_active = False |
| 306 | is_superuser = False |
| 307 | _groups = EmptyManager(Group) |
| 308 | _user_permissions = EmptyManager(Permission) |
| 309 | |
| 310 | def __init__(self): |
| 311 | pass |
| 312 | |
| 313 | def __str__(self): |
| 314 | return 'AnonymousUser' |
| 315 | |
| 316 | def __eq__(self, other): |
| 317 | return isinstance(other, self.__class__) |
| 318 | |
| 319 | def __ne__(self, other): |
| 320 | return not self.__eq__(other) |
| 321 | |
| 322 | def __hash__(self): |
| 323 | return 1 # instances always return the same hash value |
| 324 | |
| 325 | def save(self): |
| 326 | raise NotImplementedError("Django doesn't provide a DB representation for AnonymousUser.") |
| 327 | |
| 328 | def delete(self): |
| 329 | raise NotImplementedError("Django doesn't provide a DB representation for AnonymousUser.") |
| 330 | |
| 331 | def set_password(self, raw_password): |
| 332 | raise NotImplementedError("Django doesn't provide a DB representation for AnonymousUser.") |
| 333 | |
| 334 | def check_password(self, raw_password): |
| 335 | raise NotImplementedError("Django doesn't provide a DB representation for AnonymousUser.") |
| 336 | |
| 337 | @property |
| 338 | def groups(self): |
| 339 | return self._groups |
| 340 | |
| 341 | @property |
| 342 | def user_permissions(self): |
| 343 | return self._user_permissions |
| 344 | |
| 345 | def get_group_permissions(self, obj=None): |
| 346 | return set() |
| 347 | |
| 348 | def get_all_permissions(self, obj=None): |
| 349 | return _user_get_all_permissions(self, obj=obj) |
| 350 | |
| 351 | def has_perm(self, perm, obj=None): |
| 352 | return _user_has_perm(self, perm, obj=obj) |
| 353 | |
| 354 | def has_perms(self, perm_list, obj=None): |
| 355 | for perm in perm_list: |
| 356 | if not self.has_perm(perm, obj): |
| 357 | return False |
| 358 | return True |
| 359 | |
| 360 | def has_module_perms(self, module): |
| 361 | return _user_has_module_perms(self, module) |
| 362 | |
| 363 | @property |
| 364 | def is_anonymous(self): |
| 365 | return CallableTrue |
| 366 | |
| 367 | @property |
| 368 | def is_authenticated(self): |
| 369 | return CallableFalse |
| 370 | |
| 371 | def get_username(self): |
| 372 | return self.username |
| 373 | |
| 374 | |
380 | | @python_2_unicode_compatible |
381 | | class AnonymousUser(object): |
382 | | id = None |
383 | | pk = None |
384 | | username = '' |
385 | | is_staff = False |
386 | | is_active = False |
387 | | is_superuser = False |
388 | | _groups = EmptyManager(Group) |
389 | | _user_permissions = EmptyManager(Permission) |
390 | | |
391 | | def __init__(self): |
392 | | pass |
393 | | |
394 | | def __str__(self): |
395 | | return 'AnonymousUser' |
396 | | |
397 | | def __eq__(self, other): |
398 | | return isinstance(other, self.__class__) |
399 | | |
400 | | def __ne__(self, other): |
401 | | return not self.__eq__(other) |
402 | | |
403 | | def __hash__(self): |
404 | | return 1 # instances always return the same hash value |
405 | | |
406 | | def save(self): |
407 | | raise NotImplementedError("Django doesn't provide a DB representation for AnonymousUser.") |
408 | | |
409 | | def delete(self): |
410 | | raise NotImplementedError("Django doesn't provide a DB representation for AnonymousUser.") |
411 | | |
412 | | def set_password(self, raw_password): |
413 | | raise NotImplementedError("Django doesn't provide a DB representation for AnonymousUser.") |
414 | | |
415 | | def check_password(self, raw_password): |
416 | | raise NotImplementedError("Django doesn't provide a DB representation for AnonymousUser.") |
417 | | |
418 | | @property |
419 | | def groups(self): |
420 | | return self._groups |
421 | | |
422 | | @property |
423 | | def user_permissions(self): |
424 | | return self._user_permissions |
425 | | |
426 | | def get_group_permissions(self, obj=None): |
427 | | return set() |
428 | | |
429 | | def get_all_permissions(self, obj=None): |
430 | | return _user_get_all_permissions(self, obj=obj) |
431 | | |
432 | | def has_perm(self, perm, obj=None): |
433 | | return _user_has_perm(self, perm, obj=obj) |
434 | | |
435 | | def has_perms(self, perm_list, obj=None): |
436 | | for perm in perm_list: |
437 | | if not self.has_perm(perm, obj): |
438 | | return False |
439 | | return True |
440 | | |
441 | | def has_module_perms(self, module): |
442 | | return _user_has_module_perms(self, module) |
443 | | |
444 | | @property |
445 | | def is_anonymous(self): |
446 | | return CallableTrue |
447 | | |
448 | | @property |
449 | | def is_authenticated(self): |
450 | | return CallableFalse |
451 | | |
452 | | def get_username(self): |
453 | | return self.username |
| 466 | |